зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1843044 - Make titlebar system colors on windows and macOS reflect reality. r=mac-reviewers,bradwerth
I'm about to use them more in the front-end, and it'd be nice if these did the right thing. For that, make our stand-ins system return the Firefox titlebar colors. Put the Windows "show accent color on title bars" code behind a pref because we don't support it. I filed bug 1851155 to consider enabling it by default. After this changes there's only one place to tweak the (cross-platform) titlebar colors (in nsXPLookAndFeel), with high-contrast mode and so on behaving correctly by default. The macOS special-case for the titlebar is to preserve the current behavior from bug 1711261. If we want to change that to also apply to dark mode or what not, we can do it in a follow-up. I didn't bother putting the new colors in test_bug232227. That only (tries to) test that we return fixed colors when the rfp/stand-ins prefs are on. But we don't need to test the exact value of all the colors. Differential Revision: https://phabricator.services.mozilla.com/D187278
This commit is contained in:
Родитель
b3f09128c0
Коммит
f4531c594a
|
@ -16,21 +16,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=232227
|
|||
|
||||
function runTest(testCanvasColors) {
|
||||
var colorNames = [
|
||||
[ "ActiveBorder", 0xB4, 0xB4, 0xB4 ],
|
||||
[ "ActiveCaption", 0x99, 0xB4, 0xD1 ],
|
||||
[ "AppWorkspace", 0xAB, 0xAB, 0xAB ],
|
||||
[ "Background", 0x00, 0x00, 0x00 ],
|
||||
[ "ButtonFace", 0xe9, 0xe9, 0xed],
|
||||
[ "ButtonHighlight", 0xFF, 0xFF, 0xFF ],
|
||||
[ "ButtonShadow", 0xA0, 0xA0, 0xA0 ],
|
||||
[ "ButtonText", 0x00, 0x00, 0x00 ],
|
||||
[ "CaptionText", 0x00, 0x00, 0x00 ],
|
||||
[ "GrayText", 0x6D, 0x6D, 0x6D ],
|
||||
[ "Highlight", 0x33, 0x99, 0xFF ],
|
||||
[ "HighlightText", 0xFF, 0xFF, 0xFF ],
|
||||
[ "InactiveBorder", 0xF4, 0xF7, 0xFC ],
|
||||
[ "InactiveCaption", 0xBF, 0xCD, 0xDB ],
|
||||
[ "InactiveCaptionText", 0x43, 0x4E, 0x54 ],
|
||||
[ "InfoBackground", 0xFF, 0xFF, 0xE1 ],
|
||||
[ "InfoText", 0x00, 0x00, 0x00 ],
|
||||
[ "Menu", 0xF0, 0xF0, 0xF0 ],
|
||||
|
|
|
@ -15534,6 +15534,13 @@
|
|||
value: false
|
||||
mirror: always
|
||||
|
||||
# Whether to use the accent color for the titlebar, if the relevant Windows
|
||||
# setting says so. See bug 1851155.
|
||||
- name: widget.windows.titlebar-accent.enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
- name: widget.windows.window_occlusion_tracking_display_state.enabled
|
||||
type: bool
|
||||
value: false
|
||||
|
|
|
@ -176,7 +176,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
|||
color = nsCocoaFeatures::OnMontereyOrLater() ? GetColorFromNSColor(NSColor.controlTextColor)
|
||||
: NS_RGB(0xFF, 0xFF, 0xFF);
|
||||
break;
|
||||
case ColorID::Captiontext:
|
||||
case ColorID::Menutext:
|
||||
case ColorID::Infotext:
|
||||
color = GetColorFromNSColor(NSColor.textColor);
|
||||
|
@ -184,12 +183,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
|||
case ColorID::Windowtext:
|
||||
color = GetColorFromNSColor(NSColor.windowFrameTextColor);
|
||||
break;
|
||||
case ColorID::Activecaption:
|
||||
color = GetColorFromNSColor(NSColor.gridColor);
|
||||
break;
|
||||
case ColorID::Activeborder:
|
||||
color = GetColorFromNSColor(NSColor.keyboardFocusIndicatorColor);
|
||||
break;
|
||||
case ColorID::Appworkspace:
|
||||
color = NS_RGB(0xFF, 0xFF, 0xFF);
|
||||
break;
|
||||
|
@ -208,9 +201,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
|||
case ColorID::Buttonhighlight:
|
||||
color = GetColorFromNSColor(NSColor.selectedControlColor);
|
||||
break;
|
||||
case ColorID::Inactivecaptiontext:
|
||||
color = NS_RGB(0x45, 0x45, 0x45);
|
||||
break;
|
||||
case ColorID::Scrollbar:
|
||||
color = GetColorFromNSColor(NSColor.scrollBarColor);
|
||||
break;
|
||||
|
@ -244,8 +234,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
|||
}
|
||||
case ColorID::Field:
|
||||
case ColorID::MozCombobox:
|
||||
case ColorID::Inactiveborder:
|
||||
case ColorID::Inactivecaption:
|
||||
case ColorID::MozDialog:
|
||||
color = GetColorFromNSColor(NSColor.controlBackgroundColor);
|
||||
break;
|
||||
|
@ -306,9 +294,24 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme, nscolor
|
|||
case ColorID::Accentcolor:
|
||||
color = GetColorFromNSColor([NSColor controlAccentColor]);
|
||||
break;
|
||||
|
||||
case ColorID::Inactivecaption:
|
||||
case ColorID::Activecaption: {
|
||||
if (aScheme == ColorScheme::Light &&
|
||||
NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast) {
|
||||
// This has better contrast than the stand-in colors.
|
||||
aColor = GetColorFromNSColor(NSColor.windowBackgroundColor);
|
||||
return NS_OK;
|
||||
}
|
||||
[[fallthrough]];
|
||||
}
|
||||
case ColorID::Marktext:
|
||||
case ColorID::Mark:
|
||||
case ColorID::SpellCheckerUnderline:
|
||||
case ColorID::Captiontext:
|
||||
case ColorID::Inactivecaptiontext:
|
||||
case ColorID::Activeborder:
|
||||
case ColorID::Inactiveborder:
|
||||
aColor = GetStandinForNativeColor(aID, aScheme);
|
||||
return NS_OK;
|
||||
default:
|
||||
|
|
|
@ -625,9 +625,15 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
|
|||
COLOR(SpellCheckerUnderline, 0xff, 0x00, 0x00)
|
||||
COLOR(TextSelectDisabledBackground, 0xaa, 0xaa, 0xaa)
|
||||
|
||||
// CSS 2 colors:
|
||||
// Titlebar colors
|
||||
COLOR(Activeborder, 0xB4, 0xB4, 0xB4)
|
||||
COLOR(Activecaption, 0x99, 0xB4, 0xD1)
|
||||
COLOR(Inactiveborder, 0xB4, 0xB4, 0xB4)
|
||||
COLOR(Activecaption, 0xF0, 0xF0, 0xF4)
|
||||
COLOR(Inactivecaption, 0xF0, 0xF0, 0xF4)
|
||||
COLOR(Captiontext, 0x00, 0x00, 0x00)
|
||||
COLOR(Inactivecaptiontext, 0x00, 0x00, 0x00)
|
||||
|
||||
// CSS 2 colors:
|
||||
COLOR(Appworkspace, 0xAB, 0xAB, 0xAB)
|
||||
COLOR(Background, 0x00, 0x00, 0x00)
|
||||
COLOR(Buttonhighlight, 0xFF, 0xFF, 0xFF)
|
||||
|
@ -643,13 +649,9 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
|
|||
COLOR(Buttontext, 0x00, 0x00, 0x00)
|
||||
COLOR(MozComboboxtext, 0x00, 0x00, 0x00)
|
||||
|
||||
COLOR(Captiontext, 0x00, 0x00, 0x00)
|
||||
COLOR(Graytext, 0x6D, 0x6D, 0x6D)
|
||||
COLOR(Highlight, 0x33, 0x99, 0xFF)
|
||||
COLOR(Highlighttext, 0xFF, 0xFF, 0xFF)
|
||||
COLOR(Inactiveborder, 0xF4, 0xF7, 0xFC)
|
||||
COLOR(Inactivecaption, 0xBF, 0xCD, 0xDB)
|
||||
COLOR(Inactivecaptiontext, 0x43, 0x4E, 0x54)
|
||||
COLOR(Infobackground, 0xFF, 0xFF, 0xE1)
|
||||
COLOR(Infotext, 0x00, 0x00, 0x00)
|
||||
COLOR(Menu, 0xF0, 0xF0, 0xF0)
|
||||
|
@ -752,6 +754,8 @@ Maybe<nscolor> nsXPLookAndFeel::GenericDarkColor(ColorID aID) {
|
|||
case ColorID::MozButtonhovertext:
|
||||
case ColorID::MozButtonactivetext:
|
||||
case ColorID::Captiontext:
|
||||
case ColorID::Inactivecaptiontext: // TODO(emilio): Maybe make
|
||||
// Inactivecaptiontext Graytext?
|
||||
color = kWindowText;
|
||||
break;
|
||||
case ColorID::Buttonshadow:
|
||||
|
@ -763,7 +767,6 @@ Maybe<nscolor> nsXPLookAndFeel::GenericDarkColor(ColorID aID) {
|
|||
case ColorID::Graytext: // opacity: 0.4 of kWindowText blended over the
|
||||
// "Window" background color, which happens to be
|
||||
// the same :-)
|
||||
case ColorID::Inactivecaptiontext:
|
||||
color = NS_ComposeColors(kWindowBackground, NS_RGBA(251, 251, 254, 102));
|
||||
break;
|
||||
case ColorID::MozCellhighlight:
|
||||
|
|
|
@ -795,14 +795,19 @@ auto nsLookAndFeel::ComputeTitlebarColors() -> TitlebarColors {
|
|||
GetColorForSysColorIndex(COLOR_INACTIVEBORDER)};
|
||||
|
||||
if (!nsUXThemeData::IsHighContrastOn()) {
|
||||
// This is our current default light theme behavior.
|
||||
result.mActiveLight =
|
||||
result.mInactiveLight = {GetColorForSysColorIndex(COLOR_3DFACE),
|
||||
GetColorForSysColorIndex(COLOR_WINDOWTEXT),
|
||||
GetColorForSysColorIndex(COLOR_ACTIVEBORDER)};
|
||||
// Use our non-native colors.
|
||||
result.mActiveLight = {
|
||||
GetStandinForNativeColor(ColorID::Activecaption, ColorScheme::Light),
|
||||
GetStandinForNativeColor(ColorID::Captiontext, ColorScheme::Light),
|
||||
GetStandinForNativeColor(ColorID::Activeborder, ColorScheme::Light)};
|
||||
result.mInactiveLight = {
|
||||
GetStandinForNativeColor(ColorID::Inactivecaption, ColorScheme::Light),
|
||||
GetStandinForNativeColor(ColorID::Inactivecaptiontext,
|
||||
ColorScheme::Light),
|
||||
GetStandinForNativeColor(ColorID::Inactiveborder, ColorScheme::Light)};
|
||||
}
|
||||
|
||||
// Foreground and background taken from our dark theme.
|
||||
// Our dark colors are always non-native.
|
||||
result.mActiveDark = {*GenericDarkColor(ColorID::Activecaption),
|
||||
*GenericDarkColor(ColorID::Captiontext),
|
||||
*GenericDarkColor(ColorID::Activeborder)};
|
||||
|
@ -852,32 +857,43 @@ auto nsLookAndFeel::ComputeTitlebarColors() -> TitlebarColors {
|
|||
result.mUseAccent =
|
||||
NS_SUCCEEDED(dwmKey->ReadIntValue(u"ColorPrevalence"_ns, &prevalence)) &&
|
||||
prevalence == 1;
|
||||
if (result.mUseAccent) {
|
||||
// TODO(emilio): Consider reading ColorizationColorBalance to compute a
|
||||
// more correct border color, see [1]. Though for opaque accent colors this
|
||||
// isn't needed.
|
||||
//
|
||||
// [1]:
|
||||
// https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:ui/color/win/accent_color_observer.cc;l=42;drc=9d4eb7ed25296abba8fd525a6bdd0fdbf4bcdd9f
|
||||
result.mActiveLight = result.mActiveDark = {
|
||||
*result.mAccent, *result.mAccentText, *result.mAccent};
|
||||
if (result.mAccentInactive) {
|
||||
result.mInactiveLight = result.mInactiveDark = {
|
||||
*result.mAccentInactive, *result.mAccentInactiveText,
|
||||
*result.mAccentInactive};
|
||||
} else {
|
||||
// The 153 matches the .6 opacity from browser-aero.css, which says it
|
||||
// was calculated to match the opacity change of Windows Explorer
|
||||
// titlebar text change for inactive windows.
|
||||
result.mInactiveLight = {
|
||||
NS_ComposeColors(*result.mAccent, NS_RGBA(255, 255, 255, 153)),
|
||||
NS_ComposeColors(*result.mAccentText, NS_RGBA(255, 255, 255, 153)),
|
||||
NS_RGB(57, 57, 57)};
|
||||
result.mInactiveDark = {
|
||||
NS_ComposeColors(*result.mAccent, NS_RGBA(0, 0, 0, 153)),
|
||||
NS_ComposeColors(*result.mAccentText, NS_RGBA(0, 0, 0, 153)),
|
||||
NS_RGB(57, 57, 57)};
|
||||
}
|
||||
if (!result.mUseAccent) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO(emilio): Consider reading ColorizationColorBalance to compute a
|
||||
// more correct border color, see [1]. Though for opaque accent colors this
|
||||
// isn't needed.
|
||||
//
|
||||
// [1]:
|
||||
// https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:ui/color/win/accent_color_observer.cc;l=42;drc=9d4eb7ed25296abba8fd525a6bdd0fdbf4bcdd9f
|
||||
result.mActiveDark.mBorder = result.mActiveLight.mBorder = *result.mAccent;
|
||||
result.mInactiveDark.mBorder = result.mInactiveLight.mBorder =
|
||||
result.mAccentInactive.valueOr(NS_RGB(57, 57, 57));
|
||||
if (!StaticPrefs::widget_windows_titlebar_accent_enabled()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.mActiveLight.mBg = result.mActiveDark.mBg = *result.mAccent;
|
||||
result.mActiveLight.mFg = result.mActiveDark.mFg = *result.mAccentText;
|
||||
if (result.mAccentInactive) {
|
||||
result.mInactiveLight.mBg = result.mInactiveDark.mBg =
|
||||
*result.mAccentInactive;
|
||||
result.mInactiveLight.mFg = result.mInactiveDark.mFg =
|
||||
*result.mAccentInactiveText;
|
||||
} else {
|
||||
// The 153 matches the .6 opacity from browser-aero.css, which says it
|
||||
// was calculated to match the opacity change of Windows Explorer
|
||||
// titlebar text change for inactive windows.
|
||||
result.mInactiveLight.mBg =
|
||||
NS_ComposeColors(*result.mAccent, NS_RGBA(255, 255, 255, 153));
|
||||
result.mInactiveLight.mFg =
|
||||
NS_ComposeColors(*result.mAccentText, NS_RGBA(255, 255, 255, 153));
|
||||
|
||||
result.mInactiveDark.mBg =
|
||||
NS_ComposeColors(*result.mAccent, NS_RGBA(0, 0, 0, 153));
|
||||
result.mInactiveDark.mFg =
|
||||
NS_ComposeColors(*result.mAccentText, NS_RGBA(0, 0, 0, 153));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче