Commit b5301fbd authored by ap@webkit.org's avatar ap@webkit.org
Browse files

Reviewed by Darin Adler.

        https://bugs.webkit.org/show_bug.cgi?id=24122
        <rdar://problem/6674179>
        REGRESSION: DOM Range extractContents/deleteContents failures seen on Moxiecode tests

        Test: fast/dom/Range/deleted-range-endpoints.html

        * dom/Range.cpp: (WebCore::Range::processContents): Set the final range in accordance
        to the specification.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41855 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a11aa404
2009-03-19 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=24122
<rdar://problem/6674179>
REGRESSION: DOM Range extractContents/deleteContents failures seen on Moxiecode tests
* fast/dom/Range/deleted-range-endpoints-expected.txt: Added.
* fast/dom/Range/deleted-range-endpoints.html: Added.
2009-03-19 Geoffrey Garen <ggaren@apple.com>
 
Reviewed by Cameron Zwarich and Oliver Hunt.
......
Test some cases of Range.deleteContents() behavior (namely, examples from DOM Range spec).
<FOO> [A, CD]. Final range (FOO, 1) - (FOO, 1)
<FOO> [A, <MOO> [B], E]. Final range (FOO, 2) - (FOO, 2)
<FOO> [X, <BAR> [W], Q]. Final range (FOO, 1) - (FOO, 1)
<FOO> [<BAR1> [A], <BAR3> [D]]. Final range (FOO, 1) - (FOO, 1)
<p>Test some cases of Range.deleteContents() behavior (namely, examples from DOM Range spec).</p>
<pre id="console"></pre>
<div style="visibility:hidden">
<FOO>AB<MOO>CD</MOO>CD</FOO>
<FOO>A<MOO>BC</MOO>DE</FOO>
<FOO>XY<BAR>ZW</BAR>Q</FOO>
<FOO><BAR1>AB</BAR1><BAR2></BAR2><BAR3>CD</BAR3></FOO>
</div>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
function log(message)
{
document.getElementById('console').appendChild(document.createTextNode(message + '\n'));
}
// Simple recursive "give me a string to represent this tree" function
function treeAsString(node) {
var string = node.nodeName;
if (string[0] != "#")
string = "<" + string + ">";
if (string == "#text")
string = node.textContent;
if (node.childNodes.length) {
string += " [";
}
for (var x = 0; x < node.childNodes.length; x++) {
if (x != 0) {
string += ", ";
}
string += treeAsString(node.childNodes[x]);
}
if (node.childNodes.length) {
string += "]";
}
return string;
}
var range = document.createRange();
var foo = document.getElementsByTagName("FOO")[0];
range.setStart(foo.firstChild, 1);
range.setEnd(foo, 2);
range.deleteContents();
log(treeAsString(foo) + ". Final range (" + range.startContainer.nodeName + ", " + range.startOffset + ") - (" + range.endContainer.nodeName + ", " + range.endOffset + ")");
var foo = document.getElementsByTagName("FOO")[1];
range.setStart(foo.firstChild.nextSibling.firstChild, 1);
range.setEnd(foo.lastChild, 1);
range.deleteContents();
log(treeAsString(foo) + ". Final range (" + range.startContainer.nodeName + ", " + range.startOffset + ") - (" + range.endContainer.nodeName + ", " + range.endOffset + ")");
var foo = document.getElementsByTagName("FOO")[2];
range.setStart(foo.firstChild, 1);
range.setEnd(foo.firstChild.nextSibling.firstChild, 1);
range.deleteContents();
log(treeAsString(foo) + ". Final range (" + range.startContainer.nodeName + ", " + range.startOffset + ") - (" + range.endContainer.nodeName + ", " + range.endOffset + ")");
var foo = document.getElementsByTagName("FOO")[3];
range.setStart(foo.firstChild.firstChild, 1);
range.setEnd(foo.lastChild.firstChild, 1);
range.deleteContents();
log(treeAsString(foo) + ". Final range (" + range.startContainer.nodeName + ", " + range.startOffset + ") - (" + range.endContainer.nodeName + ", " + range.endOffset + ")");
</script>
2009-03-19 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=24122
<rdar://problem/6674179>
REGRESSION: DOM Range extractContents/deleteContents failures seen on Moxiecode tests
Test: fast/dom/Range/deleted-range-endpoints.html
* dom/Range.cpp: (WebCore::Range::processContents): Set the final range in accordance
to the specification.
2009-03-19 Anders Carlsson <andersca@apple.com>
 
Reviewed by Dan Bernstein.
......@@ -840,6 +840,17 @@ PassRefPtr<DocumentFragment> Range::processContents(ActionType action, Exception
processEnd = processEnd->parentNode();
}
// Collapse the range, making sure that the result is not within a node that was partially selected.
if (action == EXTRACT_CONTENTS || action == DELETE_CONTENTS) {
if (partialStart)
setStart(partialStart->parentNode(), partialStart->nodeIndex() + 1, ec);
else if (partialEnd)
setStart(partialEnd->parentNode(), partialEnd->nodeIndex(), ec);
if (ec)
return 0;
m_end = m_start;
}
// Now add leftContents, stuff in between, and rightContents to the fragment
// (or just delete the stuff in between)
......
Markdown is supported
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