Title: [110150] trunk/Source/WebCore
- Revision
- 110150
- Author
- aba...@webkit.org
- Date
- 2012-03-07 23:34:44 -0800 (Wed, 07 Mar 2012)
Log Message
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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (110149 => 110150)
--- trunk/Source/WebCore/ChangeLog 2012-03-08 06:55:36 UTC (rev 110149)
+++ trunk/Source/WebCore/ChangeLog 2012-03-08 07:34:44 UTC (rev 110150)
@@ -1,3 +1,19 @@
+2012-03-07 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-03-07 Ami Fischman <fisch...@chromium.org>
[Chromium] Allow CCLayerTreeHost::context() to be called even with the threaded compositor enabled.
Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (110149 => 110150)
--- trunk/Source/WebCore/dom/ContainerNode.cpp 2012-03-08 06:55:36 UTC (rev 110149)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp 2012-03-08 07:34:44 UTC (rev 110150)
@@ -785,13 +785,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();
}
}
@@ -802,8 +806,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