Bug 482592. Use the right container in ContentInserted. r+sr=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 12 Mar 2009 10:17:14 -0400
changeset 26101 501d8a053dc93470578c72f5e7999e1b7d1e7b75
parent 26100 27cbf8dd3fbadc214fc2bbac0086f8a07c8acca2
child 26102 a9c7c01d5ed80370aa3d24b41f7bfb6dfd738653
push id5899
push userbzbarsky@mozilla.com
push dateThu, 12 Mar 2009 14:28:10 +0000
treeherdermozilla-central@501d8a053dc9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs482592
milestone1.9.2a1pre
Bug 482592. Use the right container in ContentInserted. r+sr=roc
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/bugs/482592-1-ref.html
layout/reftests/bugs/482592-1a.xhtml
layout/reftests/bugs/482592-1b.xhtml
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -7815,17 +7815,17 @@ nsCSSFrameConstructor::ContentInserted(n
       // Get continuation that parents the last child
       parentFrame = nsLayoutUtils::GetLastContinuationWithChild(parentFrame);
       // Deal with fieldsets
       parentFrame = ::GetAdjustedParentFrame(parentFrame,
                                              parentFrame->GetType(),
                                              aChild);
       parentFrame =
         ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
-                                            aContainer, parentFrame,
+                                            container, parentFrame,
                                             &appendAfterFrame);
     }
   }
 
   if (parentFrame->GetType() == nsGkAtoms::frameSetFrame &&
       IsSpecialFramesetChild(aChild)) {
     // Just reframe the parent, since framesets are weird like that.
     return RecreateFramesForContent(parentFrame->GetContent());
@@ -7905,17 +7905,17 @@ nsCSSFrameConstructor::ContentInserted(n
   }
 
   if (!prevSibling) {
     // We're inserting the new frame as the first child. See if the
     // parent has a :before pseudo-element
     nsIFrame* firstChild = parentFrame->GetFirstChild(nsnull);
 
     if (firstChild &&
-        nsLayoutUtils::IsGeneratedContentFor(aContainer, firstChild,
+        nsLayoutUtils::IsGeneratedContentFor(container, firstChild,
                                              nsCSSPseudoElements::before)) {
       // Insert the new frames after the last continuation of the :before
       prevSibling = firstChild->GetTailContinuation();
       parentFrame = prevSibling->GetParent();
       // We perhaps could leave this true and take the AppendFrames path
       // below, but we'd have to update appendAfterFrame and it seems safer
       // to force all insert-after-:before cases to take these to take the
       // InsertFrames path
@@ -7984,42 +7984,45 @@ nsCSSFrameConstructor::ContentInserted(n
                  (frame1->GetParent() &&
                   frame1->GetParent()->GetType() == nsGkAtoms::fieldSetFrame),
                  "Unexpected frame types");
 #endif
     prevSibling = nsnull;
     isAppend = PR_TRUE;
     parentFrame =
       ::AdjustAppendParentForAfterContent(mPresShell->GetPresContext(),
-                                          aContainer,
+                                          container,
                                           frameItems.childList->GetParent(),
                                           &appendAfterFrame);
   }
 
   if (haveFirstLineStyle && parentFrame == containingBlock) {
     // It's possible that the new frame goes into a first-line
     // frame. Look at it and see...
     if (isAppend) {
       // Use append logic when appending
       AppendFirstLineFrames(state, containingBlock->GetContent(),
                             containingBlock, frameItems); 
     }
     else {
       // Use more complicated insert logic when inserting
-      InsertFirstLineFrames(state, aContainer, containingBlock, &parentFrame,
+      // XXXbz this method is a no-op, so it's easy for the args being passed
+      // here to make no sense without anyone noticing...  If it ever stops
+      // being a no-op, vet them carefully!
+      InsertFirstLineFrames(state, container, containingBlock, &parentFrame,
                             prevSibling, frameItems);
     }
   }
       
   nsIFrame* const newFrame = frameItems.childList;
   if (NS_SUCCEEDED(rv) && newFrame) {
     NS_ASSERTION(!captionItems.childList, "leaking caption frames");
     // Notify the parent frame
     if (isAppend) {
-      AppendFrames(state, aContainer, parentFrame, frameItems,
+      AppendFrames(state, container, parentFrame, frameItems,
                    appendAfterFrame);
     } else {
       state.mFrameManager->InsertFrames(parentFrame,
                                         nsnull, prevSibling, newFrame);
     }
   }
   else {
     // we might have a caption treat it here
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/482592-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    xy
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/482592-1a.xhtml
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
+  <head>
+    <bindings xmlns="http://www.mozilla.org/xbl">
+      <binding id="a">
+        <content>
+          <html:span xmlns:html="http://www.w3.org/1999/xhtml"
+                     id="hasAfter"><children/></html:span>
+        </content>
+      </binding>
+    </bindings>
+    <style>
+      #hasAfter::after { content: "y"; }
+      #l { display: none; } 
+    </style>
+    <script>
+      function doTest() {
+        var l = document.getElementById("l");
+        l.parentNode.insertBefore(document.createTextNode("x"), l);
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="doTest()">
+    <div style="-moz-binding: url(#a)"><span id="l"></span></div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/482592-1b.xhtml
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
+  <head>
+    <bindings xmlns="http://www.mozilla.org/xbl">
+      <binding id="a">
+        <content>
+          <html:span xmlns:html="http://www.w3.org/1999/xhtml"
+                     id="hasBefore"><children/></html:span>
+        </content>
+      </binding>
+    </bindings>
+    <style>
+      #hasBefore::before { content: "x"; }
+    </style>
+    <script>
+      function doTest() {
+        var l = document.getElementById("l");
+        l.parentNode.insertBefore(document.createTextNode("y"), l);
+        document.documentElement.removeAttribute("class");
+      }
+    </script>
+  </head>
+  <body onload="doTest()">
+    <div style="-moz-binding: url(#a)"><span id="l"></span></div>
+  </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1092,8 +1092,10 @@ fails == 461512-1.html 461512-1-ref.html
 == 478377-1.xul 478377-1-ref.xul
 == 478811-1.html 478811-1-ref.html
 == 478811-2.html 478811-2-ref.html
 == 478811-3.html 478811-3-ref.html
 == 478811-4.html 478811-4-ref.html
 == 478956-1a.html 478956-1-ref.html
 == 478956-1b.html 478956-1-ref.html
 == 480017-1.html 480017-1-ref.html
+== 482592-1a.xhtml 482592-1-ref.html
+== 482592-1b.xhtml 482592-1-ref.html