Bug 1407752 - Avoid taking the webrender fallback path for empty borders. r=jrmuizel

MozReview-Commit-ID: BTSljrUuKcH

--HG--
extra : rebase_source : f5370968de71c9b46dee32b743908f971c1ed3df
This commit is contained in:
Kartikaya Gupta 2017-10-31 13:18:14 -04:00
Родитель 026b20f505
Коммит f392c7eba8
3 изменённых файлов: 30 добавлений и 9 удалений

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

@ -265,7 +265,10 @@ class nsDisplayButtonBorder : public nsDisplayItem {
public:
nsDisplayButtonBorder(nsDisplayListBuilder* aBuilder,
nsButtonFrameRenderer* aRenderer)
: nsDisplayItem(aBuilder, aRenderer->GetFrame()), mBFR(aRenderer) {
: nsDisplayItem(aBuilder, aRenderer->GetFrame())
, mBFR(aRenderer)
, mBorderIsEmpty(false)
{
MOZ_COUNT_CTOR(nsDisplayButtonBorder);
}
#ifdef NS_BUILD_REFCNT_LOGGING
@ -303,6 +306,7 @@ public:
private:
nsButtonFrameRenderer* mBFR;
Maybe<nsCSSBorderRenderer> mBorderRenderer;
bool mBorderIsEmpty;
};
nsDisplayItemGeometry*
@ -329,6 +333,7 @@ nsDisplayButtonBorder::GetLayerState(nsDisplayListBuilder* aBuilder,
return LAYER_NONE;
}
mBorderIsEmpty = false;
Maybe<nsCSSBorderRenderer> br =
nsCSSRendering::CreateBorderRenderer(mFrame->PresContext(),
nullptr,
@ -336,8 +341,12 @@ nsDisplayButtonBorder::GetLayerState(nsDisplayListBuilder* aBuilder,
nsRect(),
nsRect(offset, mFrame->GetSize()),
mFrame->StyleContext(),
mFrame->GetSkipSides());
mFrame->GetSkipSides(),
&mBorderIsEmpty);
if (!br) {
if (mBorderIsEmpty) {
return LAYER_ACTIVE;
}
return LAYER_NONE;
}
@ -372,7 +381,11 @@ nsDisplayButtonBorder::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder&
return false;
}
MOZ_ASSERT(mBorderRenderer);
if (!mBorderRenderer) {
// empty border, nothing to do
MOZ_ASSERT(mBorderIsEmpty);
return true;
}
// This is really a combination of paint box shadow inner +
// paint border.

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

@ -667,7 +667,8 @@ nsCSSRendering::CreateBorderRenderer(nsPresContext* aPresContext,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
nsStyleContext* aStyleContext,
Sides aSkipSides)
Sides aSkipSides,
bool* aOutBorderIsEmpty)
{
nsStyleContext *styleIfVisited = aStyleContext->GetStyleIfVisited();
const nsStyleBorder *styleBorder = aStyleContext->StyleBorder();
@ -677,7 +678,8 @@ nsCSSRendering::CreateBorderRenderer(nsPresContext* aPresContext,
return CreateBorderRendererWithStyleBorder(aPresContext, aDrawTarget,
aForFrame, aDirtyRect,
aBorderArea, *styleBorder,
aStyleContext, aSkipSides);
aStyleContext, aSkipSides,
aOutBorderIsEmpty);
}
nsStyleBorder newStyleBorder(*styleBorder);
@ -690,7 +692,7 @@ nsCSSRendering::CreateBorderRenderer(nsPresContext* aPresContext,
return CreateBorderRendererWithStyleBorder(aPresContext, aDrawTarget,
aForFrame, aDirtyRect, aBorderArea,
newStyleBorder, aStyleContext,
aSkipSides);
aSkipSides, aOutBorderIsEmpty);
}
@ -982,7 +984,8 @@ nsCSSRendering::CreateBorderRendererWithStyleBorder(nsPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBorder& aStyleBorder,
nsStyleContext* aStyleContext,
Sides aSkipSides)
Sides aSkipSides,
bool* aOutBorderIsEmpty)
{
const nsStyleDisplay* displayData = aStyleContext->StyleDisplay();
if (displayData->mAppearance) {
@ -1002,6 +1005,9 @@ nsCSSRendering::CreateBorderRendererWithStyleBorder(nsPresContext* aPresContext,
if (0 == border.left && 0 == border.right &&
0 == border.top && 0 == border.bottom) {
// Empty border area
if (aOutBorderIsEmpty) {
*aOutBorderIsEmpty = true;
}
return Nothing();
}

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

@ -193,7 +193,8 @@ struct nsCSSRendering {
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
nsStyleContext* aStyleContext,
Sides aSkipSides = Sides());
Sides aSkipSides = Sides(),
bool* aOutBorderIsEmpty = nullptr);
static mozilla::Maybe<nsCSSBorderRenderer>
CreateBorderRendererWithStyleBorder(nsPresContext* aPresContext,
@ -203,7 +204,8 @@ struct nsCSSRendering {
const nsRect& aBorderArea,
const nsStyleBorder& aBorderStyle,
nsStyleContext* aStyleContext,
Sides aSkipSides = Sides());
Sides aSkipSides = Sides(),
bool* aOutBorderIsEmpty = nullptr);
static mozilla::Maybe<nsCSSBorderRenderer>
CreateBorderRendererForOutline(nsPresContext* aPresContext,