Bug 1304441 Part 2 - Extract main summary checking code to a function. r=bz

* Change the assertion to non-fatal to make it easier to debug.
* Change the wording per bug 1304441 comment 11.

MozReview-Commit-ID: 1UJXhC4qkrx
This commit is contained in:
Ting-Yu Lin 2016-10-05 14:43:31 +08:00
Родитель 8ccd148e08
Коммит 4dc7ab9b9e
2 изменённых файлов: 28 добавлений и 14 удалений

Просмотреть файл

@ -68,20 +68,7 @@ DetailsFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList)
}
#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
}
@ -89,6 +76,27 @@ DetailsFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList)
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)
{

Просмотреть файл

@ -38,6 +38,12 @@ public:
}
#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;