From cb4f2aea5c0623db2323d129b2dcd8138bb759ea Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Sat, 3 Nov 2001 05:18:39 +0000 Subject: [PATCH] Fix FMR/FMW caused by translating the space manager right after deleting it. r=jag sr=waterson b=108017 --- layout/generic/nsBlockFrame.cpp | 1 + layout/generic/nsBlockReflowState.cpp | 21 ++++++++++++++++++--- layout/html/base/src/nsBlockFrame.cpp | 1 + layout/html/base/src/nsBlockReflowState.cpp | 21 ++++++++++++++++++--- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 6b63a9e6df02..80f7f6b0cf68 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -884,6 +884,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (!transferredSpaceManager) #endif delete spaceManager; + state.mSpaceManager = nsnull; } #ifdef NOISY_SPACEMANAGER diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index b19b83c35a99..b006b45e616c 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -176,9 +176,12 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState, nsBlockReflowState::~nsBlockReflowState() { - // Restore the coordinate system - const nsMargin& borderPadding = BorderPadding(); - mSpaceManager->Translate(-borderPadding.left, -borderPadding.top); + // Restore the coordinate system, unless the space manager is null, + // which means it was just destroyed. + if (mSpaceManager) { + const nsMargin& borderPadding = BorderPadding(); + mSpaceManager->Translate(-borderPadding.left, -borderPadding.top); + } } nsLineBox* @@ -471,6 +474,18 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine) } } +/** + * Everything done in this function is done O(N) times for each pass of + * reflow so it is O(N*M) where M is the number of incremental reflow + * passes. That's bad. Don't do stuff here. + * + * When this function is called, |aLine| has just been slid by |aDeltaY| + * and the purpose of RecoverStateFrom is to ensure that the + * nsBlockReflowState is in the same state that it would have been in + * had the line just been reflowed. + * + * Most of the state recovery that we have to do involves floaters. + */ void nsBlockReflowState::RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY) diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 6b63a9e6df02..80f7f6b0cf68 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -884,6 +884,7 @@ nsBlockFrame::Reflow(nsIPresContext* aPresContext, if (!transferredSpaceManager) #endif delete spaceManager; + state.mSpaceManager = nsnull; } #ifdef NOISY_SPACEMANAGER diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index b19b83c35a99..b006b45e616c 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -176,9 +176,12 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState, nsBlockReflowState::~nsBlockReflowState() { - // Restore the coordinate system - const nsMargin& borderPadding = BorderPadding(); - mSpaceManager->Translate(-borderPadding.left, -borderPadding.top); + // Restore the coordinate system, unless the space manager is null, + // which means it was just destroyed. + if (mSpaceManager) { + const nsMargin& borderPadding = BorderPadding(); + mSpaceManager->Translate(-borderPadding.left, -borderPadding.top); + } } nsLineBox* @@ -471,6 +474,18 @@ nsBlockReflowState::ReconstructMarginAbove(nsLineList::iterator aLine) } } +/** + * Everything done in this function is done O(N) times for each pass of + * reflow so it is O(N*M) where M is the number of incremental reflow + * passes. That's bad. Don't do stuff here. + * + * When this function is called, |aLine| has just been slid by |aDeltaY| + * and the purpose of RecoverStateFrom is to ensure that the + * nsBlockReflowState is in the same state that it would have been in + * had the line just been reflowed. + * + * Most of the state recovery that we have to do involves floaters. + */ void nsBlockReflowState::RecoverStateFrom(nsLineList::iterator aLine, nscoord aDeltaY)