Title: [110139] trunk/Source/WebCore
Revision
110139
Author
aba...@webkit.org
Date
2012-03-07 20:08:41 -0800 (Wed, 07 Mar 2012)

Log Message

ContainerNode::willRemove uses a weak iteration pattern
https://bugs.webkit.org/show_bug.cgi?id=80530

Reviewed by Ryosuke Niwa.

This patch moves ContainerNode::willRemove 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::willRemove):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (110138 => 110139)


--- trunk/Source/WebCore/ChangeLog	2012-03-08 04:04:40 UTC (rev 110138)
+++ trunk/Source/WebCore/ChangeLog	2012-03-08 04:08:41 UTC (rev 110139)
@@ -1,3 +1,17 @@
+2012-03-07  Adam Barth  <aba...@webkit.org>
+
+        ContainerNode::willRemove uses a weak iteration pattern
+        https://bugs.webkit.org/show_bug.cgi?id=80530
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch moves ContainerNode::willRemove 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::willRemove):
+
 2012-03-07  Kentaro Hara  <hara...@chromium.org>
 
         [V8][Performance] Optimize V8 bindings for HTMLElement.classList,

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (110138 => 110139)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2012-03-08 04:04:40 UTC (rev 110138)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2012-03-08 04:08:41 UTC (rev 110139)
@@ -371,11 +371,14 @@
 {
     RefPtr<Node> protect(this);
 
-    for (RefPtr<Node> child = firstChild(); child; child = child->nextSibling()) {
-        if (child->parentNode() != this) // Check for child being removed from subtree while removing.
-            break;
-        child->willRemove();
+    NodeVector children;
+    collectNodes(this, children);
+    for (size_t i = 0; i < children.size(); ++i) {
+        if (children[i]->parentNode() != this) // Check for child being removed from subtree while removing.
+            continue;
+        children[i]->willRemove();
     }
+
     Node::willRemove();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to