summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom/ContainerNode.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-06-10 16:52:27 +0100
committerSteve Block <steveblock@google.com>2011-06-14 01:14:02 +0100
commit54cdeeebc7adcbcd900e8b6a141a8cae27d9a631 (patch)
tree845b0d338b204a48560eca3b51b34cf92ed96840 /Source/WebCore/dom/ContainerNode.cpp
parentd2c5226a647dc21d0c15267e09a3d19cf3e0d593 (diff)
downloadexternal_webkit-54cdeeebc7adcbcd900e8b6a141a8cae27d9a631.zip
external_webkit-54cdeeebc7adcbcd900e8b6a141a8cae27d9a631.tar.gz
external_webkit-54cdeeebc7adcbcd900e8b6a141a8cae27d9a631.tar.bz2
Merge WebKit at branches/chromium/742 r88085: Initial merge by git.
Change-Id: I0501b484b9528e31b0026e5ad64416dd6541cdde
Diffstat (limited to 'Source/WebCore/dom/ContainerNode.cpp')
-rw-r--r--Source/WebCore/dom/ContainerNode.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/Source/WebCore/dom/ContainerNode.cpp b/Source/WebCore/dom/ContainerNode.cpp
index 276df56..2d22fa9 100644
--- a/Source/WebCore/dom/ContainerNode.cpp
+++ b/Source/WebCore/dom/ContainerNode.cpp
@@ -534,21 +534,31 @@ void ContainerNode::removeChildren()
m_firstChild = next;
if (n == m_lastChild)
m_lastChild = 0;
-
- if (n->attached())
- n->detach();
-
removedChildren.append(n.release());
}
- allowEventDispatch();
size_t removedChildrenCount = removedChildren.size();
+ size_t i;
+
+ // 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();
// 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();