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

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

Issue 7049017: Merge 86358 - 2011-05-12 Carol Szabo <carol@webkit.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/742/
Patch Set: Created 9 years, 7 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
Index: Source/WebCore/dom/ContainerNode.cpp
===================================================================
--- Source/WebCore/dom/ContainerNode.cpp (revision 86864)
+++ Source/WebCore/dom/ContainerNode.cpp (working copy)
@@ -534,21 +534,31 @@
m_firstChild = next;
if (n == m_lastChild)
m_lastChild = 0;
+ removedChildren.append(n.release());
+ }
- if (n->attached())
- n->detach();
+ size_t removedChildrenCount = removedChildren.size();
+ size_t i;
- removedChildren.append(n.release());
+ // Detach the nodes only after properly removed from the tree because
+ // a. detaching requires a proper DOM tree (for counters and quotes for
+ // example) and during the previous loop the next sibling still points to
+ // the node being removed while the node being removed does not point back
+ // and does not point to the same parent as its next sibling.
+ // b. destroying Renderers of standalone nodes is sometimes faster.
+ for (i = 0; i < removedChildrenCount; ++i) {
+ Node* removedChild = removedChildren[i].get();
+ if (removedChild->attached())
+ removedChild->detach();
}
+
allowEventDispatch();
- size_t removedChildrenCount = removedChildren.size();
-
// Dispatch a single post-removal mutation event denoting a modified subtree.
childrenChanged(false, 0, 0, -static_cast<int>(removedChildrenCount));
dispatchSubtreeModifiedEvent();
- for (size_t i = 0; i < removedChildrenCount; ++i) {
+ for (i = 0; i < removedChildrenCount; ++i) {
Node* removedChild = removedChildren[i].get();
if (removedChild->inDocument())
removedChild->removedFromDocument();
« no previous file with comments | « LayoutTests/fast/css/counters/element-removal-crash-expected.txt ('k') | Source/WebCore/rendering/RenderCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698