Move assertion about continuations of floats so that it is valid. (Bug 595740) r=roc a2.0=blocking

When we do multiple reflow passes inside a container with page or column
breaks, we might hit this assertion for legitimate reasons.  In
particular, if a reflow places the first-in-flow of a float in a later
continuation of its containing block than it was in before, or if a
reflow reflows a float that was split and then pushes the line
containing the float's placeholder, then during reflow we push the
continuations of the float back through the continuations of the
containing block, and in intermediate states of this process (such as
when this assertion fires), we have two continuations of the same float
within the same parent.
This commit is contained in:
L. David Baron 2011-01-11 17:09:21 -08:00
parent 7c41d4ded0
commit b55b0a70f8
4 changed files with 47 additions and 10 deletions

View File

@ -3794,6 +3794,25 @@ nsLayoutUtils::GetEditableRootContentByContentEditable(nsIDocument* aDocument)
return nsnull;
}
#ifdef DEBUG
/* static */ void
nsLayoutUtils::AssertNoDuplicateContinuations(nsIFrame* aContainer,
const nsFrameList& aFrameList)
{
for (nsIFrame* f = aFrameList.FirstChild(); f ; f = f->GetNextSibling()) {
// Check only later continuations of f; we deal with checking the
// earlier continuations when we hit those earlier continuations in
// the frame list.
for (nsIFrame *c = f; (c = c->GetNextInFlow());) {
NS_ASSERTION(c->GetParent() != aContainer ||
!aFrameList.ContainsFrame(c),
"Two continuations of the same frame in the same "
"frame list");
}
}
}
#endif
nsSetAttrRunnable::nsSetAttrRunnable(nsIContent* aContent, nsIAtom* aAttrName,
const nsAString& aValue)
: mContent(aContent),

View File

@ -1263,6 +1263,17 @@ public:
(aPresContext->Type() == nsPresContext::eContext_PrintPreview ||
aPresContext->Type() == nsPresContext::eContext_PageLayout);
}
#ifdef DEBUG
/**
* Assert that there are no duplicate continuations of the same frame
* within aFrameList. Optimize the tests by assuming that all frames
* in aFrameList have parent aContainer.
*/
static void
AssertNoDuplicateContinuations(nsIFrame* aContainer,
const nsFrameList& aFrameList);
#endif
};
class nsSetAttrRunnable : public nsRunnable

View File

@ -1213,6 +1213,13 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
aStatus = state.mReflowStatus;
#ifdef DEBUG
// Between when we drain pushed floats and when we complete reflow,
// we're allowed to have multiple continuations of the same float on
// our floats list, since a first-in-flow might get pushed to a later
// continuation of its containing block. But it's not permitted
// outside that time.
nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats);
if (gNoisyReflow) {
IndentBy(stdout, gNoiseIndent);
ListTag(stdout);
@ -4511,6 +4518,15 @@ nsBlockFrame::DrainOverflowLines(nsBlockReflowState& aState)
void
nsBlockFrame::DrainPushedFloats(nsBlockReflowState& aState)
{
#ifdef DEBUG
// Between when we drain pushed floats and when we complete reflow,
// we're allowed to have multiple continuations of the same float on
// our floats list, since a first-in-flow might get pushed to a later
// continuation of its containing block. But it's not permitted
// outside that time.
nsLayoutUtils::AssertNoDuplicateContinuations(this, mFloats);
#endif
// Take any continuations we need to take from our prev-in-flow.
nsBlockFrame* prevBlock = static_cast<nsBlockFrame*>(GetPrevInFlow());
if (!prevBlock)
@ -4522,15 +4538,6 @@ nsBlockFrame::DrainPushedFloats(nsBlockReflowState& aState)
}
delete list;
}
#ifdef DEBUG
for (nsIFrame* f = mFloats.FirstChild(); f ; f = f->GetNextSibling()) {
for (nsIFrame* c = f->GetFirstInFlow(); c ; c = c->GetNextInFlow()) {
NS_ASSERTION(c == f || c->GetParent() != this || !mFloats.ContainsFrame(c),
"Two floats with same parent in same floats list, expect weird errors.");
}
}
#endif
}
nsLineList*

View File

@ -972,7 +972,7 @@ asserts(1) == 418574-2.html 418574-2-ref.html # bug 478135
== 421436-1a.html 421436-1-ref.html
== 421436-1b.html 421436-1-ref.html
== 421632-1.html 421632-1-ref.html
asserts-if(gtk2Widget,4) asserts-if(winWidget,0-4) != 421710-1.html about:blank # assertion test (and crash test), asserts are bug 602426.
!= 421710-1.html about:blank
== 421885-1.xml 421885-1-ref.xml
== 421955-1.html 421955-1-ref.html
== 422249-1.html 422249-1-ref.html