Bug 1304441 Part 2 - Extract main summary checking code to a function. draft
authorTing-Yu Lin <tlin@mozilla.com>
Fri, 23 Sep 2016 11:25:30 +0800
changeset 420422 0807db8942c53e27739caf019539524170ba4d2c
parent 420388 a513df2e33d794224c37bfde780d1277b77fd6a5
child 420423 dab78326ae25f415b54a9dc12640a8a72d4d10d3
child 420511 09e590a68f71200d47495de2f6016d4508070b74
child 421010 2afe90b8e963e0a298c337781d78e3f6924ee599
push id31190
push userbmo:tlin@mozilla.com
push dateTue, 04 Oct 2016 05:55:30 +0000
bugs1304441
milestone52.0a1
Bug 1304441 Part 2 - Extract main summary checking code to a function. * Change the assertion to non-fatal to make it easier to debug. * Change the wording per bug 1304441 comment 11. MozReview-Commit-ID: 1UJXhC4qkrx
layout/generic/DetailsFrame.cpp
layout/generic/DetailsFrame.h
--- a/layout/generic/DetailsFrame.cpp
+++ b/layout/generic/DetailsFrame.cpp
@@ -63,37 +63,45 @@ DetailsFrame::SetInitialChildList(ChildL
           aChildList.RemoveFrame(child);
           aChildList.InsertFrame(nullptr, nullptr, child);
           break;
         }
       }
     }
 
 #ifdef DEBUG
-    for (nsIFrame* child : aChildList) {
-      HTMLSummaryElement* summary =
-        HTMLSummaryElement::FromContent(child->GetContent());
-
-      if (child == aChildList.FirstChild()) {
-        if (summary && summary->IsMainSummary()) {
-          break;
-        }
-      } else {
-        MOZ_ASSERT(!summary || !summary->IsMainSummary(),
-                   "Rest of the children are neither summary elements nor"
-                   "the main summary!");
-      }
-    }
+    CheckValidMainSummary(aChildList);
 #endif
 
   }
 
   nsBlockFrame::SetInitialChildList(aListID, aChildList);
 }
 
+#ifdef DEBUG
+void
+DetailsFrame::CheckValidMainSummary(const nsFrameList& aFrameList) const
+{
+  for (nsIFrame* child : aFrameList) {
+    HTMLSummaryElement* summary =
+      HTMLSummaryElement::FromContent(child->GetContent());
+
+    if (child == aFrameList.FirstChild()) {
+      if (summary && summary->IsMainSummary()) {
+        break;
+      }
+    } else {
+      NS_ASSERTION(!summary || !summary->IsMainSummary(),
+                   "Rest of the children are either not summary element "
+                   "or are not the main summary!");
+    }
+  }
+}
+#endif
+
 void
 DetailsFrame::DestroyFrom(nsIFrame* aDestructRoot)
 {
   nsContentUtils::DestroyAnonymousContent(&mDefaultSummary);
   nsBlockFrame::DestroyFrom(aDestructRoot);
 }
 
 nsresult
--- a/layout/generic/DetailsFrame.h
+++ b/layout/generic/DetailsFrame.h
@@ -33,16 +33,22 @@ public:
 
 #ifdef DEBUG_FRAME_DUMP
   nsresult GetFrameName(nsAString& aResult) const override
   {
     return MakeFrameName(NS_LITERAL_STRING("Details"), aResult);
   }
 #endif
 
+#ifdef DEBUG
+  // Check the frame of the main summary element is the first child in the frame
+  // list.
+  void CheckValidMainSummary(const nsFrameList& aFrameList) const;
+#endif
+
   void SetInitialChildList(ChildListID aListID,
                            nsFrameList& aChildList) override;
 
   void DestroyFrom(nsIFrame* aDestructRoot) override;
 
   // nsIAnonymousContentCreator
   nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;