Bug 1671401 - Use separate Scrollbar and ThemedScrollbar ColorIDs. r=spohl

Otherwise on Windows, we have a ColorID::Scrollbar but not any of the other scrollbar part
colors, and the Windows-provided value for Scrollbar doesn't work well
with the default values for the other scrollbar parts that come from the
non-native theme.

Differential Revision: https://phabricator.services.mozilla.com/D93728
This commit is contained in:
Cameron McCormack 2020-10-16 12:49:47 +00:00
Родитель 7c5c0899bf
Коммит d7eee82ba1
5 изменённых файлов: 69 добавлений и 58 удалений

Просмотреть файл

@ -108,15 +108,17 @@ pub enum SystemColor {
#[css(skip)] #[css(skip)]
SpellCheckerUnderline, SpellCheckerUnderline,
#[css(skip)] #[css(skip)]
ScrollbarInactive, ThemedScrollbar,
#[css(skip)] #[css(skip)]
ScrollbarThumb, ThemedScrollbarInactive,
#[css(skip)] #[css(skip)]
ScrollbarThumbHover, ThemedScrollbarThumb,
#[css(skip)] #[css(skip)]
ScrollbarThumbActive, ThemedScrollbarThumbHover,
#[css(skip)] #[css(skip)]
ScrollbarThumbInactive, ThemedScrollbarThumbActive,
#[css(skip)]
ThemedScrollbarThumbInactive,
Activeborder, Activeborder,
Activecaption, Activecaption,
Appworkspace, Appworkspace,

Просмотреть файл

@ -273,12 +273,13 @@ LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
constexpr IntID kIntIdsToCache[] = {IntID::SystemUsesDarkTheme, constexpr IntID kIntIdsToCache[] = {IntID::SystemUsesDarkTheme,
IntID::PrefersReducedMotion, IntID::PrefersReducedMotion,
IntID::UseAccessibilityTheme}; IntID::UseAccessibilityTheme};
constexpr ColorID kColorIdsToCache[] = {ColorID::Scrollbar, constexpr ColorID kColorIdsToCache[] = {
ColorID::ScrollbarInactive, ColorID::ThemedScrollbar,
ColorID::ScrollbarThumb, ColorID::ThemedScrollbarInactive,
ColorID::ScrollbarThumbHover, ColorID::ThemedScrollbarThumb,
ColorID::ScrollbarThumbActive, ColorID::ThemedScrollbarThumbHover,
ColorID::ScrollbarThumbInactive}; ColorID::ThemedScrollbarThumbActive,
ColorID::ThemedScrollbarThumbInactive};
for (IntID id : kIntIdsToCache) { for (IntID id : kIntIdsToCache) {
cache.mInts.AppendElement(LookAndFeelInt{.id = id, .value = GetInt(id)}); cache.mInts.AppendElement(LookAndFeelInt{.id = id, .value = GetInt(id)});
@ -310,23 +311,23 @@ void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) {
} }
for (const auto& entry : aCache.mColors) { for (const auto& entry : aCache.mColors) {
switch (entry.id) { switch (entry.id) {
case ColorID::Scrollbar: case ColorID::ThemedScrollbar:
mMozScrollbar = entry.color; mThemedScrollbar = entry.color;
break; break;
case ColorID::ScrollbarInactive: case ColorID::ThemedScrollbarInactive:
mScrollbarInactive = entry.color; mThemedScrollbarInactive = entry.color;
break; break;
case ColorID::ScrollbarThumb: case ColorID::ThemedScrollbarThumb:
mScrollbarThumb = entry.color; mThemedScrollbarThumb = entry.color;
break; break;
case ColorID::ScrollbarThumbHover: case ColorID::ThemedScrollbarThumbHover:
mScrollbarThumbHover = entry.color; mThemedScrollbarThumbHover = entry.color;
break; break;
case ColorID::ScrollbarThumbActive: case ColorID::ThemedScrollbarThumbActive:
mScrollbarThumbActive = entry.color; mThemedScrollbarThumbActive = entry.color;
break; break;
case ColorID::ScrollbarThumbInactive: case ColorID::ThemedScrollbarThumbInactive:
mScrollbarThumbInactive = entry.color; mThemedScrollbarThumbInactive = entry.color;
break; break;
default: default:
MOZ_ASSERT_UNREACHABLE("Bogus Color ID in cache"); MOZ_ASSERT_UNREACHABLE("Bogus Color ID in cache");
@ -413,20 +414,23 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
case ColorID::SpellCheckerUnderline: case ColorID::SpellCheckerUnderline:
aColor = NS_RGB(0xff, 0, 0); aColor = NS_RGB(0xff, 0, 0);
break; break;
case ColorID::ScrollbarInactive: case ColorID::ThemedScrollbar:
aColor = mScrollbarInactive; aColor = mThemedScrollbar;
break; break;
case ColorID::ScrollbarThumb: case ColorID::ThemedScrollbarInactive:
aColor = mScrollbarThumb; aColor = mThemedScrollbarInactive;
break; break;
case ColorID::ScrollbarThumbHover: case ColorID::ThemedScrollbarThumb:
aColor = mScrollbarThumbHover; aColor = mThemedScrollbarThumb;
break; break;
case ColorID::ScrollbarThumbActive: case ColorID::ThemedScrollbarThumbHover:
aColor = mScrollbarThumbActive; aColor = mThemedScrollbarThumbHover;
break; break;
case ColorID::ScrollbarThumbInactive: case ColorID::ThemedScrollbarThumbActive:
aColor = mScrollbarThumbInactive; aColor = mThemedScrollbarThumbActive;
break;
case ColorID::ThemedScrollbarThumbInactive:
aColor = mThemedScrollbarThumbInactive;
break; break;
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors // css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
@ -1080,25 +1084,25 @@ void nsLookAndFeel::EnsureInit() {
style = GetStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL); style = GetStyleContext(MOZ_GTK_SCROLLBAR_TROUGH_VERTICAL);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
&color); &color);
mMozScrollbar = GDK_RGBA_TO_NS_RGBA(color); mMozScrollbar = mThemedScrollbar = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_BACKDROP, gtk_style_context_get_background_color(style, GTK_STATE_FLAG_BACKDROP,
&color); &color);
mScrollbarInactive = GDK_RGBA_TO_NS_RGBA(color); mThemedScrollbarInactive = GDK_RGBA_TO_NS_RGBA(color);
style = GetStyleContext(MOZ_GTK_SCROLLBAR_THUMB_VERTICAL); style = GetStyleContext(MOZ_GTK_SCROLLBAR_THUMB_VERTICAL);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
&color); &color);
mScrollbarThumb = GDK_RGBA_TO_NS_RGBA(color); mThemedScrollbarThumb = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT, gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT,
&color); &color);
mScrollbarThumbHover = GDK_RGBA_TO_NS_RGBA(color); mThemedScrollbarThumbHover = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_background_color( gtk_style_context_get_background_color(
style, GtkStateFlags(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE), style, GtkStateFlags(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE),
&color); &color);
mScrollbarThumbActive = GDK_RGBA_TO_NS_RGBA(color); mThemedScrollbarThumbActive = GDK_RGBA_TO_NS_RGBA(color);
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_BACKDROP, gtk_style_context_get_background_color(style, GTK_STATE_FLAG_BACKDROP,
&color); &color);
mScrollbarThumbInactive = GDK_RGBA_TO_NS_RGBA(color); mThemedScrollbarThumbInactive = GDK_RGBA_TO_NS_RGBA(color);
} }
// The label is not added to a parent widget, but shared for constructing // The label is not added to a parent widget, but shared for constructing

