Bug 1567094 - Make WebRender look at visited dependent border colors. r=jrmuizel

We do have test coverage for this
(layout/style/test/test_visited_reftests.html), but it seems that that uses
snapshotWindow() / drawWindow() and that may not use the WR code paths? It seems
we may be missing a bit of test coverage there. Is this expected?

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-08-15 14:18:59 +00:00
parent c3325072d0
commit e53cb2392a

View File

@ -628,58 +628,47 @@ void nsCSSRendering::ComputePixelRadii(const nscoord* aAppUnitsRadii,
Size(radii[eCornerBottomLeftX], radii[eCornerBottomLeftY]);
}
static Maybe<nsStyleBorder> GetBorderIfVisited(const ComputedStyle& aStyle) {
Maybe<nsStyleBorder> result;
// Don't check RelevantLinkVisited here, since we want to take the
// same amount of time whether or not it's true.
const ComputedStyle* styleIfVisited = aStyle.GetStyleIfVisited();
if (MOZ_LIKELY(!styleIfVisited)) {
return result;
}
result.emplace(*aStyle.StyleBorder());
auto& newBorder = result.ref();
NS_FOR_CSS_SIDES(side) {
nscolor color = aStyle.GetVisitedDependentColor(
nsStyleBorder::BorderColorFieldFor(side));
newBorder.BorderColorFor(side) = StyleColor::FromColor(color);
}
return result;
}
ImgDrawResult nsCSSRendering::PaintBorder(
nsPresContext* aPresContext, gfxContext& aRenderingContext,
nsIFrame* aForFrame, const nsRect& aDirtyRect, const nsRect& aBorderArea,
ComputedStyle* aComputedStyle, PaintBorderFlags aFlags, Sides aSkipSides) {
ComputedStyle* aStyle, PaintBorderFlags aFlags, Sides aSkipSides) {
AUTO_PROFILER_LABEL("nsCSSRendering::PaintBorder", GRAPHICS);
ComputedStyle* styleIfVisited = aComputedStyle->GetStyleIfVisited();
const nsStyleBorder* styleBorder = aComputedStyle->StyleBorder();
// Don't check RelevantLinkVisited here, since we want to take the
// same amount of time whether or not it's true.
if (!styleIfVisited) {
return PaintBorderWithStyleBorder(
aPresContext, aRenderingContext, aForFrame, aDirtyRect, aBorderArea,
*styleBorder, aComputedStyle, aFlags, aSkipSides);
}
nsStyleBorder newStyleBorder(*styleBorder);
NS_FOR_CSS_SIDES(side) {
nscolor color = aComputedStyle->GetVisitedDependentColor(
nsStyleBorder::BorderColorFieldFor(side));
newStyleBorder.BorderColorFor(side) = StyleColor::FromColor(color);
}
return PaintBorderWithStyleBorder(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, newStyleBorder,
aComputedStyle, aFlags, aSkipSides);
Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*aStyle);
return PaintBorderWithStyleBorder(
aPresContext, aRenderingContext, aForFrame, aDirtyRect, aBorderArea,
visitedBorder.refOr(*aStyle->StyleBorder()), aStyle, aFlags, aSkipSides);
}
Maybe<nsCSSBorderRenderer> nsCSSRendering::CreateBorderRenderer(
nsPresContext* aPresContext, DrawTarget* aDrawTarget, nsIFrame* aForFrame,
const nsRect& aDirtyRect, const nsRect& aBorderArea,
ComputedStyle* aComputedStyle, bool* aOutBorderIsEmpty, Sides aSkipSides) {
ComputedStyle* styleIfVisited = aComputedStyle->GetStyleIfVisited();
const nsStyleBorder* styleBorder = aComputedStyle->StyleBorder();
// Don't check RelevantLinkVisited here, since we want to take the
// same amount of time whether or not it's true.
if (!styleIfVisited) {
return CreateBorderRendererWithStyleBorder(
aPresContext, aDrawTarget, aForFrame, aDirtyRect, aBorderArea,
*styleBorder, aComputedStyle, aOutBorderIsEmpty, aSkipSides);
}
nsStyleBorder newStyleBorder(*styleBorder);
NS_FOR_CSS_SIDES(side) {
nscolor color = aComputedStyle->GetVisitedDependentColor(
nsStyleBorder::BorderColorFieldFor(side));
newStyleBorder.BorderColorFor(side) = StyleColor::FromColor(color);
}
const nsRect& aDirtyRect, const nsRect& aBorderArea, ComputedStyle* aStyle,
bool* aOutBorderIsEmpty, Sides aSkipSides) {
Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*aStyle);
return CreateBorderRendererWithStyleBorder(
aPresContext, aDrawTarget, aForFrame, aDirtyRect, aBorderArea,
newStyleBorder, aComputedStyle, aOutBorderIsEmpty, aSkipSides);
visitedBorder.refOr(*aStyle->StyleBorder()), aStyle, aOutBorderIsEmpty,
aSkipSides);
}
ImgDrawResult nsCSSRendering::CreateWebRenderCommandsForBorder(
@ -689,10 +678,11 @@ ImgDrawResult nsCSSRendering::CreateWebRenderCommandsForBorder(
const mozilla::layers::StackingContextHelper& aSc,
mozilla::layers::RenderRootStateManager* aManager,
nsDisplayListBuilder* aDisplayListBuilder) {
const nsStyleBorder* styleBorder = aForFrame->Style()->StyleBorder();
const auto* style = aForFrame->Style();
Maybe<nsStyleBorder> visitedBorder = GetBorderIfVisited(*style);
return nsCSSRendering::CreateWebRenderCommandsForBorderWithStyleBorder(
aItem, aForFrame, aBorderArea, aBuilder, aResources, aSc, aManager,
aDisplayListBuilder, *styleBorder);
aDisplayListBuilder, visitedBorder.refOr(*style->StyleBorder()));
}
void nsCSSRendering::CreateWebRenderCommandsForNullBorder(