Fix determination of the style context parent for the inner table frame of aroot table. Bug 379386, r+sr=roc
authorbzbarsky@mit.edu
Mon, 07 May 2007 20:59:12 -0700
changeset 1270 ff2cfd939890f0977529437a4ee6a2ac56c5f290
parent 1269 006125ab92f96288e092482bfb11b05904a64038
child 1271 7a7287c57ecf0c2c2a6a29b5107d66e9f73d1a22
push idunknown
push userunknown
push dateunknown
bugs379386
milestone1.9a5pre
Fix determination of the style context parent for the inner table frame of aroot table. Bug 379386, r+sr=roc
layout/generic/nsFrame.cpp
layout/tables/nsTableFrame.cpp
layout/tables/nsTableOuterFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -5508,21 +5508,17 @@ nsFrame::CorrectStyleParentFrame(nsIFram
     }
 
     parent = parent->GetParent();
   } while (parent);
 
   // We can get here if aProspectiveParent is the scrollframe for a viewport
   // and the kids are the anonymous scrollbars.
   NS_ASSERTION(aProspectiveParent->GetStyleContext()->GetPseudoType() ==
-                 nsCSSAnonBoxes::viewportScroll ||
-               aProspectiveParent->GetStyleContext()->GetPseudoType() ==
-                 nsCSSAnonBoxes::canvas ||
-               aProspectiveParent->GetStyleContext()->GetPseudoType() ==
-                 nsCSSAnonBoxes::pageSequence,
+                 nsCSSAnonBoxes::viewportScroll,
                "Should have found a parent before this");
   return aProspectiveParent;
 }
 
 nsresult
 nsFrame::DoGetParentStyleContextFrame(nsPresContext* aPresContext,
                                       nsIFrame**      aProviderFrame,
                                       PRBool*         aIsChild)
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -159,16 +159,23 @@ NS_IMETHODIMP
 nsTableFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
                                          nsIFrame**      aProviderFrame,
                                          PRBool*         aIsChild)
 {
   // Since our parent, the table outer frame, returned this frame, we
   // must return whatever our parent would normally have returned.
 
   NS_PRECONDITION(mParent, "table constructed without outer table");
+  if (!mContent->GetParent() && !GetStyleContext()->GetPseudoType()) {
+    // We're the root.  We have no style context parent.
+    *aIsChild = PR_FALSE;
+    *aProviderFrame = nsnull;
+    return NS_OK;
+  }
+    
   return NS_STATIC_CAST(nsFrame*, mParent)->
           DoGetParentStyleContextFrame(aPresContext, aProviderFrame, aIsChild);
 }
 
 
 nsIAtom*
 nsTableFrame::GetType() const
 {
--- a/layout/tables/nsTableOuterFrame.cpp
+++ b/layout/tables/nsTableOuterFrame.cpp
@@ -110,16 +110,19 @@ nsTableCaptionFrame::ComputeAutoSize(nsI
   return result;
 }
 
 NS_IMETHODIMP 
 nsTableCaptionFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
                                                 nsIFrame**      aProviderFrame,
                                                 PRBool*         aIsChild)
 {
+  NS_PRECONDITION(mContent->GetParent(),
+                  "How could we not have a parent here?");
+    
   // The caption's style context parent is the inner frame, unless
   // it's anonymous.
   nsIFrame* outerFrame = GetParent();
   if (outerFrame && outerFrame->GetType() == nsGkAtoms::tableOuterFrame) {
     nsIFrame* innerFrame = outerFrame->GetFirstChild(nsnull);
     if (innerFrame) {
       *aProviderFrame =
         nsFrame::CorrectStyleParentFrame(innerFrame,