Просмотреть файл

@ -90,11 +90,12 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
nscolor mInfoBarText = kBlack; nscolor mInfoBarText = kBlack;
nscolor mMozColHeaderText = kBlack; nscolor mMozColHeaderText = kBlack;
nscolor mMozColHeaderHoverText = kBlack; nscolor mMozColHeaderHoverText = kBlack;
nscolor mScrollbarInactive = kBlack; nscolor mThemedScrollbar = kWhite;
nscolor mScrollbarThumb = kBlack; nscolor mThemedScrollbarInactive = kWhite;
nscolor mScrollbarThumbHover = kBlack; nscolor mThemedScrollbarThumb = kBlack;
nscolor mScrollbarThumbActive = kBlack; nscolor mThemedScrollbarThumbHover = kBlack;
nscolor mScrollbarThumbInactive = kBlack; nscolor mThemedScrollbarThumbActive = kBlack;
nscolor mThemedScrollbarThumbInactive = kBlack;
char16_t mInvisibleCharacter = 0; char16_t mInvisibleCharacter = 0;
float mCaretRatio = 0.0f; float mCaretRatio = 0.0f;
int32_t mCaretBlinkTime = 0; int32_t mCaretBlinkTime = 0;

Просмотреть файл

@ -879,16 +879,19 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarthumbColor(
if (ui->mScrollbarColor.IsColors()) { if (ui->mScrollbarColor.IsColors()) {
color = ui->mScrollbarColor.AsColors().thumb.CalcColor(aStyle); color = ui->mScrollbarColor.AsColors().thumb.CalcColor(aStyle);
} else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) { } else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbInactive, color = LookAndFeel::GetColor(
sScrollbarThumbColor.ToABGR()); LookAndFeel::ColorID::ThemedScrollbarThumbInactive,
sScrollbarThumbColor.ToABGR());
} else if (aElementState.HasAllStates(NS_EVENT_STATE_ACTIVE)) { } else if (aElementState.HasAllStates(NS_EVENT_STATE_ACTIVE)) {
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbActive, color =
sScrollbarThumbColorActive.ToABGR()); LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarThumbActive,
sScrollbarThumbColorActive.ToABGR());
} else if (aElementState.HasAllStates(NS_EVENT_STATE_HOVER)) { } else if (aElementState.HasAllStates(NS_EVENT_STATE_HOVER)) {
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbHover, color =
sScrollbarThumbColorHover.ToABGR()); LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarThumbHover,
sScrollbarThumbColorHover.ToABGR());
} else { } else {
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumb, color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarThumb,
sScrollbarThumbColor.ToABGR()); sScrollbarThumbColor.ToABGR());
} }
return gfx::sRGBColor::FromABGR(color); return gfx::sRGBColor::FromABGR(color);
@ -902,10 +905,10 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarColor(
if (ui->mScrollbarColor.IsColors()) { if (ui->mScrollbarColor.IsColors()) {
color = ui->mScrollbarColor.AsColors().track.CalcColor(aStyle); color = ui->mScrollbarColor.AsColors().track.CalcColor(aStyle);
} else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) { } else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarInactive, color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarInactive,
sScrollbarColor.ToABGR()); sScrollbarColor.ToABGR());
} else { } else {
color = LookAndFeel::GetColor(LookAndFeel::ColorID::Scrollbar, color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbar,
sScrollbarColor.ToABGR()); sScrollbarColor.ToABGR());
} }
if (aIsRoot) { if (aIsRoot) {

Просмотреть файл

@ -146,11 +146,12 @@ const char nsXPLookAndFeel::sColorPrefs[][41] = {
"ui.IMESelectedConvertedTextForeground", "ui.IMESelectedConvertedTextForeground",
"ui.IMESelectedConvertedTextUnderline", "ui.IMESelectedConvertedTextUnderline",
"ui.SpellCheckerUnderline", "ui.SpellCheckerUnderline",
"ui.scrollbarInactive", "ui.themedScrollbar",
"ui.scrollbarThumb", "ui.themedScrollbarInactive",
"ui.scrollbarThumbHover", "ui.themedScrollbarThumb",
"ui.scrollbarThumbActive", "ui.themedScrollbarThumbHover",
"ui.scrollbarThumbInactive", "ui.themedScrollbarThumbActive",
"ui.themedScrollbarThumbInactive",
"ui.activeborder", "ui.activeborder",
"ui.activecaption", "ui.activecaption",
"ui.appworkspace", "ui.appworkspace",