Bug 455063. Make sure we don't lose track of our initial containing block. r+sr=roc
authorMats Palmgren <mats.palmgren@bredband.net>
Wed, 08 Oct 2008 09:07:04 -0400
changeset 20147 ad4d8bd0f99bf72e95c0904f37b7ab7227b97836
parent 20146 1e55532f66ca9c4597113936a0302e3e4851278e
child 20148 68108962dd089da541c221adb033f76f4e8ff129
push idunknown
push userunknown
push dateunknown
bugs455063
milestone1.9.1b2pre
Bug 455063. Make sure we don't lose track of our initial containing block. r+sr=roc
layout/base/crashtests/455063-1.html
layout/base/crashtests/455063-2.html
layout/base/crashtests/455063-3.html
layout/base/crashtests/crashtests.list
layout/base/nsCSSFrameConstructor.cpp
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/455063-1.html
@@ -0,0 +1,6 @@
+<html>
+<body onload="document.documentElement.style.display = 'table'">
+  <span><div></div></span>
+</body>
+
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/455063-2.html
@@ -0,0 +1,6 @@
+<html style="display:table">
+<body onload="document.documentElement.style.display = 'block'">
+  <span><div></div></span>
+</body>
+
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/455063-3.html
@@ -0,0 +1,6 @@
+<html style="display:block;-moz-column-count:2;column-count:2;">
+<body>
+  <span><div></div></span>
+</body>
+
+</html>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -119,8 +119,11 @@ load 420213-1.html
 load 420651-1.xhtml
 load 423107-1.xhtml
 load 428448-1.html
 load 429088-1.html
 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
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -3537,16 +3537,22 @@ nsCSSFrameConstructor::ConstructTableFra
     aNewOuterFrame->SetInitialChildList(nsnull, aNewInnerFrame);
 
     rv = aState.AddChild(aNewOuterFrame, *frameItems, aContent,
                          aStyleContext, parentFrame);
     if (NS_FAILED(rv)) {
       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);
     // XXXbz what about cleaning up?
     if (NS_FAILED(rv)) return rv;
 
     // if there are any anonymous children for the table, create frames for them
     CreateAnonymousFrames(nsnull, aState, aContent, aNewInnerFrame,
@@ -4292,16 +4298,19 @@ nsCSSFrameConstructor::ConstructDocEleme
       NS_ASSERTION(!frameItems.childList->GetNextSibling(),
                    "multiple root element frames");
     }
   }
 
   // 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,
   // assigning it to mRootElementStyleFrame.
   // Backgrounds should be propagated from that frame to the viewport.
   PRBool isChild;
   contentFrame->GetParentStyleContextFrame(aState.mPresContext,
           &mRootElementStyleFrame, &isChild);
@@ -7710,18 +7719,17 @@ nsCSSFrameConstructor::GetAbsoluteContai
   // Starting with aFrame, look for a frame that is absolutely positioned or
   // relatively positioned
   nsIFrame* containingBlock = nsnull;
   for (nsIFrame* frame = aFrame; frame && !containingBlock;
        frame = frame->GetParent()) {
     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;
     }
     
     // Is it positioned?
     // If it's table-related then ignore it, because for the time
     // being table-related frames are not containers for absolutely
     // positioned child frames.
     const nsStyleDisplay* disp = frame->GetStyleDisplay();
@@ -12310,16 +12318,22 @@ nsCSSFrameConstructor::ConstructBlock(ns
                                                       aParentFrame);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // 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
   // of the element, which are the dimensions of the outer block. But
   // we can't really do that because only blocks can have absolute
   // children. So use the block and try to compensate with hacks
   // in nsBlockFrame::CalculateContainingBlockSizeForAbsolutes.
   nsFrameConstructorSaveState absoluteSaveState;