Bug 607494. Add assertions to catch creating frames for content nodes that already have a frame. r=bzbarsky a=blocking-final+
authorTimothy Nikkel <tnikkel@gmail.com>
Wed, 24 Nov 2010 19:35:01 -0600
changeset 58204 a352c0afa63175292938f9392e2c5fb39ec58251
parent 58203 9cc9952ecc898cc258a50ac8074dc7fa54dfa7f1
child 58205 c6a2526886f959b6923e93aa5578945140dca1f9
push id1
push usershaver@mozilla.com
push dateTue, 04 Jan 2011 17:58:04 +0000
reviewersbzbarsky, blocking-final
bugs607494
milestone2.0b8pre
Bug 607494. Add assertions to catch creating frames for content nodes that already have a frame. r=bzbarsky a=blocking-final+
layout/base/nsCSSFrameConstructor.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -5036,16 +5036,23 @@ nsCSSFrameConstructor::AddFrameConstruct
     // "is possible restyle root" flags, and need to.  Otherwise we can
     // end up with stale such flags (e.g. if we used to have a
     // display:none parent when our last restyle was posted and
     // processed and now no longer do).
     aContent->UnsetFlags(ELEMENT_ALL_RESTYLE_FLAGS &
                          ~ELEMENT_PENDING_RESTYLE_FLAGS);
   }
 
+  // XXX the GetContent() != aContent check is needed due to bug 135040.
+  // Remove it once that's fixed.  
+  NS_ASSERTION(!aContent->GetPrimaryFrame() ||
+    aContent->GetPrimaryFrame()->GetContent() != aContent ||
+    aState.mCreatingExtraFrames,
+    "asked to create frame construction item for a node that already has a frame");
+
   // don't create a whitespace frame if aParent doesn't want it
   if (!NeedFrameFor(aState, aParentFrame, aContent)) {
     return;
   }
 
   // never create frames for comments or PIs
   if (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
       aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION))
@@ -6476,16 +6483,28 @@ nsCSSFrameConstructor::ContentAppended(n
            static_cast<void*>(aContainer), aFirstNewContent,
            aAllowLazyConstruction);
     if (gReallyNoisyContentUpdates && aContainer) {
       aContainer->List(stdout, 0);
     }
   }
 #endif
 
+#ifdef DEBUG
+  for (nsIContent* child = aFirstNewContent;
+       child;
+       child = child->GetNextSibling()) {
+    // XXX the GetContent() != child check is needed due to bug 135040.
+    // Remove it once that's fixed.  
+    NS_ASSERTION(!child->GetPrimaryFrame() ||
+                 child->GetPrimaryFrame()->GetContent() != child,
+                 "asked to construct a frame for a node that already has a frame");
+  }
+#endif
+
 #ifdef MOZ_XUL
   if (aContainer) {
     PRInt32 namespaceID;
     nsIAtom* tag =
       mDocument->BindingManager()->ResolveTag(aContainer, &namespaceID);
 
     // Just ignore tree tags, anyway we don't create any frames for them.
     if (tag == nsGkAtoms::treechildren ||
@@ -6827,16 +6846,28 @@ nsCSSFrameConstructor::ContentRangeInser
         aContainer->List(stdout,0);
       } else {
         aStartChild->List(stdout, 0);
       }
     }
   }
 #endif
 
+#ifdef DEBUG
+  for (nsIContent* child = aStartChild;
+       child != aEndChild;
+       child = child->GetNextSibling()) {
+    // XXX the GetContent() != child check is needed due to bug 135040.
+    // Remove it once that's fixed.  
+    NS_ASSERTION(!child->GetPrimaryFrame() ||
+                 child->GetPrimaryFrame()->GetContent() != child,
+                 "asked to construct a frame for a node that already has a frame");
+  }
+#endif
+
   nsresult rv = NS_OK;
 
   PRBool isSingleInsert = (aStartChild->GetNextSibling() == aEndChild);
   NS_ASSERTION(isSingleInsert || !aAllowLazyConstruction,
                "range insert shouldn't be lazy");
   NS_ASSERTION(isSingleInsert || aEndChild,
                "range should not include all nodes after aStartChild");