Title: [129400] trunk
Revision
129400
Author
[email protected]
Date
2012-09-24 13:04:01 -0700 (Mon, 24 Sep 2012)

Log Message

DOM4 remove method
https://bugs.webkit.org/show_bug.cgi?id=73885

Reviewed by Ojan Vafai.

This adds the DOM 4 remove method.

http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-childnode-remove

The remove method removes the node from its parent if it has a parent.

Source/WebCore:

Tests: fast/dom/Comment/remove.html
       fast/dom/DocumentType/remove.html
       fast/dom/Element/remove.html
       fast/dom/Text/remove.html

* dom/CharacterData.idl:
* dom/DocumentType.idl:
* dom/Element.idl:
* dom/Node.cpp:
(WebCore::Node::remove): The spec says to do nothing if the node has no parent.
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTagForInBody): Cleanup.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::removeDisplayTree): No need to check parenNode twice.

LayoutTests:

* fast/dom/Comment/remove-expected.txt: Added.
* fast/dom/Comment/remove.html: Added.
* fast/dom/DocumentType/remove-expected.txt: Added.
* fast/dom/DocumentType/remove.html: Added.
* fast/dom/Element/remove-expected.txt: Added.
* fast/dom/Element/remove.html: Added.
* fast/dom/Text/remove-expected.txt: Added.
* fast/dom/Text/remove.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (129399 => 129400)


--- trunk/LayoutTests/ChangeLog	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/LayoutTests/ChangeLog	2012-09-24 20:04:01 UTC (rev 129400)
@@ -1,3 +1,25 @@
+2012-09-24  Erik Arvidsson  <[email protected]>
+
+        DOM4 remove method
+        https://bugs.webkit.org/show_bug.cgi?id=73885
+
+        Reviewed by Ojan Vafai.
+
+        This adds the DOM 4 remove method.
+        
+        http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-childnode-remove
+        
+        The remove method removes the node from its parent if it has a parent.
+
+        * fast/dom/Comment/remove-expected.txt: Added.
+        * fast/dom/Comment/remove.html: Added.
+        * fast/dom/DocumentType/remove-expected.txt: Added.
+        * fast/dom/DocumentType/remove.html: Added.
+        * fast/dom/Element/remove-expected.txt: Added.
+        * fast/dom/Element/remove.html: Added.
+        * fast/dom/Text/remove-expected.txt: Added.
+        * fast/dom/Text/remove.html: Added.
+
 2012-09-24  Roger Fong  <[email protected]>
 
         Unreviewed. Removing Windows specific results for fast/text/international/float-as-only-child-of-isolate-crash that were added in https://bugs.webkit.org/show_bug.cgi?id=87998.

Added: trunk/LayoutTests/fast/dom/Comment/remove-expected.txt (0 => 129400)


--- trunk/LayoutTests/fast/dom/Comment/remove-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Comment/remove-expected.txt	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,12 @@
+This tests the DOM 4 remove method on a Comment.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testDiv.childNodes.length is 1
+PASS testDiv.childNodes.length is 0
+PASS testDiv.childNodes.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Comment/remove.html (0 => 129400)


--- trunk/LayoutTests/fast/dom/Comment/remove.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Comment/remove.html	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src=""
+<div id="test"></div>
+<script>
+
+description('This tests the DOM 4 remove method on a Comment.');
+
+var testDiv = document.getElementById('test');
+var comment = document.createComment('Comment');
+testDiv.appendChild(comment);
+shouldBe('testDiv.childNodes.length', '1');
+comment.remove();
+shouldBe('testDiv.childNodes.length', '0');
+comment.remove();
+shouldBe('testDiv.childNodes.length', '0');
+
+</script>
+<script src=""

Added: trunk/LayoutTests/fast/dom/DocumentType/remove-expected.txt (0 => 129400)


--- trunk/LayoutTests/fast/dom/DocumentType/remove-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/DocumentType/remove-expected.txt	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,12 @@
+This tests the DOM 4 remove method on a DocumentType node.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.childNodes.length is 2
+PASS document.childNodes.length is 1
+PASS document.childNodes.length is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/DocumentType/remove.html (0 => 129400)


--- trunk/LayoutTests/fast/dom/DocumentType/remove.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/DocumentType/remove.html	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<script src=""
+<script>
+
+description('This tests the DOM 4 remove method on a DocumentType node.');
+
+var doctype = document.doctype;
+shouldBe('document.childNodes.length', '2');
+doctype.remove();
+shouldBe('document.childNodes.length', '1');
+doctype.remove();
+shouldBe('document.childNodes.length', '1');
+
+</script>
+<script src=""

Added: trunk/LayoutTests/fast/dom/Element/remove-expected.txt (0 => 129400)


--- trunk/LayoutTests/fast/dom/Element/remove-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/remove-expected.txt	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,12 @@
+This tests the DOM 4 remove method on an Element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testDiv.childNodes.length is 1
+PASS testDiv.childNodes.length is 0
+PASS testDiv.childNodes.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Element/remove.html (0 => 129400)


--- trunk/LayoutTests/fast/dom/Element/remove.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Element/remove.html	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src=""
+<div id="test"></div>
+<script>
+
+description('This tests the DOM 4 remove method on an Element.');
+
+var testDiv = document.getElementById('test');
+var a = document.createElement('a');
+testDiv.appendChild(a);
+shouldBe('testDiv.childNodes.length', '1');
+a.remove();
+shouldBe('testDiv.childNodes.length', '0');
+a.remove();
+shouldBe('testDiv.childNodes.length', '0');
+
+</script>
+<script src=""

Added: trunk/LayoutTests/fast/dom/Text/remove-expected.txt (0 => 129400)


