Bug 1144096 part 19 - [css-grid] Sanity check the initial child lists we get from the frame constructor (DEBUG only). r=dholbert
authorMats Palmgren <mats@mozilla.com>
Fri, 11 Mar 2016 17:39:27 +0100
changeset 288311 2a7ef2dd4427641166c3a49d3311f5d092337961
parent 288310 47452506ec5632ec4e535d6618552a8a7d804991
child 288312 557bb3ae736f484ca7671ba9ec84b09e24ac7d70
push id30079
push userryanvm@gmail.com
push dateSat, 12 Mar 2016 20:24:19 +0000
treeherdermozilla-central@d1d47ba19ce9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1144096
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1144096 part 19 - [css-grid] Sanity check the initial child lists we get from the frame constructor (DEBUG only). r=dholbert
layout/generic/nsGridContainerFrame.cpp
layout/generic/nsGridContainerFrame.h
--- a/layout/generic/nsGridContainerFrame.cpp
+++ b/layout/generic/nsGridContainerFrame.cpp
@@ -5255,63 +5255,54 @@ nsGridContainerFrame::MergeSortedExcessO
 static bool
 FrameWantsToBeInAnonymousGridItem(nsIFrame* aFrame)
 {
   // Note: This needs to match the logic in
   // nsCSSFrameConstructor::FrameConstructionItem::NeedsAnonFlexOrGridItem()
   return aFrame->IsFrameOfType(nsIFrame::eLineParticipant);
 }
 
-// Debugging method, to let us assert that our anonymous grid items are
-// set up correctly -- in particular, we assert:
+// Debug-only override, to let us assert that our anonymous grid items are
+// set up correctly by the frame constructor -- in particular, we assert:
 //  (1) we don't have any inline non-replaced children
 //  (2) we don't have any consecutive anonymous grid items
 //  (3) we don't have any empty anonymous grid items
 //  (4) all children are on the expected child lists
 void
-nsGridContainerFrame::SanityCheckAnonymousGridItems() const
+nsGridContainerFrame::SetInitialChildList(ChildListID  aListID,
+                                          nsFrameList& aChildList)
 {
-  ChildListIDs noCheckLists = kAbsoluteList | kFixedList |
-    kOverflowContainersList | kExcessOverflowContainersList;
-  ChildListIDs checkLists = kPrincipalList | kOverflowList;
-  for (nsIFrame::ChildListIterator childLists(this);
-       !childLists.IsDone(); childLists.Next()) {
-    if (!checkLists.Contains(childLists.CurrentID())) {
-      MOZ_ASSERT(noCheckLists.Contains(childLists.CurrentID()),
-                 "unexpected non-empty child list");
-      continue;
-    }
-
+  ChildListIDs supportedLists = kAbsoluteList | kFixedList | kPrincipalList;
+  MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
+
+  if (aListID == kPrincipalList) {
     bool prevChildWasAnonGridItem = false;
-    nsFrameList children = childLists.CurrentList();
-    for (nsFrameList::Enumerator e(children); !e.AtEnd(); e.Next()) {
+    for (nsFrameList::Enumerator e(aChildList); !e.AtEnd(); e.Next()) {
       nsIFrame* child = e.get();
       MOZ_ASSERT(!FrameWantsToBeInAnonymousGridItem(child),
-                 "frame wants to be inside an anonymous grid item, "
-                 "but it isn't");
+                 "frame wants to be inside an anonymous grid item, but it isn't");
       if (child->StyleContext()->GetPseudo() ==
             nsCSSAnonBoxes::anonymousGridItem) {
-/*
-  XXX haven't decided yet whether to reorder children or not.
-  XXX If we do, we want this assertion instead of the one below.
-        MOZ_ASSERT(!prevChildWasAnonGridItem ||
-                   HasAnyStateBits(NS_STATE_GRID_CHILDREN_REORDERED),
-                   "two anon grid items in a row (shouldn't happen, unless our "
-                   "children have been reordered with the 'order' property)");
-*/
         MOZ_ASSERT(!prevChildWasAnonGridItem, "two anon grid items in a row");
         nsIFrame* firstWrappedChild = child->PrincipalChildList().FirstChild();
         MOZ_ASSERT(firstWrappedChild,
                    "anonymous grid item is empty (shouldn't happen)");
         prevChildWasAnonGridItem = true;
       } else {
         prevChildWasAnonGridItem = false;
       }
     }
   }
+
+  return nsContainerFrame::SetInitialChildList(aListID, aChildList);
+}
+
+void
+nsGridContainerFrame::SanityCheckAnonymousGridItems() const
+{
 }
 
 void
 nsGridContainerFrame::TrackSize::Dump() const
 {
   printf("mPosition=%d mBase=%d mLimit=%d", mPosition, mBase, mLimit);
 
   printf(" min:");
--- a/layout/generic/nsGridContainerFrame.h
+++ b/layout/generic/nsGridContainerFrame.h
@@ -62,17 +62,21 @@ public:
              ~nsIFrame::eCanContainOverflowContainers);
   }
 
   void BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                         const nsRect&           aDirtyRect,
                         const nsDisplayListSet& aLists) override;
 
 #ifdef DEBUG_FRAME_DUMP
-  virtual nsresult GetFrameName(nsAString& aResult) const override;
+  nsresult GetFrameName(nsAString& aResult) const override;
+#endif
+#ifdef DEBUG
+  void SetInitialChildList(ChildListID  aListID,
+                           nsFrameList& aChildList) override;
 #endif
 
   /**
    * Return the containing block for aChild which MUST be an abs.pos. child
    * of a grid container.  This is just a helper method for
    * nsAbsoluteContainingBlock::Reflow - it's not meant to be used elsewhere.
    */
   static const nsRect& GridItemCB(nsIFrame* aChild);