Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: Source/WebCore/dom/ContainerNode.cpp

Issue 9854037: Merge 110150 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1025/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/ContainerNode.cpp
===================================================================
--- Source/WebCore/dom/ContainerNode.cpp (revision 112450)
+++ Source/WebCore/dom/ContainerNode.cpp (working copy)
@@ -813,13 +813,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();
}
}
@@ -830,8 +834,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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698