Title: [112451] branches/chromium/1025/Source/WebCore/dom/ContainerNode.cpp
- Revision
- 112451
- Author
- [email protected]
- Date
- 2012-03-28 15:11:47 -0700 (Wed, 28 Mar 2012)
Log Message
Merge 110150
BUG=117400
Review URL: https://chromiumcodereview.appspot.com/9854037
Modified Paths
Diff
Modified: branches/chromium/1025/Source/WebCore/dom/ContainerNode.cpp (112450 => 112451)
--- branches/chromium/1025/Source/WebCore/dom/ContainerNode.cpp 2012-03-28 22:09:28 UTC (rev 112450)
+++ branches/chromium/1025/Source/WebCore/dom/ContainerNode.cpp 2012-03-28 22:11:47 UTC (rev 112451)
@@ -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)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes