Simplify ContainerNode::removeChildren
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2013 18:44:40 +0000 (18:44 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Apr 2013 18:44:40 +0000 (18:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=115398

Reviewed by Andreas Kling.

Back port https://chromium.googlesource.com/chromium/blink/+/b981f01cd065236b5ff7e3a8446d15b384c1b557
by Andrei Bucur, which includes both this and his r148754.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeChildren):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@149386 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/ContainerNode.cpp

index da298bfb3b100e9a366971579ba8e19cfe1bf656..f0f89f37bafa970ffc1917de870d0c194ff33ff6 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-30  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Simplify ContainerNode::removeChildren
+        https://bugs.webkit.org/show_bug.cgi?id=115398
+
+        Reviewed by Andreas Kling.
+
+        Back port https://chromium.googlesource.com/chromium/blink/+/b981f01cd065236b5ff7e3a8446d15b384c1b557
+        by Andrei Bucur, which includes both this and his r148754.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::removeChildren):
+
 2013-04-30  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [SOUP] Move default buffer handling from ResourceHandleClient to ResourceHandlesoup
index a0be88aa5b37e7ec4e31f6fc3e67d8bec00bbf01..60e2f11fcf59666fb6f9a93654fd7c52f707d3ec 100644 (file)
@@ -607,30 +607,15 @@ void ContainerNode::removeChildren()
     // and remove... e.g. stop loading frames, fire unload events.
     willRemoveChildren(protect.get());
 
-    Vector<RefPtr<Node>, 10> removedChildren;
+    NodeVector removedChildren;
     {
         WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
         {
             NoEventDispatchAssertion assertNoEventDispatch;
             removedChildren.reserveInitialCapacity(childNodeCount());
             while (RefPtr<Node> n = m_firstChild) {
-                Node* next = n->nextSibling();
-
-                if (n->attached())
-                    n->detach();
-
-                n->setPreviousSibling(0);
-                n->setNextSibling(0);
-                n->setParentOrShadowHostNode(0);
-                document()->adoptIfNeeded(n.get());
-
-                m_firstChild = next;
-                if (n == m_lastChild)
-                    m_lastChild = 0;
-                else
-                    m_firstChild->setPreviousSibling(0);
-
-                removedChildren.append(n.release());
+                removedChildren.append(m_firstChild);
+                removeBetween(0, m_firstChild->nextSibling(), m_firstChild);
             }
         }