Commit 8b0430f0 authored by arv@chromium.org's avatar arv@chromium.org
Browse files

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129400 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5693f3c5
2012-09-24 Erik Arvidsson <arv@chromium.org>
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 <roger_fong@apple.com>
 
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.
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
<!DOCTYPE html>
<script src="../../js/resources/js-test-pre.js"></script>
<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="../../js/resources/js-test-post.js"></script>
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
<!DOCTYPE html>
<script src="../../js/resources/js-test-pre.js"></script>
<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="../../js/resources/js-test-post.js"></script>
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
<!DOCTYPE html>
<script src="../../js/resources/js-test-pre.js"></script>
<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="../../js/resources/js-test-post.js"></script>
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
<!DOCTYPE html>
<script src="../../js/resources/js-test-pre.js"></script>
<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="../../js/resources/js-test-post.js"></script>
2012-09-24 Erik Arvidsson <arv@chromium.org>
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 <tommyw@google.com>
 
MediaStream API: Fix the incorrectly spelled RTCPeerConnection::onnegotiationneeded callback
......@@ -45,7 +45,10 @@ module core {
in [IsIndex,Optional=DefaultIsUndefined] unsigned long length,
in [Optional=DefaultIsUndefined] DOMString data)
raises(DOMException);
// DOM 4
void remove()
raises(DOMException);
};
}
......@@ -35,6 +35,9 @@ module core {
readonly attribute [TreatReturnedNullStringAs=Null] DOMString systemId;
readonly attribute [TreatReturnedNullStringAs=Null] DOMString internalSubset;
// DOM 4
void remove()
raises(DOMException);
};
}
......@@ -120,6 +120,10 @@ module core {
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();
......
......@@ -630,8 +630,6 @@ void Node::remove(ExceptionCode& ec)
{
if (ContainerNode* parent = parentNode())
parent->removeChild(this, ec);
else
ec = HIERARCHY_REQUEST_ERR;
}
void Node::normalize()
......
......@@ -686,9 +686,7 @@ void HTMLTreeBuilder::processStartTagForInBody(AtomicHTMLToken* token)
}
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());
......
......@@ -742,8 +742,7 @@ PassRefPtr<TextTrackCueBox> TextTrackCue::getDisplayTree()
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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment