Title: [136584] trunk/Source/WebCore
Revision
136584
Author
[email protected]
Date
2012-12-04 15:04:04 -0800 (Tue, 04 Dec 2012)

Log Message

parser* methods in ContainerNode should not support DocumentFragment
https://bugs.webkit.org/show_bug.cgi?id=103965

Patch by Elliott Sprehn <[email protected]> on 2012-12-04
Reviewed by Darin Adler.

Only parserInsertBefore ever supported DocumentFragment and this feature
is never used. It appears this code ended up in parserInsertBefore when
it was created as a copy of insertBefore that didn't fire events. This
patch removes that code and adds assertions that we never pass
DocumentFragments since doing so would cause a corrupted tree as we never
check checkAcceptChild or do other validation in the parser methods.

No new tests, just refactoring.

* dom/ContainerNode.cpp:
(WebCore::ContainerNode::parserInsertBefore):
(WebCore::ContainerNode::parserRemoveChild):
(WebCore::ContainerNode::parserAppendChild):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (136583 => 136584)


--- trunk/Source/WebCore/ChangeLog	2012-12-04 23:01:32 UTC (rev 136583)
+++ trunk/Source/WebCore/ChangeLog	2012-12-04 23:04:04 UTC (rev 136584)
@@ -1,3 +1,24 @@
+2012-12-04  Elliott Sprehn  <[email protected]>
+
+        parser* methods in ContainerNode should not support DocumentFragment
+        https://bugs.webkit.org/show_bug.cgi?id=103965
+
+        Reviewed by Darin Adler.
+
+        Only parserInsertBefore ever supported DocumentFragment and this feature
+        is never used. It appears this code ended up in parserInsertBefore when
+        it was created as a copy of insertBefore that didn't fire events. This
+        patch removes that code and adds assertions that we never pass
+        DocumentFragments since doing so would cause a corrupted tree as we never
+        check checkAcceptChild or do other validation in the parser methods.
+
+        No new tests, just refactoring.
+
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::parserInsertBefore):
+        (WebCore::ContainerNode::parserRemoveChild):
+        (WebCore::ContainerNode::parserAppendChild):
+
 2012-12-04  Elliott Sprehn  <[email protected]>
 
         Simplify ShadowRoot::cloneNode(bool,ExceptionCode)

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (136583 => 136584)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2012-12-04 23:01:32 UTC (rev 136583)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2012-12-04 23:04:04 UTC (rev 136584)
@@ -76,15 +76,6 @@
 unsigned NoEventDispatchAssertion::s_count = 0;
 #endif
 
-static void collectTargetNodes(Node* node, NodeVector& nodes)
-{
-    if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
-        nodes.append(node);
-        return;
-    }
-    getChildNodes(node, nodes);
-}
-
 static void collectChildrenAndRemoveFromOldParent(Node* node, NodeVector& nodes, ExceptionCode& ec)
 {
     if (node->nodeType() != Node::DOCUMENT_FRAGMENT_NODE) {
@@ -311,25 +302,15 @@
     ASSERT(nextChild);
     ASSERT(nextChild->parentNode() == this);
     ASSERT(document() == newChild->document());
+    ASSERT(!newChild->isDocumentFragment());
 
-    NodeVector targets;
-    collectTargetNodes(newChild.get(), targets);
-    if (targets.isEmpty())
-        return;
-
     if (nextChild->previousSibling() == newChild || nextChild == newChild) // nothing to do
         return;
 
-    RefPtr<Node> next = nextChild;
-    RefPtr<Node> nextChildPreviousSibling = nextChild->previousSibling();
-    for (NodeVector::const_iterator it = targets.begin(); it != targets.end(); ++it) {
-        Node* child = it->get();
+    insertBeforeCommon(nextChild, newChild.get());
 
-        insertBeforeCommon(next.get(), child);
-
-        childrenChanged(true, nextChildPreviousSibling.get(), nextChild, 1);
-        ChildNodeInsertionNotifier(this).notify(child);
-    }
+    childrenChanged(true, newChild->previousSibling(), nextChild, 1);
+    ChildNodeInsertionNotifier(this).notify(newChild.get());
 }
 
 bool ContainerNode::replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& ec, bool shouldLazyAttach)
@@ -555,6 +536,7 @@
 {
     ASSERT(oldChild);
     ASSERT(oldChild->parentNode() == this);
+    ASSERT(!oldChild->isDocumentFragment());
 
     Node* prev = oldChild->previousSibling();
     Node* next = oldChild->nextSibling();
@@ -696,6 +678,7 @@
 {
     ASSERT(newChild);
     ASSERT(!newChild->parentNode()); // Use appendChild if you need to handle reparenting (and want DOM mutation events).
+    ASSERT(!newChild->isDocumentFragment());
     // FIXME: This assert should be valid, but DOMImplementation::createDocument()
     // blindly calls paserAppendChild on the docType its passed.
     // ASSERT(document() == newChild->document());
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to