Bug 1275026: Part 1. Prevent infinit recursion in GenerateAndPushTextMask r=jfkthame

MozReview-Commit-ID: 4tcMuW5i13F

--HG--
extra : rebase_source : edee596f677e9819d90700d3df77c417eb5c9cf5
extra : source : eabf478ac1ce8e7718a123dd37b92878166fdf2a
This commit is contained in:
cku 2016-05-24 12:14:57 +08:00
parent 21a9297be3
commit a41bad531c
2 changed files with 16 additions and 23 deletions

View File

@ -492,10 +492,15 @@ AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
}
}
static void
static bool
GenerateAndPushTextMask(nsIFrame* aFrame, nsRenderingContext* aContext,
const nsRect& aFillRect)
const nsRect& aFillRect, nsDisplayListBuilder* aBuilder)
{
if (aBuilder->IsForGenerateGlyphMask() ||
aBuilder->IsForPaintingSelectionBG()) {
return false;
}
// The main function of enabling background-clip:text property value.
// When a nsDisplayBackgroundImage detects "text" bg-clip style, it will call
// this function to
@ -562,6 +567,8 @@ GenerateAndPushTextMask(nsIFrame* aFrame, nsRenderingContext* aContext,
RefPtr<SourceSurface> maskSurface = maskDT->Snapshot();
sourceCtx->PushGroupForBlendBack(gfxContentType::COLOR_ALPHA, 1.0, maskSurface, maskTransform);
return true;
}
/* static */ void
@ -2472,11 +2479,6 @@ nsDisplayBackgroundImage::AppendBackgroundItemsToTop(nsDisplayListBuilder* aBuil
nsDisplayList* aList,
bool aAllowWillPaintBorderOptimization)
{
if (aBuilder->IsForGenerateGlyphMask() ||
aBuilder->IsForPaintingSelectionBG()) {
return true;
}
nsStyleContext* bgSC = nullptr;
const nsStyleBackground* bg = nullptr;
nsRect bgRect = aBackgroundRect + aBuilder->ToReferenceFrame(aFrame);
@ -2978,7 +2980,9 @@ nsDisplayBackgroundImage::PaintInternal(nsDisplayListBuilder* aBuilder,
uint8_t clip = mBackgroundStyle->mImage.mLayers[mLayer].mClip;
if (clip == NS_STYLE_IMAGELAYER_CLIP_TEXT) {
GenerateAndPushTextMask(mFrame, aCtx, mBackgroundRect);
if (!GenerateAndPushTextMask(mFrame, aCtx, mBackgroundRect, aBuilder)) {
return;
}
}
nsCSSRendering::PaintBGParams params =
@ -3410,7 +3414,10 @@ nsDisplayBackgroundColor::Paint(nsDisplayListBuilder* aBuilder,
uint8_t clip = mBackgroundStyle->mImage.mLayers[0].mClip;
if (clip == NS_STYLE_IMAGELAYER_CLIP_TEXT) {
GenerateAndPushTextMask(mFrame, aCtx, mBackgroundRect);
if (!GenerateAndPushTextMask(mFrame, aCtx, mBackgroundRect, aBuilder)) {
return;
}
ctx->SetColor(mColor);
ctx->Rectangle(bounds, true);
ctx->Fill();

View File

@ -3481,20 +3481,6 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram
js::ProfileEntry::Category::GRAPHICS);
aFrame->BuildDisplayListForStackingContext(&builder, dirtyRect, &list);
#ifdef DEBUG
if (builder.IsForGenerateGlyphMask() || builder.IsForPaintingSelectionBG()) {
// PaintFrame is called to generate text glyph by
// nsDisplayBackgroundImage::Paint or nsDisplayBackgroundColor::Paint.
//
// Assert that we do not generate and put nsDisplayBackgroundImage or
// nsDisplayBackgroundColor into the list again, which would lead to
// infinite recursion.
for (nsDisplayItem* i = list.GetBottom(); i; i = i->GetAbove()) {
MOZ_ASSERT(nsDisplayItem::TYPE_BACKGROUND != i->GetType() &&
nsDisplayItem::TYPE_BACKGROUND_COLOR != i->GetType());
}
}
#endif
}
nsIAtom* frameType = aFrame->GetType();