Bug 1264949 - Ensure that the display list does not contain any background-image/background-color display item; draft
authorCJKu <cku@mozilla.com>
Tue, 19 Apr 2016 13:41:03 +0800
changeset 353052 15e6dc4ab4199e39c352666642a5fe060e737a57
parent 352861 67ac40fb8f680ea5e03805552187ba1b5e8392a1
child 353053 81320675b6362286ded6e51e75458b528f16e587
push id15867
push usercku@mozilla.com
push dateTue, 19 Apr 2016 05:43:20 +0000
bugs1264949
milestone48.0a1
Bug 1264949 - Ensure that the display list does not contain any background-image/background-color display item; MozReview-Commit-ID: LikPnuMxeMc
layout/base/nsDisplayList.cpp
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -509,18 +509,24 @@ ClipBackgroundByText(nsIFrame* aFrame, n
   builder.EnterPresShell(aFrame);
   nsDisplayList list;
   aFrame->BuildDisplayListForStackingContext(&builder,
                                       nsRect(nsPoint(0, 0), aFrame->GetSize()),
                                       &list);
   builder.LeavePresShell(aFrame);
 
 #ifdef DEBUG
+  // ClipBackgroundByText is called 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_TEXT == i->GetType());
+    MOZ_ASSERT(nsDisplayItem::TYPE_BACKGROUND != i->GetType() &&
+               nsDisplayItem::TYPE_BACKGROUND_COLOR != i->GetType());
   }
 #endif
 
   gfxContext* ctx = aContext->ThebesContext();
   gfxContextMatrixAutoSaveRestore save(ctx);
   ctx->SetMatrix(ctx->CurrentMatrix().Translate(aFillRect.TopLeft()));
   ctx->NewPath();