Bug 1469741 part 1 - Apply scrollbar colors to background of some scrollbar parts when theme doesn't support them. r=mattwoodrow

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Xidorn Quan 2018-08-20 01:33:54 +00:00
Родитель 9197cbf364
Коммит ee8b85324b
1 изменённых файлов: 38 добавлений и 2 удалений

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

@ -2530,6 +2530,43 @@ DrawBackgroundColor(nsCSSRendering::ImageLayerClipState& aClipState,
aCtx->Restore();
}
static Maybe<nscolor>
CalcScrollbarColor(nsIFrame* aFrame, StyleComplexColor nsStyleUI::* aColor)
{
ComputedStyle* scrollbarStyle = nsLayoutUtils::StyleForScrollbar(aFrame);
auto color = scrollbarStyle->StyleUI()->*aColor;
if (color.IsAuto()) {
return Nothing();
}
return Some(color.CalcColor(scrollbarStyle));
}
static nscolor
GetBackgroundColor(nsIFrame* aFrame, ComputedStyle* aComputedStyle)
{
Maybe<nscolor> overrideColor = Nothing();
switch (aComputedStyle->StyleDisplay()->mAppearance) {
case StyleAppearance::ScrollbarthumbVertical:
case StyleAppearance::ScrollbarthumbHorizontal:
overrideColor =
CalcScrollbarColor(aFrame, &nsStyleUI::mScrollbarFaceColor);
break;
case StyleAppearance::ScrollbarVertical:
case StyleAppearance::ScrollbarHorizontal:
case StyleAppearance::Scrollcorner:
overrideColor =
CalcScrollbarColor(aFrame, &nsStyleUI::mScrollbarTrackColor);
break;
default:
break;
}
if (overrideColor.isSome()) {
return *overrideColor;
}
return aComputedStyle->
GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor);
}
nscolor
nsCSSRendering::DetermineBackgroundColor(nsPresContext* aPresContext,
ComputedStyle* aComputedStyle,
@ -2551,8 +2588,7 @@ nsCSSRendering::DetermineBackgroundColor(nsPresContext* aPresContext,
const nsStyleBackground *bg = aComputedStyle->StyleBackground();
nscolor bgColor;
if (aDrawBackgroundColor) {
bgColor = aComputedStyle->
GetVisitedDependentColor(&nsStyleBackground::mBackgroundColor);
bgColor = GetBackgroundColor(aFrame, aComputedStyle);
if (NS_GET_A(bgColor) == 0) {
aDrawBackgroundColor = false;
}