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
--- 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;