Skip to content

Commit

Permalink
Bug 1869299 - Generalize -moz-mac-sidebar into a cross-platform -moz-…
Browse files Browse the repository at this point in the history
…sidebar{,text,border} set. r=dao,desktop-theme-reviewers,win-reviewers,gstoll

This will be useful for Adwaita. Keep the field colors in this patch
tho.

Differential Revision: https://phabricator.services.mozilla.com/D196150
  • Loading branch information
emilio committed Dec 12, 2023
1 parent d1aa4ad commit b21a492
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 18 deletions.
4 changes: 0 additions & 4 deletions browser/themes/linux/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

@namespace html url("http://www.w3.org/1999/xhtml");

:root {
--sidebar-border-color: ThreeDShadow;
}

/**
* We intentionally do not include browser-custom-colors.css,
* instead choosing to fall back to system colours and transparencies
Expand Down
3 changes: 0 additions & 3 deletions browser/themes/osx/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

:root {
--arrowpanel-field-background: light-dark(rgba(249, 249, 250, .3), rgba(12, 12, 13, .3));

--sidebar-border-color: hsla(240, 5%, 5%, .1);
--sidebar-background-color: -moz-mac-sidebar;
}

#browser,
Expand Down
2 changes: 1 addition & 1 deletion browser/themes/osx/places/organizer.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/* Places Organizer Sidebars */

#placesList {
background-color: -moz-mac-sidebar;
background-color: -moz-sidebar;
width: 160px;
min-width: 100px;
max-width: 400px;
Expand Down
5 changes: 3 additions & 2 deletions browser/themes/shared/sidebar.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
@namespace html url("http://www.w3.org/1999/xhtml");

:root {
--sidebar-background-color: Field;
--sidebar-text-color: FieldText;
--sidebar-background-color: -moz-sidebar;
--sidebar-text-color: -moz-sidebartext;
--sidebar-border-color: -moz-sidebarborder;
}

#sidebar-box {
Expand Down
4 changes: 0 additions & 4 deletions browser/themes/windows/browser.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
@import url("chrome://browser/skin/contextmenu.css");
@import url("chrome://browser/skin/browser-custom-colors.css");

:root {
--sidebar-border-color: ThreeDLightShadow;
}

#menubar-items {
flex-direction: column; /* for flex hack */
justify-content: normal; /* align the menubar to the top also in customize mode */
Expand Down
10 changes: 8 additions & 2 deletions servo/components/style/values/specified/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,15 @@ pub enum SystemColor {
/// Text color of disabled text on toolbars.
#[parse(condition = "ParserContext::chrome_rules_enabled")]
MozMacDisabledtoolbartext,
/// The background of a macOS sidebar.
/// The background of a sidebar.
#[parse(condition = "ParserContext::chrome_rules_enabled")]
MozMacSidebar,
MozSidebar,
/// The foreground color of a sidebar.
#[parse(condition = "ParserContext::chrome_rules_enabled")]
MozSidebartext,
/// The border color of a sidebar.
#[parse(condition = "ParserContext::chrome_rules_enabled")]
MozSidebarborder,

/// Theme accent color.
/// https://drafts.csswg.org/css-color-4/#valdef-system-color-accentcolor
Expand Down
7 changes: 6 additions & 1 deletion widget/cocoa/nsLookAndFeel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,14 @@ static nscolor GetColorFromNSColorWithCustomAlpha(NSColor* aColor,
case ColorID::MozMacDefaultbuttontext:
color = NS_RGB(0xFF, 0xFF, 0xFF);
break;
case ColorID::MozMacSidebar:
case ColorID::MozSidebar:
color = aScheme == ColorScheme::Light ? NS_RGB(0xf6, 0xf6, 0xf6)
: NS_RGB(0x2d, 0x2d, 0x2d);
break;
case ColorID::MozSidebarborder:
// hsla(240, 5%, 5%, .1)
color = NS_RGBA(12, 12, 13, 26);
break;
case ColorID::MozButtonactivetext:
// Pre-macOS 12, pressed buttons were filled with the highlight color and
// the text was white. Starting with macOS 12, pressed (non-default)
Expand All @@ -194,6 +198,7 @@ static nscolor GetColorFromNSColorWithCustomAlpha(NSColor* aColor,
break;
case ColorID::Menutext:
case ColorID::Infotext:
case ColorID::MozSidebartext:
color = GetColorFromNSColor(NSColor.textColor);
break;
case ColorID::Windowtext:
Expand Down
11 changes: 11 additions & 0 deletions widget/gtk/nsLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,15 @@ nsresult nsLookAndFeel::PerThemeData::GetColor(ColorID aID,
case ColorID::Fieldtext:
aColor = mField.mFg;
break;
case ColorID::MozSidebar:
aColor = mSidebar.mBg;
break;
case ColorID::MozSidebartext:
aColor = mSidebar.mFg;
break;
case ColorID::MozSidebarborder:
aColor = mSidebarBorder;
break;
case ColorID::MozButtonhoverface:
aColor = mButtonHover.mBg;
break;
Expand Down Expand Up @@ -2025,6 +2034,7 @@ void nsLookAndFeel::PerThemeData::Init() {
mField.mBg = GDK_RGBA_TO_NS_RGBA(bgColor);
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
mField.mFg = GDK_RGBA_TO_NS_RGBA(color);
mSidebar = mField;

// Selected text and background
{
Expand Down Expand Up @@ -2143,6 +2153,7 @@ void nsLookAndFeel::PerThemeData::Init() {
style = GetStyleContext(MOZ_GTK_FRAME);
GetBorderColors(style, &mFrameOuterLightBorder, &mFrameInnerDarkBorder);
}
mSidebarBorder = mFrameInnerDarkBorder;

// Some themes have a unified menu bar, and support window dragging on it
gboolean supports_menubar_drag = FALSE;
Expand Down
2 changes: 2 additions & 0 deletions widget/gtk/nsLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
nscolor mComboBoxText = kBlack;
ColorPair mField;
ColorPair mWindow;
ColorPair mSidebar;
nscolor mSidebarBorder = kBlack;

nscolor mMozWindowActiveBorder = kBlack;
nscolor mMozWindowInactiveBorder = kBlack;
Expand Down
4 changes: 3 additions & 1 deletion widget/nsXPLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ static const char sColorPrefs[][41] = {
"ui.-moz-mac-defaultbuttontext",
"ui.-moz-mac-focusring",
"ui.-moz_mac_disabledtoolbartext",
"ui.-moz-mac-sidebar",
"ui.-moz-sidebar",
"ui.-moz-sidebartext",
"ui.-moz-sidebarborder",
"ui.accentcolor",
"ui.accentcolortext",
"ui.-moz-autofill-background",
Expand Down
3 changes: 3 additions & 0 deletions widget/windows/nsLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
case ColorID::Threedlightshadow:
case ColorID::Buttonborder:
case ColorID::MozDisabledfield:
case ColorID::MozSidebarborder:
idx = COLOR_3DLIGHT;
break;
case ColorID::Threedshadow:
Expand All @@ -318,10 +319,12 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
case ColorID::MozEventreerow:
case ColorID::MozOddtreerow:
case ColorID::Field:
case ColorID::MozSidebar:
case ColorID::MozCombobox:
idx = COLOR_WINDOW;
break;
case ColorID::Fieldtext:
case ColorID::MozSidebartext:
case ColorID::MozComboboxtext:
idx = COLOR_WINDOWTEXT;
break;
Expand Down

0 comments on commit b21a492

Please sign in to comment.