diff --git a/mozilla/layout/base/nsCSSFrameConstructor.cpp b/mozilla/layout/base/nsCSSFrameConstructor.cpp index 06c378b54d6..1500f2baa2d 100644 --- a/mozilla/layout/base/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/base/nsCSSFrameConstructor.cpp @@ -2802,9 +2802,8 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel rv = aTableCreator.CreateTableColFrame(&aNewFrame); if (NS_FAILED(rv)) return rv; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context - nsStyleContext* parentStyleContext = parentFrame->GetStyleContext(); if (aIsPseudoParent) { - aPresContext->ReParentStyleContext(aNewFrame, parentStyleContext); + aPresContext->ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); } // construct additional col frames if the col frame has a span > 1 @@ -11678,8 +11677,8 @@ ReparentFrame(nsIPresContext* aPresContext, nsStyleContext* aParentStyleContext, nsIFrame* aFrame) { - aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); aFrame->SetParent(aNewParentFrame); + aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); } // Special routine to handle placing a list of frames into a block diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index adeaf34325e..b6880ca08c1 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -1463,10 +1463,8 @@ FrameManager::ReParentStyleContext(nsIFrame* aFrame, NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); nsresult result = NS_ERROR_NULL_POINTER; if (aFrame) { -#ifdef NS_DEBUG - DebugVerifyStyleTree(aFrame); -#endif - + // DO NOT verify the style tree before reparenting. The frame + // tree has already been changed, so this check would just fail. nsStyleContext* oldContext = aFrame->GetStyleContext(); if (oldContext) { nsIPresContext *presContext = GetPresContext(); @@ -1529,7 +1527,7 @@ FrameManager::ReParentStyleContext(nsIFrame* aFrame, break; } } -#ifdef NS_DEBUG +#ifdef DEBUG VerifyStyleTree(GetPresContext(), aFrame, aNewParentContext); #endif } diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index f918f559db9..5d9c73f7e09 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -253,7 +253,9 @@ public: /** * For a given frame tree, get a new style context that is the equivalent - * but within a new parent + * but within a new parent. The StyleContextParent of aFrame should be + * changed _before_ this method is called, so that style tree verification + * can take place correctly. */ NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext) = 0; diff --git a/mozilla/layout/base/public/nsIFrameManager.h b/mozilla/layout/base/public/nsIFrameManager.h index ba08e279fe2..dc4da9035d8 100644 --- a/mozilla/layout/base/public/nsIFrameManager.h +++ b/mozilla/layout/base/public/nsIFrameManager.h @@ -140,7 +140,9 @@ public: NS_IMETHOD NotifyDestroyingFrame(nsIFrame* aFrame) = 0; // reparent the style contexts of this frame sub tree to live under the - // new given parent style context + // new given parent style context. The StyleContextParent of aFrame + // should be changed _before_ this method is called, so that style tree + // verification can take place correctly. NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext) = 0; diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index f918f559db9..5d9c73f7e09 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -253,7 +253,9 @@ public: /** * For a given frame tree, get a new style context that is the equivalent - * but within a new parent + * but within a new parent. The StyleContextParent of aFrame should be + * changed _before_ this method is called, so that style tree verification + * can take place correctly. */ NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext) = 0; diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index f918f559db9..5d9c73f7e09 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -253,7 +253,9 @@ public: /** * For a given frame tree, get a new style context that is the equivalent - * but within a new parent + * but within a new parent. The StyleContextParent of aFrame should be + * changed _before_ this method is called, so that style tree verification + * can take place correctly. */ NS_IMETHOD ReParentStyleContext(nsIFrame* aFrame, nsStyleContext* aNewParentContext) = 0; diff --git a/mozilla/layout/generic/nsFirstLetterFrame.cpp b/mozilla/layout/generic/nsFirstLetterFrame.cpp index b164aa66848..5ce2fb60d0a 100644 --- a/mozilla/layout/generic/nsFirstLetterFrame.cpp +++ b/mozilla/layout/generic/nsFirstLetterFrame.cpp @@ -158,8 +158,8 @@ nsFirstLetterFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame* aChildList) { mFrames.SetFrames(aChildList); - if (aChildList) { - aPresContext->ReParentStyleContext(aChildList, mStyleContext); + for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) { + aPresContext->ReParentStyleContext(frame, mStyleContext); } return NS_OK; } diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index 037ce2e1e43..3e70c33eea2 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -993,8 +993,8 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, if (prevOverflowFrames) { nsFrameList frames(prevOverflowFrames); - ReParentChildListStyle(aPresContext, mStyleContext, frames); mFrames.InsertFrames(this, nsnull, prevOverflowFrames); + ReParentChildListStyle(aPresContext, mStyleContext, frames); } } @@ -1004,8 +1004,8 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames"); nsFrameList frames(overflowFrames); - ReParentChildListStyle(aPresContext, mStyleContext, frames); mFrames.AppendFrames(nsnull, overflowFrames); + ReParentChildListStyle(aPresContext, mStyleContext, frames); } // Set our own reflow state (additional state above and beyond diff --git a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp index b164aa66848..5ce2fb60d0a 100644 --- a/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp +++ b/mozilla/layout/html/base/src/nsFirstLetterFrame.cpp @@ -158,8 +158,8 @@ nsFirstLetterFrame::SetInitialChildList(nsIPresContext* aPresContext, nsIFrame* aChildList) { mFrames.SetFrames(aChildList); - if (aChildList) { - aPresContext->ReParentStyleContext(aChildList, mStyleContext); + for (nsIFrame* frame = aChildList; frame; frame = frame->GetNextSibling()) { + aPresContext->ReParentStyleContext(frame, mStyleContext); } return NS_OK; } diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index adeaf34325e..b6880ca08c1 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -1463,10 +1463,8 @@ FrameManager::ReParentStyleContext(nsIFrame* aFrame, NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_AVAILABLE); nsresult result = NS_ERROR_NULL_POINTER; if (aFrame) { -#ifdef NS_DEBUG - DebugVerifyStyleTree(aFrame); -#endif - + // DO NOT verify the style tree before reparenting. The frame + // tree has already been changed, so this check would just fail. nsStyleContext* oldContext = aFrame->GetStyleContext(); if (oldContext) { nsIPresContext *presContext = GetPresContext(); @@ -1529,7 +1527,7 @@ FrameManager::ReParentStyleContext(nsIFrame* aFrame, break; } } -#ifdef NS_DEBUG +#ifdef DEBUG VerifyStyleTree(GetPresContext(), aFrame, aNewParentContext); #endif } diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index 037ce2e1e43..3e70c33eea2 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -993,8 +993,8 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, if (prevOverflowFrames) { nsFrameList frames(prevOverflowFrames); - ReParentChildListStyle(aPresContext, mStyleContext, frames); mFrames.InsertFrames(this, nsnull, prevOverflowFrames); + ReParentChildListStyle(aPresContext, mStyleContext, frames); } } @@ -1004,8 +1004,8 @@ nsFirstLineFrame::Reflow(nsIPresContext* aPresContext, NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames"); nsFrameList frames(overflowFrames); - ReParentChildListStyle(aPresContext, mStyleContext, frames); mFrames.AppendFrames(nsnull, overflowFrames); + ReParentChildListStyle(aPresContext, mStyleContext, frames); } // Set our own reflow state (additional state above and beyond diff --git a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp index 06c378b54d6..1500f2baa2d 100644 --- a/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp +++ b/mozilla/layout/html/style/src/nsCSSFrameConstructor.cpp @@ -2802,9 +2802,8 @@ nsCSSFrameConstructor::ConstructTableColFrame(nsIPresShell* aPresShel rv = aTableCreator.CreateTableColFrame(&aNewFrame); if (NS_FAILED(rv)) return rv; InitAndRestoreFrame(aPresContext, aState, aContent, parentFrame, aStyleContext, nsnull, aNewFrame); // if the parent frame was anonymous then reparent the style context - nsStyleContext* parentStyleContext = parentFrame->GetStyleContext(); if (aIsPseudoParent) { - aPresContext->ReParentStyleContext(aNewFrame, parentStyleContext); + aPresContext->ReParentStyleContext(aNewFrame, parentFrame->GetStyleContext()); } // construct additional col frames if the col frame has a span > 1 @@ -11678,8 +11677,8 @@ ReparentFrame(nsIPresContext* aPresContext, nsStyleContext* aParentStyleContext, nsIFrame* aFrame) { - aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); aFrame->SetParent(aNewParentFrame); + aPresContext->ReParentStyleContext(aFrame, aParentStyleContext); } // Special routine to handle placing a list of frames into a block