Bug 1501418 - Have scrollbar-color: auto resolved to auto rather than two colors. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D9640

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Xidorn Quan 2018-10-24 11:52:46 +00:00
Родитель 9a5381d7d5
Коммит 78e208a120
8 изменённых файлов: 25 добавлений и 113 удалений

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

@ -74,14 +74,6 @@ public:
const nsRect& aRect,
const nsRect& aDirtyRect) = 0;
/**
* Get the used color of the given widget when it's specified as auto.
* It's currently only used for scrollbar-*-color properties.
*/
virtual nscolor GetWidgetAutoColor(mozilla::ComputedStyle* aStyle,
WidgetType aWidgetType)
{ return NS_RGB(0, 0, 0); }
/**
* Create WebRender commands for the theme background.
* @return true if the theme knows how to create WebRender commands for the

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

@ -1150,32 +1150,6 @@ nsComputedDOMStyle::SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
SetToRGBAColor(aValue, aColor.CalcColor(mComputedStyle));
}
void
nsComputedDOMStyle::SetValueForWidgetColor(nsROCSSPrimitiveValue* aValue,
const StyleComplexColor& aColor,
StyleAppearance aWidgetType)
{
if (!aColor.IsAuto()) {
SetToRGBAColor(aValue, aColor.CalcColor(mComputedStyle));
return;
}
nsPresContext* presContext = mPresShell->GetPresContext();
MOZ_ASSERT(presContext);
if (nsContentUtils::ShouldResistFingerprinting(presContext->GetDocShell())) {
// Return transparent when resisting fingerprinting.
SetToRGBAColor(aValue, NS_RGBA(0, 0, 0, 0));
return;
}
if (nsITheme* theme = presContext->GetTheme()) {
nscolor color = theme->GetWidgetAutoColor(mComputedStyle, aWidgetType);
SetToRGBAColor(aValue, color);
} else {
// If we don't have theme, we don't know what value it should be,
// just give it a transparent fallback.
SetToRGBAColor(aValue, NS_RGBA(0, 0, 0, 0));
}
}
already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetColor()
{
@ -2486,15 +2460,24 @@ already_AddRefed<CSSValue>
nsComputedDOMStyle::DoGetScrollbarColor()
{
const nsStyleUI* ui = StyleUI();
RefPtr<nsDOMCSSValueList> list = GetROCSSValueList(false);
auto put = [this, &list](const StyleComplexColor& color,
StyleAppearance type) {
MOZ_ASSERT(ui->mScrollbarFaceColor.IsAuto() ==
ui->mScrollbarTrackColor.IsAuto(),
"Whether the two colors are auto should be identical");
if (ui->mScrollbarFaceColor.IsAuto()) {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueForWidgetColor(val, color, type);
val->SetIdent(eCSSKeyword_auto);
return val.forget();
}
RefPtr<nsDOMCSSValueList> list = GetROCSSValueList(false);
auto put = [this, &list](const StyleComplexColor& color) {
RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
SetValueFromComplexColor(val, color);
list->AppendCSSValue(val.forget());
};
put(ui->mScrollbarFaceColor, StyleAppearance::ScrollbarthumbVertical);
put(ui->mScrollbarTrackColor, StyleAppearance::ScrollbarVertical);
put(ui->mScrollbarFaceColor);
put(ui->mScrollbarTrackColor);
return list.forget();
}

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

@ -459,9 +459,6 @@ private:
void SetToRGBAColor(nsROCSSPrimitiveValue* aValue, nscolor aColor);
void SetValueFromComplexColor(nsROCSSPrimitiveValue* aValue,
const mozilla::StyleComplexColor& aColor);
void SetValueForWidgetColor(nsROCSSPrimitiveValue* aValue,
const mozilla::StyleComplexColor& aColor,
mozilla::StyleAppearance aWidgetType);
void SetValueToPositionCoord(const mozilla::Position::Coord& aCoord,
nsROCSSPrimitiveValue* aValue);
void SetValueToPosition(const mozilla::Position& aPosition,

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

@ -1590,9 +1590,14 @@ function test_auto_color_transition(prop, options={}) {
const test_color = "rgb(51, 102, 153)";
div.style.setProperty("transition-property", "none", "");
div.style.setProperty(prop, "auto", "");
let used_value_of_auto = get_color(cs.getPropertyValue(prop));
isnot(used_value_of_auto, test_color,
msg_prefix + "ensure used auto value is different than our test color");
if (prop == "scrollbar-color") {
is(cs.getPropertyValue(prop), "auto",
msg_prefix + "auto should not be resolved to rgb color");
} else {
let used_value_of_auto = get_color(cs.getPropertyValue(prop));
isnot(used_value_of_auto, test_color,
msg_prefix + "ensure used auto value is different than our test color");
}
div.style.setProperty("transition-property", prop, "");
div.style.setProperty(prop, set_color(test_color), "");

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

@ -380,8 +380,6 @@ public:
WidgetType aWidgetType,
const nsRect& aRect,
const nsRect& aDirtyRect) override;
nscolor GetWidgetAutoColor(mozilla::ComputedStyle* aStyle,
WidgetType aWidgetType) override;
bool CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBuilder& aBuilder,
mozilla::wr::IpcResourceUpdateQueue& aResources,
const mozilla::layers::StackingContextHelper& aSc,

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

@ -3994,31 +3994,6 @@ nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBui
}
}
nscolor
nsNativeThemeCocoa::GetWidgetAutoColor(mozilla::ComputedStyle* aStyle,
WidgetType aWidgetType)
{
switch (aWidgetType) {
case StyleAppearance::Scrollbar:
case StyleAppearance::ScrollbarSmall:
case StyleAppearance::ScrollbarVertical:
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::ScrollbarbuttonUp:
case StyleAppearance::ScrollbarbuttonDown:
case StyleAppearance::ScrollbarbuttonLeft:
case StyleAppearance::ScrollbarbuttonRight:
return NS_RGB(0xFA, 0xFA, 0xFA);
case StyleAppearance::ScrollbarthumbVertical:
case StyleAppearance::ScrollbarthumbHorizontal:
return NS_RGB(0xC1, 0xC1, 0xC1);
default:
return nsITheme::GetWidgetAutoColor(aStyle, aWidgetType);
}
}
LayoutDeviceIntMargin
nsNativeThemeCocoa::DirectionAwareMargin(const LayoutDeviceIntMargin& aMargin,
nsIFrame* aFrame)

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

@ -1989,41 +1989,6 @@ RENDER_AGAIN:
return NS_OK;
}
static nscolor
GetScrollbarFaceColorForAuto(ComputedStyle* aStyle)
{
return NS_RGB(205, 205, 205);
}
static nscolor
GetScrollbarTrackColorForAuto(ComputedStyle* aStyle)
{
return NS_RGB(240, 240, 240);
}
nscolor
nsNativeThemeWin::GetWidgetAutoColor(ComputedStyle* aStyle, WidgetType aWidgetType)
{
switch (aWidgetType) {
case StyleAppearance::Scrollbar:
case StyleAppearance::ScrollbarSmall:
case StyleAppearance::ScrollbarVertical:
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::ScrollbarbuttonUp:
case StyleAppearance::ScrollbarbuttonDown:
case StyleAppearance::ScrollbarbuttonLeft:
case StyleAppearance::ScrollbarbuttonRight:
return GetScrollbarTrackColorForAuto(aStyle);
case StyleAppearance::ScrollbarthumbVertical:
case StyleAppearance::ScrollbarthumbHorizontal:
return GetScrollbarFaceColorForAuto(aStyle);
default:
return nsITheme::GetWidgetAutoColor(aStyle, aWidgetType);
}
}
static void
ScaleForFrameDPI(LayoutDeviceIntMargin* aMargin, nsIFrame* aFrame)
{
@ -4350,7 +4315,7 @@ nsNativeThemeWin::DrawCustomScrollbarPart(gfxContext* aContext,
const nsStyleUI* ui = aStyle->StyleUI();
nscolor trackColor = ui->mScrollbarTrackColor.IsAuto()
? GetScrollbarTrackColorForAuto(aStyle)
? NS_RGB(240, 240, 240)
: ui->mScrollbarTrackColor.CalcColor(aStyle);
switch (aWidgetType) {
case StyleAppearance::ScrollbarHorizontal:
@ -4387,7 +4352,7 @@ nsNativeThemeWin::DrawCustomScrollbarPart(gfxContext* aContext,
case StyleAppearance::ScrollbarthumbVertical:
case StyleAppearance::ScrollbarthumbHorizontal: {
nscolor faceColor = ui->mScrollbarFaceColor.IsAuto()
? GetScrollbarFaceColorForAuto(aStyle)
? NS_RGB(205, 205, 205)
: ui->mScrollbarFaceColor.CalcColor(aStyle);
faceColor = AdjustScrollbarFaceColor(faceColor, eventStates);
ctx->SetColor(Color::FromABGR(faceColor));

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

@ -37,9 +37,6 @@ public:
const nsRect& aRect,
const nsRect& aDirtyRect) override;
nscolor GetWidgetAutoColor(mozilla::ComputedStyle* aStyle,
WidgetType aWidgetType) override;
MOZ_MUST_USE LayoutDeviceIntMargin GetWidgetBorder(nsDeviceContext* aContext,
nsIFrame* aFrame,
WidgetType aWidgetType) override;