From 56de4122941d97653d0329b6feccb71be2421a90 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 8 Oct 2008 09:07:04 -0400 Subject: [PATCH] Bug 455063. Make sure we don't lose track of our initial containing block. r+sr=roc --- layout/base/crashtests/455063-1.html | 6 ++++++ layout/base/crashtests/455063-2.html | 6 ++++++ layout/base/crashtests/455063-3.html | 6 ++++++ layout/base/crashtests/crashtests.list | 3 +++ layout/base/nsCSSFrameConstructor.cpp | 18 ++++++++++++++++-- 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 layout/base/crashtests/455063-1.html create mode 100644 layout/base/crashtests/455063-2.html create mode 100644 layout/base/crashtests/455063-3.html diff --git a/layout/base/crashtests/455063-1.html b/layout/base/crashtests/455063-1.html new file mode 100644 index 000000000000..bb8e5e9dd290 --- /dev/null +++ b/layout/base/crashtests/455063-1.html @@ -0,0 +1,6 @@ + + +
+ + + diff --git a/layout/base/crashtests/455063-2.html b/layout/base/crashtests/455063-2.html new file mode 100644 index 000000000000..666998eda59e --- /dev/null +++ b/layout/base/crashtests/455063-2.html @@ -0,0 +1,6 @@ + + +
+ + + diff --git a/layout/base/crashtests/455063-3.html b/layout/base/crashtests/455063-3.html new file mode 100644 index 000000000000..20234d4adc27 --- /dev/null +++ b/layout/base/crashtests/455063-3.html @@ -0,0 +1,6 @@ + + +
+ + + diff --git a/layout/base/crashtests/crashtests.list b/layout/base/crashtests/crashtests.list index 399eb12baf1d..d9d8b42c31f1 100644 --- a/layout/base/crashtests/crashtests.list +++ b/layout/base/crashtests/crashtests.list @@ -124,3 +124,6 @@ load 429088-2.html load 432752-1.svg load 433450-1.html load 444925-1.xul +load 455063-1.html +load 455063-2.html +load 455063-3.html diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 9084726ea877..0384ae6665ca 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3542,6 +3542,12 @@ nsCSSFrameConstructor::ConstructTableFrame(nsFrameConstructorState& aState, return rv; } + if (!mInitialContainingBlock) { + // The frame we're constructing will be the initial containing block. + // Set mInitialContainingBlock before processing children. + mInitialContainingBlock = aNewOuterFrame; + } + nsFrameItems childItems; rv = ProcessChildren(aState, aContent, aNewInnerFrame, PR_TRUE, childItems, PR_FALSE); @@ -4297,6 +4303,9 @@ nsCSSFrameConstructor::ConstructDocElementFrame(nsFrameConstructorState& aState, // set the primary frame aState.mFrameManager->SetPrimaryFrameFor(aDocElement, contentFrame); + NS_ASSERTION(processChildren ? !mInitialContainingBlock : + mInitialContainingBlock == contentFrame, + "unexpected mInitialContainingBlock"); mInitialContainingBlock = contentFrame; // Figure out which frame has the main style for the document element, @@ -7715,8 +7724,7 @@ nsCSSFrameConstructor::GetAbsoluteContainingBlock(nsIFrame* aFrame) if (frame->IsFrameOfType(nsIFrame::eMathML)) { // If it's mathml, bail out -- no absolute positioning out from inside // mathml frames. Note that we don't make this part of the loop - // condition because of the mInitialContainingBlock stuff at the - // end of this method... + // condition because of the stuff at the end of this method... return nsnull; } @@ -12315,6 +12323,12 @@ nsCSSFrameConstructor::ConstructBlock(nsFrameConstructorState& aState, // See if we need to create a view, e.g. the frame is absolutely positioned nsHTMLContainerFrame::CreateViewForFrame(blockFrame, contentParent, PR_FALSE); + if (!mInitialContainingBlock) { + // The frame we're constructing will be the initial containing block. + // Set mInitialContainingBlock before processing children. + mInitialContainingBlock = *aNewFrame; + } + // We should make the outer frame be the absolute containing block, // if one is required. We have to do this because absolute // positioning must be computed with respect to the CSS dimensions