--- trunk/LayoutTests/fast/dom/Text/remove-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Text/remove-expected.txt	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,12 @@
+This tests the DOM 4 remove method on a Text node.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testDiv.childNodes.length is 1
+PASS testDiv.childNodes.length is 0
+PASS testDiv.childNodes.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Text/remove.html (0 => 129400)


--- trunk/LayoutTests/fast/dom/Text/remove.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Text/remove.html	2012-09-24 20:04:01 UTC (rev 129400)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<script src=""
+<div id="test"></div>
+<script>
+
+description('This tests the DOM 4 remove method on a Text node.');
+
+var testDiv = document.getElementById('test');
+var text = document.createTextNode('text');
+testDiv.appendChild(text);
+shouldBe('testDiv.childNodes.length', '1');
+text.remove();
+shouldBe('testDiv.childNodes.length', '0');
+text.remove();
+shouldBe('testDiv.childNodes.length', '0');
+
+</script>
+<script src=""

Modified: trunk/Source/WebCore/ChangeLog (129399 => 129400)


--- trunk/Source/WebCore/ChangeLog	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/ChangeLog	2012-09-24 20:04:01 UTC (rev 129400)
@@ -1,3 +1,31 @@
+2012-09-24  Erik Arvidsson  <[email protected]>
+
+        DOM4 remove method
+        https://bugs.webkit.org/show_bug.cgi?id=73885
+
+        Reviewed by Ojan Vafai.
+
+        This adds the DOM 4 remove method.
+        
+        http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-childnode-remove
+        
+        The remove method removes the node from its parent if it has a parent.
+
+        Tests: fast/dom/Comment/remove.html
+               fast/dom/DocumentType/remove.html
+               fast/dom/Element/remove.html
+               fast/dom/Text/remove.html
+
+        * dom/CharacterData.idl:
+        * dom/DocumentType.idl:
+        * dom/Element.idl:
+        * dom/Node.cpp:
+        (WebCore::Node::remove): The spec says to do nothing if the node has no parent.
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody): Cleanup.
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::removeDisplayTree): No need to check parenNode twice.
+
 2012-09-24  Tommy Widenflycht  <[email protected]>
 
         MediaStream API: Fix the incorrectly spelled RTCPeerConnection::onnegotiationneeded callback

Modified: trunk/Source/WebCore/dom/CharacterData.idl (129399 => 129400)


--- trunk/Source/WebCore/dom/CharacterData.idl	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/dom/CharacterData.idl	2012-09-24 20:04:01 UTC (rev 129400)
@@ -45,7 +45,10 @@
                                         in [IsIndex,Optional=DefaultIsUndefined] unsigned long length,
                                         in [Optional=DefaultIsUndefined] DOMString data)
             raises(DOMException);
-    
+
+        // DOM 4
+        void remove()
+            raises(DOMException);
     };
 
 }

Modified: trunk/Source/WebCore/dom/DocumentType.idl (129399 => 129400)


--- trunk/Source/WebCore/dom/DocumentType.idl	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/dom/DocumentType.idl	2012-09-24 20:04:01 UTC (rev 129400)
@@ -35,6 +35,9 @@
         readonly attribute [TreatReturnedNullStringAs=Null] DOMString systemId;
         readonly attribute [TreatReturnedNullStringAs=Null] DOMString internalSubset;        
 
+        // DOM 4
+        void remove()
+            raises(DOMException);
     };
 
 }

Modified: trunk/Source/WebCore/dom/Element.idl (129399 => 129400)


--- trunk/Source/WebCore/dom/Element.idl	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/dom/Element.idl	2012-09-24 20:04:01 UTC (rev 129400)
@@ -120,6 +120,10 @@
         readonly attribute Element nextElementSibling;
         readonly attribute unsigned long childElementCount;
 
+        // DOM 4
+        void remove()
+            raises(DOMException);
+
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
         // CSSOM View Module API
         ClientRectList getClientRects();

Modified: trunk/Source/WebCore/dom/Node.cpp (129399 => 129400)


--- trunk/Source/WebCore/dom/Node.cpp	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/dom/Node.cpp	2012-09-24 20:04:01 UTC (rev 129400)
@@ -630,8 +630,6 @@
 {
     if (ContainerNode* parent = parentNode())
         parent->removeChild(this, ec);
-    else
-        ec = HIERARCHY_REQUEST_ERR;
 }
 
 void Node::normalize()

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (129399 => 129400)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2012-09-24 20:04:01 UTC (rev 129400)
@@ -686,9 +686,7 @@
         }
         if (!m_framesetOk)
             return;
-        ExceptionCode ec = 0;
-        m_tree.openElements()->bodyElement()->remove(ec);
-        ASSERT(!ec);
+        m_tree.openElements()->bodyElement()->remove(ASSERT_NO_EXCEPTION);
         m_tree.openElements()->popUntil(m_tree.openElements()->bodyElement());
         m_tree.openElements()->popHTMLBodyElement();
         ASSERT(m_tree.openElements()->top() == m_tree.openElements()->htmlElement());

Modified: trunk/Source/WebCore/html/track/TextTrackCue.cpp (129399 => 129400)


--- trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-09-24 19:53:40 UTC (rev 129399)
+++ trunk/Source/WebCore/html/track/TextTrackCue.cpp	2012-09-24 20:04:01 UTC (rev 129400)
@@ -742,8 +742,7 @@
 
 void TextTrackCue::removeDisplayTree()
 {
-    if (m_displayTree->parentNode())
-        m_displayTree->remove(ASSERT_NO_EXCEPTION);
+    m_displayTree->remove(ASSERT_NO_EXCEPTION);
 }
 
 std::pair<double, double> TextTrackCue::getPositionCoordinates() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to