Title: [114331] releases/WebKitGTK/webkit-1.8/Source/WebCore
Revision
114331
Author
mrobin...@webkit.org
Date
2012-04-16 18:06:57 -0700 (Mon, 16 Apr 2012)

Log Message

Merging r110150

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog (114330 => 114331)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog	2012-04-17 00:55:31 UTC (rev 114330)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/ChangeLog	2012-04-17 01:06:57 UTC (rev 114331)
@@ -1,3 +1,19 @@
+2012-04-16  Adam Barth  <aba...@webkit.org>
+
+        ContainerNode::insertedIntoDocument and removedFromDocument use weak iteration patterns
+        https://bugs.webkit.org/show_bug.cgi?id=80569
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch moves ContainerNode::insertedIntoDocument and
+        removedFromDocument to using a better iteration pattern in which we
+        collect all the nodes we're planning to iterate into a vector and then
+        iterate over them.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::insertedIntoDocument):
+        (WebCore::ContainerNode::removedFromDocument):
+
 2012-04-03  Dominik Röttsches  <dominik.rottsc...@linux.intel.com>
 
         Soup HTTP backend does not send Content-Length in certain cases

Modified: releases/WebKitGTK/webkit-1.8/Source/WebCore/dom/ContainerNode.cpp (114330 => 114331)


--- releases/WebKitGTK/webkit-1.8/Source/WebCore/dom/ContainerNode.cpp	2012-04-17 00:55:31 UTC (rev 114330)
+++ releases/WebKitGTK/webkit-1.8/Source/WebCore/dom/ContainerNode.cpp	2012-04-17 01:06:57 UTC (rev 114331)
@@ -809,13 +809,17 @@
     Node::insertedIntoDocument();
     insertedIntoTree(false);
 
-    for (RefPtr<Node> child = m_firstChild; child; child = child->nextSibling()) {
-        // Guard against mutation during re-parenting.
-        if (!inDocument()) // Check for self being removed from document while reparenting.
+    NodeVector children;
+    collectNodes(this, children);
+    for (size_t i = 0; i < children.size(); ++i) {
+        // If we have been removed from the document during this loop, then
+        // we don't want to tell the rest of our children that they've been
+        // inserted into the document because they haven't.
+        if (!inDocument())
             break;
-        if (child->parentNode() != this) // Check for child being removed from subtree while reparenting.
-            break;
-        child->insertedIntoDocument();
+        if (children[i]->parentNode() != this)
+            continue;
+        children[i]->insertedIntoDocument();
     }
 }
 
@@ -826,8 +830,19 @@
         document()->setCSSTarget(0); 
     clearInDocument();
     removedFromTree(false);
-    for (Node* child = m_firstChild; child; child = child->nextSibling())
-        child->removedFromDocument();
+
+    NodeVector children;
+    collectNodes(this, children);
+    for (size_t i = 0; i < children.size(); ++i) {
+        // If we have been added to the document during this loop, then we
+        // don't want to tell the rest of our children that they've been
+        // removed from the document because they haven't.
+        if (inDocument())
+            break;
+        if (children[i]->parentNode() != this)
+            continue;
+        children[i]->removedFromDocument();
+    }
 }
 
 void ContainerNode::insertedIntoTree(bool deep)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to