зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1691781 - Make Linux tab bar use the darker of the highlight / highlighttext colors. r=dao
Some GTK themes use very soft colors for selection backgrounds, using darker colors for the text. This makes the tab and focus outlines in the tab bar not have sufficient contrast with usual backgrounds. I needed to do this for bug 1690778, but it seems worth doing it on the front-end as well. Differential Revision: https://phabricator.services.mozilla.com/D104547
This commit is contained in:
Родитель
2a5a3fe221
Коммит
d96854eeb1
|
@ -32,7 +32,7 @@
|
|||
}
|
||||
|
||||
#tabbrowser-tabs {
|
||||
--tab-line-color: highlight;
|
||||
--tab-line-color: -moz-accent-color;
|
||||
}
|
||||
|
||||
:root:-moz-lwtheme {
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
%define urlbarSearchButtonWidth calc(16px + 2 * @identityBoxPaddingInline@)
|
||||
|
||||
:root {
|
||||
--toolbar-field-focus-border-color: Highlight;
|
||||
--toolbar-field-focus-border-color: -moz-accent-color;
|
||||
|
||||
/* 28x28 box - 16x16 image = 12x12 padding, 6 on each side */
|
||||
--urlbar-icon-padding: 6px;
|
||||
|
|
|
@ -227,6 +227,14 @@ pub enum SystemColor {
|
|||
MozMacActiveSourceListSelection,
|
||||
MozMacTooltip,
|
||||
|
||||
/// Theme accent color.
|
||||
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
|
||||
MozAccentColor,
|
||||
|
||||
/// Foreground for the accent color.
|
||||
#[parse(condition = "ParserContext::in_ua_or_chrome_sheet")]
|
||||
MozAccentColorForeground,
|
||||
|
||||
/// Accent color for title bar.
|
||||
MozWinAccentcolor,
|
||||
/// Color from drawing text over the accent color.
|
||||
|
|
|
@ -195,12 +195,14 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
case ColorID::MozCellhighlight:
|
||||
case ColorID::MozHtmlCellhighlight:
|
||||
case ColorID::Highlight:
|
||||
case ColorID::MozAccentColor:
|
||||
// background of selected item
|
||||
aColor = NS_RGB(0xfa, 0xd1, 0x84);
|
||||
break;
|
||||
case ColorID::MozCellhighlighttext:
|
||||
case ColorID::MozHtmlCellhighlighttext:
|
||||
case ColorID::Highlighttext:
|
||||
case ColorID::MozAccentColorForeground:
|
||||
case ColorID::Fieldtext:
|
||||
aColor = NS_RGB(0x1a, 0x1a, 0x1a);
|
||||
break;
|
||||
|
|
|
@ -191,6 +191,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
aColor = ProcessSelectionBackground(mColorTextSelectBackgroundDisabled);
|
||||
break;
|
||||
case ColorID::Highlight: // CSS2 color
|
||||
case ColorID::MozAccentColor:
|
||||
aColor = mColorHighlight;
|
||||
break;
|
||||
case ColorID::MozMenuhover:
|
||||
|
@ -200,6 +201,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
aColor = mColorTextSelectForeground;
|
||||
break;
|
||||
case ColorID::Highlighttext: // CSS2 color
|
||||
case ColorID::MozAccentColorForeground:
|
||||
case ColorID::MozMenuhovertext:
|
||||
aColor = mColorMenuHoverText;
|
||||
break;
|
||||
|
|
|
@ -385,6 +385,12 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
case ColorID::Highlight: // preference selected item,
|
||||
aColor = mTextSelectedBackground;
|
||||
break;
|
||||
case ColorID::MozAccentColor:
|
||||
aColor = mAccentColor;
|
||||
break;
|
||||
case ColorID::MozAccentColorForeground:
|
||||
aColor = mAccentColorForeground;
|
||||
break;
|
||||
case ColorID::WidgetSelectForeground:
|
||||
case ColorID::TextSelectForeground:
|
||||
case ColorID::IMESelectedRawTextForeground:
|
||||
|
@ -1298,6 +1304,14 @@ void nsLookAndFeel::EnsureInit() {
|
|||
// fall back to the regular text view style.
|
||||
GrabSelectionColors(style);
|
||||
}
|
||||
|
||||
// Accent is the darker of the selection background / foreground.
|
||||
mAccentColor = mTextSelectedBackground;
|
||||
mAccentColorForeground = mTextSelectedText;
|
||||
if (RelativeLuminanceUtils::Compute(mAccentColor) >
|
||||
RelativeLuminanceUtils::Compute(mAccentColorForeground)) {
|
||||
std::exchange(mAccentColor, mAccentColorForeground);
|
||||
}
|
||||
}
|
||||
|
||||
// Button text color
|
||||
|
|
|
@ -92,6 +92,8 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
nscolor mMozCellHighlightText = kBlack;
|
||||
nscolor mTextSelectedText = kBlack;
|
||||
nscolor mTextSelectedBackground = kWhite;
|
||||
nscolor mAccentColor = kWhite;
|
||||
nscolor mAccentColorForeground = kWhite;
|
||||
nscolor mMozScrollbar = kWhite;
|
||||
nscolor mInfoBarText = kBlack;
|
||||
nscolor mMozColHeaderText = kBlack;
|
||||
|
|
|
@ -67,13 +67,11 @@ static LayoutDeviceIntCoord SnapBorderWidth(
|
|||
return aLuminance >= 0.18f ? aLuminance * aFactor : aLuminance / aFactor;
|
||||
}
|
||||
|
||||
static nscolor ThemedAccentColor(bool aDarker) {
|
||||
static nscolor ThemedAccentColor(bool aBackground) {
|
||||
MOZ_ASSERT(StaticPrefs::widget_non_native_use_theme_accent());
|
||||
nscolor a = LookAndFeel::GetColor(LookAndFeel::ColorID::Highlight);
|
||||
nscolor b = LookAndFeel::GetColor(LookAndFeel::ColorID::Highlighttext);
|
||||
const bool darker =
|
||||
RelativeLuminanceUtils::Compute(b) > RelativeLuminanceUtils::Compute(a);
|
||||
nscolor color = darker == aDarker ? a : b;
|
||||
nscolor color = LookAndFeel::GetColor(
|
||||
aBackground ? LookAndFeel::ColorID::MozAccentColor
|
||||
: LookAndFeel::ColorID::MozAccentColorForeground);
|
||||
if (NS_GET_A(color) != 0xff) {
|
||||
// Blend with white, ensuring the color is opaque to avoid surprises if we
|
||||
// overdraw.
|
||||
|
|
|
@ -227,6 +227,8 @@ const char nsXPLookAndFeel::sColorPrefs[][41] = {
|
|||
"ui.-moz-mac-source-list-selection",
|
||||
"ui.-moz-mac-active-source-list-selection",
|
||||
"ui.-moz-mac-tooltip",
|
||||
"ui.-moz-accent-color",
|
||||
"ui.-moz-accent-color-foreground",
|
||||
"ui.-moz-win-accentcolor",
|
||||
"ui.-moz-win-accentcolortext",
|
||||
"ui.-moz-win-mediatext",
|
||||
|
|
|
@ -226,6 +226,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
idx = COLOR_GRAYTEXT;
|
||||
break;
|
||||
case ColorID::Highlight:
|
||||
case ColorID::MozAccentColor:
|
||||
case ColorID::MozHtmlCellhighlight:
|
||||
case ColorID::MozMenuhover:
|
||||
idx = COLOR_HIGHLIGHT;
|
||||
|
@ -244,6 +245,7 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
}
|
||||
// Fall through
|
||||
case ColorID::Highlighttext:
|
||||
case ColorID::MozAccentColorForeground:
|
||||
case ColorID::MozHtmlCellhighlighttext:
|
||||
idx = COLOR_HIGHLIGHTTEXT;
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче