diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index d26ac731e9d6..ac36fc85c4a5 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -993,8 +993,7 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext, // delete the line with the line cursor. ClearLineCursor(); - if (IsFrameTreeTooDeep(aReflowState, aMetrics)) { - aStatus = NS_FRAME_COMPLETE; + if (IsFrameTreeTooDeep(aReflowState, aMetrics, aStatus)) { return NS_OK; } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index b85fdc70817e..282a4ad95bf8 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4551,7 +4551,8 @@ nsIFrame::CheckInvalidateSizeChange(const nsRect& aOldRect, PRBool nsFrame::IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState, - nsHTMLReflowMetrics& aMetrics) + nsHTMLReflowMetrics& aMetrics, + nsReflowStatus& aStatus) { if (aReflowState.mReflowDepth > MAX_FRAME_DEPTH) { NS_WARNING("frame tree too deep; setting zero size and returning"); @@ -4562,6 +4563,16 @@ nsFrame::IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState, aMetrics.ascent = 0; aMetrics.mCarriedOutBottomMargin.Zero(); aMetrics.mOverflowAreas.Clear(); + + if (GetNextInFlow()) { + // Reflow depth might vary between reflows, so we might have + // successfully reflowed and split this frame before. If so, we + // shouldn't delete its continuations. + aStatus = NS_FRAME_NOT_COMPLETE; + } else { + aStatus = NS_FRAME_COMPLETE; + } + return PR_TRUE; } mState &= ~NS_FRAME_TOO_DEEP_IN_FRAME_TREE; diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index de3ec1803af6..13d876217389 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -386,13 +386,14 @@ public: */ void CheckInvalidateSizeChange(nsHTMLReflowMetrics& aNewDesiredSize); - // Helper function that tests if the frame tree is too deep; if it - // is it marks the frame as "unflowable" and zeros out the metrics - // and returns PR_TRUE. Otherwise, the frame is unmarked - // "unflowable" and the metrics are not touched and PR_FALSE is - // returned. + // Helper function that tests if the frame tree is too deep; if it is + // it marks the frame as "unflowable", zeroes out the metrics, sets + // the reflow status, and returns PR_TRUE. Otherwise, the frame is + // unmarked "unflowable" and the metrics and reflow status are not + // touched and PR_FALSE is returned. PRBool IsFrameTreeTooDeep(const nsHTMLReflowState& aReflowState, - nsHTMLReflowMetrics& aMetrics); + nsHTMLReflowMetrics& aMetrics, + nsReflowStatus& aStatus); // Do the work for getting the parent style context frame so that // other frame's |GetParentStyleContextFrame| methods can call this diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index 79a28647e2aa..e04a638900f8 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -392,8 +392,7 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext, } } - if (IsFrameTreeTooDeep(aReflowState, aMetrics)) { - aStatus = NS_FRAME_COMPLETE; + if (IsFrameTreeTooDeep(aReflowState, aMetrics, aStatus)) { return NS_OK; }