зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
7c5c0899bf
Коммит
d7eee82ba1
|
@ -108,15 +108,17 @@ pub enum SystemColor {
|
|||
#[css(skip)]
|
||||
SpellCheckerUnderline,
|
||||
#[css(skip)]
|
||||
ScrollbarInactive,
|
||||
ThemedScrollbar,
|
||||
#[css(skip)]
|
||||
ScrollbarThumb,
|
||||
ThemedScrollbarInactive,
|
||||
#[css(skip)]
|
||||
ScrollbarThumbHover,
|
||||
ThemedScrollbarThumb,
|
||||
#[css(skip)]
|
||||
ScrollbarThumbActive,
|
||||
ThemedScrollbarThumbHover,
|
||||
#[css(skip)]
|
||||
ScrollbarThumbInactive,
|
||||
ThemedScrollbarThumbActive,
|
||||
#[css(skip)]
|
||||
ThemedScrollbarThumbInactive,
|
||||
Activeborder,
|
||||
Activecaption,
|
||||
Appworkspace,
|
||||
|
|
|
@ -273,12 +273,13 @@ LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
|||
constexpr IntID kIntIdsToCache[] = {IntID::SystemUsesDarkTheme,
|
||||
IntID::PrefersReducedMotion,
|
||||
IntID::UseAccessibilityTheme};
|
||||
constexpr ColorID kColorIdsToCache[] = {ColorID::Scrollbar,
|
||||
ColorID::ScrollbarInactive,
|
||||
ColorID::ScrollbarThumb,
|
||||
ColorID::ScrollbarThumbHover,
|
||||
ColorID::ScrollbarThumbActive,
|
||||
ColorID::ScrollbarThumbInactive};
|
||||
constexpr ColorID kColorIdsToCache[] = {
|
||||
ColorID::ThemedScrollbar,
|
||||
ColorID::ThemedScrollbarInactive,
|
||||
ColorID::ThemedScrollbarThumb,
|
||||
ColorID::ThemedScrollbarThumbHover,
|
||||
ColorID::ThemedScrollbarThumbActive,
|
||||
ColorID::ThemedScrollbarThumbInactive};
|
||||
|
||||
for (IntID id : kIntIdsToCache) {
|
||||
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) {
|
||||
switch (entry.id) {
|
||||
case ColorID::Scrollbar:
|
||||
mMozScrollbar = entry.color;
|
||||
case ColorID::ThemedScrollbar:
|
||||
mThemedScrollbar = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarInactive:
|
||||
mScrollbarInactive = entry.color;
|
||||
case ColorID::ThemedScrollbarInactive:
|
||||
mThemedScrollbarInactive = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumb:
|
||||
mScrollbarThumb = entry.color;
|
||||
case ColorID::ThemedScrollbarThumb:
|
||||
mThemedScrollbarThumb = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbHover:
|
||||
mScrollbarThumbHover = entry.color;
|
||||
case ColorID::ThemedScrollbarThumbHover:
|
||||
mThemedScrollbarThumbHover = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbActive:
|
||||
mScrollbarThumbActive = entry.color;
|
||||
case ColorID::ThemedScrollbarThumbActive:
|
||||
mThemedScrollbarThumbActive = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbInactive:
|
||||
mScrollbarThumbInactive = entry.color;
|
||||
case ColorID::ThemedScrollbarThumbInactive:
|
||||
mThemedScrollbarThumbInactive = entry.color;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Bogus Color ID in cache");
|
||||
|
@ -413,20 +414,23 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
case ColorID::SpellCheckerUnderline:
|
||||
aColor = NS_RGB(0xff, 0, 0);
|
||||
break;
|
||||
case ColorID::ScrollbarInactive:
|
||||
aColor = mScrollbarInactive;
|
||||
case ColorID::ThemedScrollbar:
|
||||
aColor = mThemedScrollbar;
|
||||
break;
|
||||
case ColorID::ScrollbarThumb:
|
||||
aColor = mScrollbarThumb;
|
||||
case ColorID::ThemedScrollbarInactive:
|
||||
aColor = mThemedScrollbarInactive;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbHover:
|
||||
aColor = mScrollbarThumbHover;
|
||||
case ColorID::ThemedScrollbarThumb:
|
||||
aColor = mThemedScrollbarThumb;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbActive:
|
||||
aColor = mScrollbarThumbActive;
|
||||
case ColorID::ThemedScrollbarThumbHover:
|
||||
aColor = mThemedScrollbarThumbHover;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbInactive:
|
||||
aColor = mScrollbarThumbInactive;
|
||||
case ColorID::ThemedScrollbarThumbActive:
|
||||
aColor = mThemedScrollbarThumbActive;
|
||||
break;
|
||||
case ColorID::ThemedScrollbarThumbInactive:
|
||||
aColor = mThemedScrollbarThumbInactive;
|
||||
break;
|
||||
|
||||
// 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);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
|
||||
&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,
|
||||
&color);
|
||||
mScrollbarInactive = GDK_RGBA_TO_NS_RGBA(color);
|
||||
mThemedScrollbarInactive = GDK_RGBA_TO_NS_RGBA(color);
|
||||
|
||||
style = GetStyleContext(MOZ_GTK_SCROLLBAR_THUMB_VERTICAL);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL,
|
||||
&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,
|
||||
&color);
|
||||
mScrollbarThumbHover = GDK_RGBA_TO_NS_RGBA(color);
|
||||
mThemedScrollbarThumbHover = GDK_RGBA_TO_NS_RGBA(color);
|
||||
gtk_style_context_get_background_color(
|
||||
style, GtkStateFlags(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE),
|
||||
&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,
|
||||
&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
|
||||
|
|
|
@ -90,11 +90,12 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
|||
nscolor mInfoBarText = kBlack;
|
||||
nscolor mMozColHeaderText = kBlack;
|
||||
nscolor mMozColHeaderHoverText = kBlack;
|
||||
nscolor mScrollbarInactive = kBlack;
|
||||
nscolor mScrollbarThumb = kBlack;
|
||||
nscolor mScrollbarThumbHover = kBlack;
|
||||
nscolor mScrollbarThumbActive = kBlack;
|
||||
nscolor mScrollbarThumbInactive = kBlack;
|
||||
nscolor mThemedScrollbar = kWhite;
|
||||
nscolor mThemedScrollbarInactive = kWhite;
|
||||
nscolor mThemedScrollbarThumb = kBlack;
|
||||
nscolor mThemedScrollbarThumbHover = kBlack;
|
||||
nscolor mThemedScrollbarThumbActive = kBlack;
|
||||
nscolor mThemedScrollbarThumbInactive = kBlack;
|
||||
char16_t mInvisibleCharacter = 0;
|
||||
float mCaretRatio = 0.0f;
|
||||
int32_t mCaretBlinkTime = 0;
|
||||
|
|
|
@ -879,16 +879,19 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarthumbColor(
|
|||
if (ui->mScrollbarColor.IsColors()) {
|
||||
color = ui->mScrollbarColor.AsColors().thumb.CalcColor(aStyle);
|
||||
} else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbInactive,
|
||||
sScrollbarThumbColor.ToABGR());
|
||||
color = LookAndFeel::GetColor(
|
||||
LookAndFeel::ColorID::ThemedScrollbarThumbInactive,
|
||||
sScrollbarThumbColor.ToABGR());
|
||||
} else if (aElementState.HasAllStates(NS_EVENT_STATE_ACTIVE)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbActive,
|
||||
sScrollbarThumbColorActive.ToABGR());
|
||||
color =
|
||||
LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarThumbActive,
|
||||
sScrollbarThumbColorActive.ToABGR());
|
||||
} else if (aElementState.HasAllStates(NS_EVENT_STATE_HOVER)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbHover,
|
||||
sScrollbarThumbColorHover.ToABGR());
|
||||
color =
|
||||
LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarThumbHover,
|
||||
sScrollbarThumbColorHover.ToABGR());
|
||||
} else {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumb,
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarThumb,
|
||||
sScrollbarThumbColor.ToABGR());
|
||||
}
|
||||
return gfx::sRGBColor::FromABGR(color);
|
||||
|
@ -902,10 +905,10 @@ sRGBColor nsNativeBasicTheme::ComputeScrollbarColor(
|
|||
if (ui->mScrollbarColor.IsColors()) {
|
||||
color = ui->mScrollbarColor.AsColors().track.CalcColor(aStyle);
|
||||
} else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarInactive,
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbarInactive,
|
||||
sScrollbarColor.ToABGR());
|
||||
} else {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::Scrollbar,
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbar,
|
||||
sScrollbarColor.ToABGR());
|
||||
}
|
||||
if (aIsRoot) {
|
||||
|
|
|
@ -146,11 +146,12 @@ const char nsXPLookAndFeel::sColorPrefs[][41] = {
|
|||
"ui.IMESelectedConvertedTextForeground",
|
||||
"ui.IMESelectedConvertedTextUnderline",
|
||||
"ui.SpellCheckerUnderline",
|
||||
"ui.scrollbarInactive",
|
||||
"ui.scrollbarThumb",
|
||||
"ui.scrollbarThumbHover",
|
||||
"ui.scrollbarThumbActive",
|
||||
"ui.scrollbarThumbInactive",
|
||||
"ui.themedScrollbar",
|
||||
"ui.themedScrollbarInactive",
|
||||
"ui.themedScrollbarThumb",
|
||||
"ui.themedScrollbarThumbHover",
|
||||
"ui.themedScrollbarThumbActive",
|
||||
"ui.themedScrollbarThumbInactive",
|
||||
"ui.activeborder",
|
||||
"ui.activecaption",
|
||||
"ui.appworkspace",
|
||||
|
|
Загрузка…
Ссылка в новой задаче