Bug 1415683 - Make nsGridContainerFrame aware of the ::backdrop placeholder list. r=dholbert
authorMats Palmgren <mats@mozilla.com>
Fri, 10 Nov 2017 19:28:05 +0100
changeset 696764 dedc4be5ce80ac0e2e3864fba91f77c5583a8e17
parent 696763 5b177ba1e9d9875f419a8bf88528031e89518d71
child 696765 35bb5af0f317f65c257b69bff7bbfdb42ece6afe
push id88784
push usercholler@mozilla.com
push dateSat, 11 Nov 2017 10:21:53 +0000
reviewersdholbert
bugs1415683
milestone58.0a1
Bug 1415683 - Make nsGridContainerFrame aware of the ::backdrop placeholder list. r=dholbert MozReview-Commit-ID: KtOTmQSYgAn
layout/generic/ViewportFrame.cpp
layout/generic/nsGridContainerFrame.cpp
--- a/layout/generic/ViewportFrame.cpp
+++ b/layout/generic/ViewportFrame.cpp
@@ -164,16 +164,19 @@ ViewportFrame::BuildDisplayListForTopLay
       if (!(frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)) {
         MOZ_ASSERT(!elem->GetParent()->IsHTMLElement(), "HTML element "
                    "should always be out-of-flow if in the top layer");
         continue;
       }
       if (nsIFrame* backdropPh =
           frame->GetChildList(kBackdropList).FirstChild()) {
         MOZ_ASSERT(backdropPh->IsPlaceholderFrame());
+        MOZ_ASSERT(!backdropPh->GetNextSibling(), "more than one ::backdrop?");
+        MOZ_ASSERT(backdropPh->HasAnyStateBits(NS_FRAME_FIRST_REFLOW),
+                   "did you intend to reflow ::backdrop placeholders?");
         nsIFrame* backdropFrame =
           static_cast<nsPlaceholderFrame*>(backdropPh)->GetOutOfFlowFrame();
         MOZ_ASSERT(backdropFrame);
         BuildDisplayListForTopLayerFrame(aBuilder, backdropFrame, aList);
       }
       BuildDisplayListForTopLayerFrame(aBuilder, frame, aList);
     }
   }
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -6460,16 +6460,19 @@ nsGridContainerFrame::InsertFrames(Child
 }
 
 void
 nsGridContainerFrame::RemoveFrame(ChildListID aListID, nsIFrame* aOldFrame)
 {
 #ifdef DEBUG
   ChildListIDs supportedLists =
     kAbsoluteList | kFixedList | kPrincipalList | kNoReflowPrincipalList;
+  // We don't handle the kBackdropList frames in any way, but it only contains
+  // a placeholder for ::backdrop which is OK to not reflow (for now anyway).
+  supportedLists |= kBackdropList;
   MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
 
   // Note that kPrincipalList doesn't mean aOldFrame must be on that list.
   // It can also be on kOverflowList, in which case it might be a pushed
   // item, and if it's the only pushed item our DID_PUSH_ITEMS bit will lie.
   if (aListID == kPrincipalList && !aOldFrame->GetPrevInFlow()) {
     // Since the bit may lie, set the mDidPushItemsBitMayLie value to true for
     // ourself and for all our contiguous previous-in-flow nsGridContainerFrames.
@@ -6679,16 +6682,19 @@ nsGridContainerFrame::GetFrameName(nsASt
 
 void
 nsGridContainerFrame::NoteNewChildren(ChildListID aListID,
                                       const nsFrameList& aFrameList)
 {
 #ifdef DEBUG
   ChildListIDs supportedLists =
     kAbsoluteList | kFixedList | kPrincipalList | kNoReflowPrincipalList;
+  // We don't handle the kBackdropList frames in any way, but it only contains
+  // a placeholder for ::backdrop which is OK to not reflow (for now anyway).
+  supportedLists |= kBackdropList;
   MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
 #endif
 
   nsIPresShell* shell = PresShell();
   for (auto pif = GetPrevInFlow(); pif; pif = pif->GetPrevInFlow()) {
     if (aListID == kPrincipalList) {
       pif->AddStateBits(NS_STATE_GRID_DID_PUSH_ITEMS);
     }
@@ -6798,18 +6804,23 @@ nsGridContainerFrame::FindLastItemInGrid
   return result;
 }
 
 #ifdef DEBUG
 void
 nsGridContainerFrame::SetInitialChildList(ChildListID  aListID,
                                           nsFrameList& aChildList)
 {
+#ifdef DEBUG
   ChildListIDs supportedLists = kAbsoluteList | kFixedList | kPrincipalList;
+  // We don't handle the kBackdropList frames in any way, but it only contains
+  // a placeholder for ::backdrop which is OK to not reflow (for now anyway).
+  supportedLists |= kBackdropList;
   MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
+#endif
 
   return nsContainerFrame::SetInitialChildList(aListID, aChildList);
 }
 
 void
 nsGridContainerFrame::SanityCheckGridItemsBeforeReflow() const
 {
   ChildListIDs absLists = kAbsoluteList | kFixedList |
@@ -6817,17 +6828,18 @@ nsGridContainerFrame::SanityCheckGridIte
   ChildListIDs itemLists = kPrincipalList | kOverflowList;
   for (const nsIFrame* f = this; f; f = f->GetNextInFlow()) {
     MOZ_ASSERT(!f->HasAnyStateBits(NS_STATE_GRID_DID_PUSH_ITEMS),
                "At start of reflow, we should've pulled items back from all "
                "NIFs and cleared NS_STATE_GRID_DID_PUSH_ITEMS in the process");
     for (nsIFrame::ChildListIterator childLists(f);
          !childLists.IsDone(); childLists.Next()) {
       if (!itemLists.Contains(childLists.CurrentID())) {
-        MOZ_ASSERT(absLists.Contains(childLists.CurrentID()),
+        MOZ_ASSERT(absLists.Contains(childLists.CurrentID()) ||
+                   childLists.CurrentID() == kBackdropList,
                    "unexpected non-empty child list");
         continue;
       }
       for (auto child : childLists.CurrentList()) {
         MOZ_ASSERT(f == this || child->GetPrevInFlow(),
                    "all pushed items must be pulled up before reflow");
       }
     }