Title: [114053] branches/safari-534.57-branch/Source/WebCore
Revision
114053
Author
[email protected]
Date
2012-04-12 17:15:50 -0700 (Thu, 12 Apr 2012)

Log Message

Merged r110150.

Modified Paths

Diff

Modified: branches/safari-534.57-branch/Source/WebCore/ChangeLog (114052 => 114053)


--- branches/safari-534.57-branch/Source/WebCore/ChangeLog	2012-04-13 00:09:40 UTC (rev 114052)
+++ branches/safari-534.57-branch/Source/WebCore/ChangeLog	2012-04-13 00:15:50 UTC (rev 114053)
@@ -1,5 +1,25 @@
 2012-04-12  Lucas Forschler  <[email protected]>
 
+    Merge 110150
+
+    2012-03-07  Adam Barth  <[email protected]>
+
+            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-12  Lucas Forschler  <[email protected]>
+
     Merge 110139
 
     2012-03-07  Adam Barth  <[email protected]>

Modified: branches/safari-534.57-branch/Source/WebCore/dom/ContainerNode.cpp (114052 => 114053)


--- branches/safari-534.57-branch/Source/WebCore/dom/ContainerNode.cpp	2012-04-13 00:09:40 UTC (rev 114052)
+++ branches/safari-534.57-branch/Source/WebCore/dom/ContainerNode.cpp	2012-04-13 00:15:50 UTC (rev 114053)
@@ -773,13 +773,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();
     }
 }
 
@@ -790,8 +794,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
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to