зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1669368 - Use LookAndFeelCache to pass Gtk theme-derived scrollbar colors to content processes. r=spohl
Differential Revision: https://phabricator.services.mozilla.com/D93467
This commit is contained in:
Родитель
7105217e53
Коммит
76b30e3307
|
@ -107,6 +107,16 @@ pub enum SystemColor {
|
|||
IMESelectedConvertedTextUnderline,
|
||||
#[css(skip)]
|
||||
SpellCheckerUnderline,
|
||||
#[css(skip)]
|
||||
ScrollbarInactive,
|
||||
#[css(skip)]
|
||||
ScrollbarThumb,
|
||||
#[css(skip)]
|
||||
ScrollbarThumbHover,
|
||||
#[css(skip)]
|
||||
ScrollbarThumbActive,
|
||||
#[css(skip)]
|
||||
ScrollbarThumbInactive,
|
||||
Activeborder,
|
||||
Activecaption,
|
||||
Appworkspace,
|
||||
|
|
|
@ -565,13 +565,20 @@ struct LookAndFeelFont {
|
|||
bool bold;
|
||||
};
|
||||
|
||||
struct LookAndFeelColor {
|
||||
mozilla::LookAndFeel::ColorID id;
|
||||
nscolor color;
|
||||
};
|
||||
|
||||
struct LookAndFeelCache {
|
||||
void Clear() {
|
||||
mInts.Clear();
|
||||
mFonts.Clear();
|
||||
mColors.Clear();
|
||||
}
|
||||
nsTArray<LookAndFeelInt> mInts;
|
||||
nsTArray<LookAndFeelFont> mFonts;
|
||||
nsTArray<LookAndFeelColor> mColors;
|
||||
};
|
||||
|
||||
// On the Mac, GetColor(ColorID::TextSelectForeground, color) returns this
|
||||
|
|
|
@ -54,6 +54,29 @@ struct ParamTraits<LookAndFeelFont> {
|
|||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<LookAndFeelColor> {
|
||||
using paramType = LookAndFeelColor;
|
||||
using idType = std::underlying_type<mozilla::LookAndFeel::ColorID>::type;
|
||||
|
||||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
WriteParam(aMsg, static_cast<idType>(aParam.id));
|
||||
WriteParam(aMsg, aParam.color);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
||||
paramType* aResult) {
|
||||
idType id;
|
||||
nscolor color;
|
||||
if (ReadParam(aMsg, aIter, &id) && ReadParam(aMsg, aIter, &color)) {
|
||||
aResult->id = static_cast<mozilla::LookAndFeel::ColorID>(id);
|
||||
aResult->color = color;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<LookAndFeelCache> {
|
||||
typedef LookAndFeelCache paramType;
|
||||
|
@ -61,12 +84,14 @@ struct ParamTraits<LookAndFeelCache> {
|
|||
static void Write(Message* aMsg, const paramType& aParam) {
|
||||
WriteParam(aMsg, aParam.mInts);
|
||||
WriteParam(aMsg, aParam.mFonts);
|
||||
WriteParam(aMsg, aParam.mColors);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter,
|
||||
paramType* aResult) {
|
||||
return ReadParam(aMsg, aIter, &aResult->mInts) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mFonts);
|
||||
ReadParam(aMsg, aIter, &aResult->mFonts) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mColors);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -270,13 +270,23 @@ void nsLookAndFeel::RefreshImpl() {
|
|||
LookAndFeelCache nsLookAndFeel::GetCacheImpl() {
|
||||
LookAndFeelCache cache = nsXPLookAndFeel::GetCacheImpl();
|
||||
|
||||
const IntID kIdsToCache[] = {IntID::SystemUsesDarkTheme,
|
||||
IntID::PrefersReducedMotion,
|
||||
IntID::UseAccessibilityTheme};
|
||||
constexpr IntID kIntIdsToCache[] = {IntID::SystemUsesDarkTheme,
|
||||
IntID::PrefersReducedMotion,
|
||||
IntID::UseAccessibilityTheme};
|
||||
constexpr ColorID kColorIdsToCache[] = {ColorID::Scrollbar,
|
||||
ColorID::ScrollbarInactive,
|
||||
ColorID::ScrollbarThumb,
|
||||
ColorID::ScrollbarThumbHover,
|
||||
ColorID::ScrollbarThumbActive,
|
||||
ColorID::ScrollbarThumbInactive};
|
||||
|
||||
for (IntID id : kIdsToCache) {
|
||||
for (IntID id : kIntIdsToCache) {
|
||||
cache.mInts.AppendElement(LookAndFeelInt{.id = id, .value = GetInt(id)});
|
||||
}
|
||||
for (ColorID id : kColorIdsToCache) {
|
||||
cache.mColors.AppendElement(
|
||||
LookAndFeelColor{.id = id, .color = GetColor(id)});
|
||||
}
|
||||
|
||||
return cache;
|
||||
}
|
||||
|
@ -298,6 +308,31 @@ void nsLookAndFeel::SetCacheImpl(const LookAndFeelCache& aCache) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
for (const auto& entry : aCache.mColors) {
|
||||
switch (entry.id) {
|
||||
case ColorID::Scrollbar:
|
||||
mMozScrollbar = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarInactive:
|
||||
mScrollbarInactive = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumb:
|
||||
mScrollbarThumb = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbHover:
|
||||
mScrollbarThumbHover = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbActive:
|
||||
mScrollbarThumbActive = entry.color;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbInactive:
|
||||
mScrollbarThumbInactive = entry.color;
|
||||
break;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Bogus Color ID in cache");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
||||
|
@ -378,6 +413,21 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, nscolor& aColor) {
|
|||
case ColorID::SpellCheckerUnderline:
|
||||
aColor = NS_RGB(0xff, 0, 0);
|
||||
break;
|
||||
case ColorID::ScrollbarInactive:
|
||||
aColor = mScrollbarInactive;
|
||||
break;
|
||||
case ColorID::ScrollbarThumb:
|
||||
aColor = mScrollbarThumb;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbHover:
|
||||
aColor = mScrollbarThumbHover;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbActive:
|
||||
aColor = mScrollbarThumbActive;
|
||||
break;
|
||||
case ColorID::ScrollbarThumbInactive:
|
||||
aColor = mScrollbarThumbInactive;
|
||||
break;
|
||||
|
||||
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
|
||||
case ColorID::Activeborder:
|
||||
|
@ -994,6 +1044,7 @@ void nsLookAndFeel::EnsureInit() {
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
GtkStyleContext* style;
|
||||
GdkRGBA color;
|
||||
|
||||
if (XRE_IsContentProcess()) {
|
||||
LOG(("nsLookAndFeel::EnsureInit() [%p] Content process\n", (void*)this));
|
||||
|
@ -1024,6 +1075,30 @@ void nsLookAndFeel::EnsureInit() {
|
|||
gboolean enableAnimations = false;
|
||||
g_object_get(settings, "gtk-enable-animations", &enableAnimations, nullptr);
|
||||
mPrefersReducedMotion = !enableAnimations;
|
||||
|
||||
// Colors that we pass to content processes through the LookAndFeelCache.
|
||||
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);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_BACKDROP,
|
||||
&color);
|
||||
mScrollbarInactive = 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);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_PRELIGHT,
|
||||
&color);
|
||||
mScrollbarThumbHover = 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);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_BACKDROP,
|
||||
&color);
|
||||
mScrollbarThumbInactive = GDK_RGBA_TO_NS_RGBA(color);
|
||||
}
|
||||
|
||||
// The label is not added to a parent widget, but shared for constructing
|
||||
|
@ -1032,12 +1107,6 @@ void nsLookAndFeel::EnsureInit() {
|
|||
GtkWidget* labelWidget = gtk_label_new("M");
|
||||
g_object_ref_sink(labelWidget);
|
||||
|
||||
// Scrollbar colors
|
||||
GdkRGBA color;
|
||||
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);
|
||||
|
||||
// Window colors
|
||||
style = GetStyleContext(MOZ_GTK_WINDOW);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
||||
|
|
|
@ -90,6 +90,11 @@ 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;
|
||||
char16_t mInvisibleCharacter = 0;
|
||||
float mCaretRatio = 0.0f;
|
||||
int32_t mCaretBlinkTime = 0;
|
||||
|
|
|
@ -93,8 +93,9 @@ nsNativeBasicThemeGTK::GetMinimumWidgetSize(nsPresContext* aPresContext,
|
|||
|
||||
void nsNativeBasicThemeGTK::PaintScrollbarthumbHorizontal(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aState) {
|
||||
sRGBColor thumbColor = ComputeScrollbarthumbColor(aStyle, aState);
|
||||
const EventStates& aElementState, const EventStates& aDocumentState) {
|
||||
sRGBColor thumbColor =
|
||||
ComputeScrollbarthumbColor(aStyle, aElementState, aDocumentState);
|
||||
Rect thumbRect(aRect);
|
||||
thumbRect.Deflate(floorf(aRect.height / 4.0f));
|
||||
PaintRoundedRectWithRadius(aDrawTarget, thumbRect, thumbColor, sRGBColor(), 0,
|
||||
|
@ -103,8 +104,9 @@ void nsNativeBasicThemeGTK::PaintScrollbarthumbHorizontal(
|
|||
|
||||
void nsNativeBasicThemeGTK::PaintScrollbarthumbVertical(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aState) {
|
||||
sRGBColor thumbColor = ComputeScrollbarthumbColor(aStyle, aState);
|
||||
const EventStates& aElementState, const EventStates& aDocumentState) {
|
||||
sRGBColor thumbColor =
|
||||
ComputeScrollbarthumbColor(aStyle, aElementState, aDocumentState);
|
||||
Rect thumbRect(aRect);
|
||||
thumbRect.Deflate(floorf(aRect.width / 4.0f));
|
||||
PaintRoundedRectWithRadius(aDrawTarget, thumbRect, thumbColor, sRGBColor(), 0,
|
||||
|
@ -113,16 +115,14 @@ void nsNativeBasicThemeGTK::PaintScrollbarthumbVertical(
|
|||
|
||||
void nsNativeBasicThemeGTK::PaintScrollbarHorizontal(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
bool aIsRoot) {
|
||||
sRGBColor trackColor =
|
||||
ComputeScrollbarColor(aStyle, aIsRoot, /* aDefaultTransparent = */ true);
|
||||
const EventStates& aDocumentState, bool aIsRoot) {
|
||||
sRGBColor trackColor = ComputeScrollbarColor(aStyle, aDocumentState, aIsRoot);
|
||||
aDrawTarget->FillRect(aRect, ColorPattern(ToDeviceColor(trackColor)));
|
||||
}
|
||||
|
||||
void nsNativeBasicThemeGTK::PaintScrollbarVerticalAndCorner(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
uint32_t aDpiRatio, bool aIsRoot) {
|
||||
sRGBColor trackColor =
|
||||
ComputeScrollbarColor(aStyle, aIsRoot, /* aDefaultTransparent = */ true);
|
||||
const EventStates& aDocumentState, uint32_t aDpiRatio, bool aIsRoot) {
|
||||
sRGBColor trackColor = ComputeScrollbarColor(aStyle, aDocumentState, aIsRoot);
|
||||
aDrawTarget->FillRect(aRect, ColorPattern(ToDeviceColor(trackColor)));
|
||||
}
|
||||
|
|
|
@ -20,18 +20,22 @@ class nsNativeBasicThemeGTK : public nsNativeBasicTheme {
|
|||
|
||||
nsITheme::Transparency GetWidgetTransparency(
|
||||
nsIFrame* aFrame, StyleAppearance aAppearance) override;
|
||||
void PaintScrollbarthumbHorizontal(DrawTarget* aDrawTarget, const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aState) override;
|
||||
void PaintScrollbarthumbHorizontal(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aElementState,
|
||||
const EventStates& aDocumentState) override;
|
||||
void PaintScrollbarthumbVertical(DrawTarget* aDrawTarget, const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aState) override;
|
||||
const EventStates& aElementState,
|
||||
const EventStates& aDocumentState) override;
|
||||
void PaintScrollbarHorizontal(DrawTarget* aDrawTarget, const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
bool aIsRoot) override;
|
||||
void PaintScrollbarVerticalAndCorner(DrawTarget* aDrawTarget,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
uint32_t aDpiRatio,
|
||||
bool aIsRoot) override;
|
||||
|
||||
|
|
|
@ -872,58 +872,72 @@ void nsNativeBasicTheme::PaintButton(nsIFrame* aFrame, DrawTarget* aDrawTarget,
|
|||
}
|
||||
|
||||
sRGBColor nsNativeBasicTheme::ComputeScrollbarthumbColor(
|
||||
const ComputedStyle& aStyle, const EventStates& aState) {
|
||||
const ComputedStyle& aStyle, const EventStates& aElementState,
|
||||
const EventStates& aDocumentState) {
|
||||
const nsStyleUI* ui = aStyle.StyleUI();
|
||||
nscolor color;
|
||||
if (ui->mScrollbarColor.IsColors()) {
|
||||
nscolor color = ui->mScrollbarColor.AsColors().thumb.CalcColor(aStyle);
|
||||
return gfx::sRGBColor::FromABGR(color);
|
||||
color = ui->mScrollbarColor.AsColors().thumb.CalcColor(aStyle);
|
||||
} else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbInactive,
|
||||
sScrollbarThumbColor.ToABGR());
|
||||
} else if (aElementState.HasAllStates(NS_EVENT_STATE_ACTIVE)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbActive,
|
||||
sScrollbarThumbColorActive.ToABGR());
|
||||
} else if (aElementState.HasAllStates(NS_EVENT_STATE_HOVER)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumbHover,
|
||||
sScrollbarThumbColorHover.ToABGR());
|
||||
} else {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarThumb,
|
||||
sScrollbarThumbColor.ToABGR());
|
||||
}
|
||||
if (aState.HasAllStates(NS_EVENT_STATE_ACTIVE)) {
|
||||
return sScrollbarThumbColorActive;
|
||||
}
|
||||
if (aState.HasAllStates(NS_EVENT_STATE_HOVER)) {
|
||||
return sScrollbarThumbColorHover;
|
||||
}
|
||||
return sScrollbarThumbColor;
|
||||
return gfx::sRGBColor::FromABGR(color);
|
||||
}
|
||||
|
||||
sRGBColor nsNativeBasicTheme::ComputeScrollbarColor(const ComputedStyle& aStyle,
|
||||
bool aIsRoot,
|
||||
bool aDefaultTransparent) {
|
||||
sRGBColor nsNativeBasicTheme::ComputeScrollbarColor(
|
||||
const ComputedStyle& aStyle, const EventStates& aDocumentState,
|
||||
bool aIsRoot) {
|
||||
const nsStyleUI* ui = aStyle.StyleUI();
|
||||
nscolor color;
|
||||
if (ui->mScrollbarColor.IsColors()) {
|
||||
nscolor color = ui->mScrollbarColor.AsColors().track.CalcColor(aStyle);
|
||||
if (aIsRoot) {
|
||||
color = NS_ComposeColors(sScrollbarColor.ToABGR(), color);
|
||||
}
|
||||
return gfx::sRGBColor::FromABGR(color);
|
||||
color = ui->mScrollbarColor.AsColors().track.CalcColor(aStyle);
|
||||
} else if (aDocumentState.HasAllStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ScrollbarInactive,
|
||||
sScrollbarColor.ToABGR());
|
||||
} else {
|
||||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::Scrollbar,
|
||||
sScrollbarColor.ToABGR());
|
||||
}
|
||||
if (aIsRoot || !aDefaultTransparent) {
|
||||
return sScrollbarColor;
|
||||
if (aIsRoot) {
|
||||
// Root scrollbars must be opaque.
|
||||
nscolor bg = LookAndFeel::GetColor(LookAndFeel::ColorID::WindowBackground,
|
||||
NS_RGB(0xff, 0xff, 0xff));
|
||||
color = NS_ComposeColors(bg, color);
|
||||
}
|
||||
return sScrollbarColorTransparent;
|
||||
return gfx::sRGBColor::FromABGR(color);
|
||||
}
|
||||
|
||||
void nsNativeBasicTheme::PaintScrollbarthumbHorizontal(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aState) {
|
||||
sRGBColor thumbColor = ComputeScrollbarthumbColor(aStyle, aState);
|
||||
const EventStates& aElementState, const EventStates& aDocumentState) {
|
||||
sRGBColor thumbColor =
|
||||
ComputeScrollbarthumbColor(aStyle, aElementState, aDocumentState);
|
||||
aDrawTarget->FillRect(aRect, ColorPattern(ToDeviceColor(thumbColor)));
|
||||
}
|
||||
|
||||
void nsNativeBasicTheme::PaintScrollbarthumbVertical(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aState) {
|
||||
sRGBColor thumbColor = ComputeScrollbarthumbColor(aStyle, aState);
|
||||
const EventStates& aElementState, const EventStates& aDocumentState) {
|
||||
sRGBColor thumbColor =
|
||||
ComputeScrollbarthumbColor(aStyle, aElementState, aDocumentState);
|
||||
aDrawTarget->FillRect(aRect, ColorPattern(ToDeviceColor(thumbColor)));
|
||||
}
|
||||
|
||||
void nsNativeBasicTheme::PaintScrollbarHorizontal(DrawTarget* aDrawTarget,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
bool aIsRoot) {
|
||||
void nsNativeBasicTheme::PaintScrollbarHorizontal(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, bool aIsRoot) {
|
||||
sRGBColor scrollbarColor =
|
||||
ComputeScrollbarColor(aStyle, aIsRoot, /* aDefaultTransparent = */ false);
|
||||
ComputeScrollbarColor(aStyle, aDocumentState, aIsRoot);
|
||||
aDrawTarget->FillRect(aRect, ColorPattern(ToDeviceColor(scrollbarColor)));
|
||||
// FIXME(heycam): We should probably derive the border color when custom
|
||||
// scrollbar colors are in use too. But for now, just skip painting it,
|
||||
|
@ -940,9 +954,9 @@ void nsNativeBasicTheme::PaintScrollbarHorizontal(DrawTarget* aDrawTarget,
|
|||
|
||||
void nsNativeBasicTheme::PaintScrollbarVerticalAndCorner(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
uint32_t aDpiRatio, bool aIsRoot) {
|
||||
const EventStates& aDocumentState, uint32_t aDpiRatio, bool aIsRoot) {
|
||||
sRGBColor scrollbarColor =
|
||||
ComputeScrollbarColor(aStyle, aIsRoot, /* aDefaultTransparent = */ false);
|
||||
ComputeScrollbarColor(aStyle, aDocumentState, aIsRoot);
|
||||
aDrawTarget->FillRect(aRect, ColorPattern(ToDeviceColor(scrollbarColor)));
|
||||
// FIXME(heycam): We should probably derive the border color when custom
|
||||
// scrollbar colors are in use too. But for now, just skip painting it,
|
||||
|
@ -958,20 +972,19 @@ void nsNativeBasicTheme::PaintScrollbarVerticalAndCorner(
|
|||
}
|
||||
}
|
||||
|
||||
void nsNativeBasicTheme::PaintScrollbarbutton(DrawTarget* aDrawTarget,
|
||||
StyleAppearance aAppearance,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aState,
|
||||
uint32_t aDpiRatio) {
|
||||
bool isActive = aState.HasState(NS_EVENT_STATE_ACTIVE);
|
||||
bool isHovered = aState.HasState(NS_EVENT_STATE_HOVER);
|
||||
void nsNativeBasicTheme::PaintScrollbarbutton(
|
||||
DrawTarget* aDrawTarget, StyleAppearance aAppearance, const Rect& aRect,
|
||||
const ComputedStyle& aStyle, const EventStates& aElementState,
|
||||
const EventStates& aDocumentState, uint32_t aDpiRatio) {
|
||||
bool isActive = aElementState.HasState(NS_EVENT_STATE_ACTIVE);
|
||||
bool isHovered = aElementState.HasState(NS_EVENT_STATE_HOVER);
|
||||
|
||||
bool hasCustomColor = aStyle.StyleUI()->mScrollbarColor.IsColors();
|
||||
sRGBColor buttonColor;
|
||||
if (hasCustomColor) {
|
||||
// When scrollbar-color is in use, use the thumb color for the button.
|
||||
buttonColor = ComputeScrollbarthumbColor(aStyle, aState);
|
||||
buttonColor =
|
||||
ComputeScrollbarthumbColor(aStyle, aElementState, aDocumentState);
|
||||
} else if (isActive) {
|
||||
buttonColor = sScrollbarButtonActiveColor;
|
||||
} else if (!hasCustomColor && isHovered) {
|
||||
|
@ -1073,6 +1086,7 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
|||
DrawTarget* dt = aContext->GetDrawTarget();
|
||||
const nscoord twipsPerPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
EventStates eventState = GetContentState(aFrame, aAppearance);
|
||||
EventStates docState = aFrame->GetContent()->OwnerDoc()->GetDocumentState();
|
||||
Rect devPxRect = NSRectToSnappedRect(aRect, twipsPerPixel, *dt);
|
||||
|
||||
if (aAppearance == StyleAppearance::MozMenulistArrowButton) {
|
||||
|
@ -1148,23 +1162,25 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
|||
PaintMeterchunk(aFrame, dt, devPxRect, eventState, dpiRatio);
|
||||
break;
|
||||
case StyleAppearance::ScrollbarthumbHorizontal:
|
||||
PaintScrollbarthumbHorizontal(
|
||||
dt, devPxRect, *nsLayoutUtils::StyleForScrollbar(aFrame), eventState);
|
||||
PaintScrollbarthumbHorizontal(dt, devPxRect,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame),
|
||||
eventState, docState);
|
||||
break;
|
||||
case StyleAppearance::ScrollbarthumbVertical:
|
||||
PaintScrollbarthumbVertical(
|
||||
dt, devPxRect, *nsLayoutUtils::StyleForScrollbar(aFrame), eventState);
|
||||
PaintScrollbarthumbVertical(dt, devPxRect,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame),
|
||||
eventState, docState);
|
||||
break;
|
||||
case StyleAppearance::ScrollbarHorizontal:
|
||||
PaintScrollbarHorizontal(dt, devPxRect,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame),
|
||||
IsRootScrollbar(aFrame));
|
||||
docState, IsRootScrollbar(aFrame));
|
||||
break;
|
||||
case StyleAppearance::ScrollbarVertical:
|
||||
case StyleAppearance::Scrollcorner:
|
||||
PaintScrollbarVerticalAndCorner(dt, devPxRect,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame),
|
||||
dpiRatio, IsRootScrollbar(aFrame));
|
||||
PaintScrollbarVerticalAndCorner(
|
||||
dt, devPxRect, *nsLayoutUtils::StyleForScrollbar(aFrame), docState,
|
||||
dpiRatio, IsRootScrollbar(aFrame));
|
||||
break;
|
||||
case StyleAppearance::ScrollbarbuttonUp:
|
||||
case StyleAppearance::ScrollbarbuttonDown:
|
||||
|
@ -1172,7 +1188,7 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
|||
case StyleAppearance::ScrollbarbuttonRight:
|
||||
PaintScrollbarbutton(dt, aAppearance, devPxRect,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame),
|
||||
eventState, dpiRatio);
|
||||
eventState, docState, dpiRatio);
|
||||
break;
|
||||
case StyleAppearance::Button:
|
||||
PaintButton(aFrame, dt, devPxRect, eventState, dpiRatio);
|
||||
|
@ -1418,8 +1434,9 @@ nsNativeBasicTheme::WidgetStateChanged(nsIFrame* aFrame,
|
|||
NS_IMETHODIMP
|
||||
nsNativeBasicTheme::ThemeChanged() { return NS_OK; }
|
||||
|
||||
bool nsNativeBasicTheme::WidgetAppearanceDependsOnWindowFocus(StyleAppearance) {
|
||||
return false;
|
||||
bool nsNativeBasicTheme::WidgetAppearanceDependsOnWindowFocus(
|
||||
StyleAppearance aAppearance) {
|
||||
return IsWidgetScrollbarPart(aAppearance);
|
||||
}
|
||||
|
||||
nsITheme::ThemeGeometryType nsNativeBasicTheme::ThemeGeometryTypeForWidget(
|
||||
|
|
|
@ -77,8 +77,6 @@ static const gfx::sRGBColor sColorMeterRed20(
|
|||
|
||||
static const gfx::sRGBColor sScrollbarColor(gfx::sRGBColor(0.94f, 0.94f,
|
||||
0.94f));
|
||||
static const gfx::sRGBColor sScrollbarColorTransparent(
|
||||
gfx::sRGBColor(0.94f, 0.94f, 0.94f, 0.2f));
|
||||
static const gfx::sRGBColor sScrollbarBorderColor(gfx::sRGBColor(1.0f, 1.0f,
|
||||
1.0f));
|
||||
static const gfx::sRGBColor sScrollbarThumbColor(gfx::sRGBColor(0.8f, 0.8f,
|
||||
|
@ -260,10 +258,11 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
|||
static std::pair<sRGBColor, sRGBColor> ComputeRangeThumbColors(
|
||||
const EventStates& aState);
|
||||
static sRGBColor ComputeScrollbarColor(const ComputedStyle& aStyle,
|
||||
bool aIsRoot,
|
||||
bool aDefaultTransparent);
|
||||
static sRGBColor ComputeScrollbarthumbColor(const ComputedStyle& aStyle,
|
||||
const EventStates& aState);
|
||||
const EventStates& aDocumentState,
|
||||
bool aIsRoot);
|
||||
static sRGBColor ComputeScrollbarthumbColor(
|
||||
const ComputedStyle& aStyle, const EventStates& aState,
|
||||
const EventStates& aDocumentState);
|
||||
static void PaintListbox(DrawTarget* aDrawTarget, const Rect& aRect,
|
||||
const EventStates& aState, uint32_t aDpiRatio);
|
||||
static void PaintMenulist(DrawTarget* aDrawTarget, const Rect& aRect,
|
||||
|
@ -307,26 +306,25 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
|||
virtual void PaintScrollbarthumbHorizontal(DrawTarget* aDrawTarget,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aState);
|
||||
const EventStates& aElementState,
|
||||
const EventStates& aDocumentState);
|
||||
virtual void PaintScrollbarthumbVertical(DrawTarget* aDrawTarget,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aState);
|
||||
const EventStates& aElementState,
|
||||
const EventStates& aDocumentState);
|
||||
virtual void PaintScrollbarHorizontal(DrawTarget* aDrawTarget,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
bool aIsRoot);
|
||||
virtual void PaintScrollbarVerticalAndCorner(DrawTarget* aDrawTarget,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
uint32_t aDpiRatio,
|
||||
bool aIsRoot);
|
||||
virtual void PaintScrollbarbutton(DrawTarget* aDrawTarget,
|
||||
StyleAppearance aAppearance,
|
||||
const Rect& aRect,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aState,
|
||||
uint32_t aDpiRatio);
|
||||
virtual void PaintScrollbarVerticalAndCorner(
|
||||
DrawTarget* aDrawTarget, const Rect& aRect, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, uint32_t aDpiRatio, bool aIsRoot);
|
||||
virtual void PaintScrollbarbutton(
|
||||
DrawTarget* aDrawTarget, StyleAppearance aAppearance, const Rect& aRect,
|
||||
const ComputedStyle& aStyle, const EventStates& aElementState,
|
||||
const EventStates& aDocumentState, uint32_t aDpiRatio);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -146,6 +146,11 @@ const char nsXPLookAndFeel::sColorPrefs[][41] = {
|
|||
"ui.IMESelectedConvertedTextForeground",
|
||||
"ui.IMESelectedConvertedTextUnderline",
|
||||
"ui.SpellCheckerUnderline",
|
||||
"ui.scrollbarInactive",
|
||||
"ui.scrollbarThumb",
|
||||
"ui.scrollbarThumbHover",
|
||||
"ui.scrollbarThumbActive",
|
||||
"ui.scrollbarThumbInactive",
|
||||
"ui.activeborder",
|
||||
"ui.activecaption",
|
||||
"ui.appworkspace",
|
||||
|
|
Загрузка…
Ссылка в новой задаче