Commit bce8c795 authored by justing's avatar justing

LayoutTests:

        Reviewed by darin

        <rdar://problem/4920488>
        REGRESSION: A crash occurs at WebCore::Range::processContents () when removing formatting from selected text (that contains a link)

        * editing/execCommand/4920488-expected.checksum: Added.
        * editing/execCommand/4920488-expected.png: Added.
        * editing/execCommand/4920488-expected.txt: Added.
        * editing/execCommand/4920488.html: Added.
        * fast/dom/Range/compareBoundaryPoints-1-expected.txt: Added.
        * fast/dom/Range/compareBoundaryPoints-1.html: Added.

WebCore:

        Reviewed by darin
        
        <rdar://problem/4920488>
        REGRESSION: A crash occurs at WebCore::Range::processContents () when removing formatting from selected text (that contains a link)

        * dom/Range.cpp:
        (WebCore::Range::commonAncestorContainer): Return null if the nodes
        don't have a common ancestor.  As a side effect, the public 
        commonAncestorContainer now sets an exception if the Range starts
        in one document and ends in another, or starts or ends in a tree
        that's been removed from the document.  The spec doesn't cover
        this and there is no precedent in other browsers for this case because
        they don't allow invalid Ranges (you can create one with WebCore
        by removing a node that contains the start/end of a Range).
        (WebCore::Range::compareBoundaryPoints): If the the two positions
        are in nodes that have no common ancestor, return null.  This doesn't
        change the behavior of the public compareBoundaryPoints: it already
        throws an exception if the two positions are in nodes that don't have
        a common ancestor.  This follows the spec.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@18924 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b83d025a
2007-01-17 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
<rdar://problem/4920488>
REGRESSION: A crash occurs at WebCore::Range::processContents () when removing formatting from selected text (that contains a link)
* editing/execCommand/4920488-expected.checksum: Added.
* editing/execCommand/4920488-expected.png: Added.
* editing/execCommand/4920488-expected.txt: Added.
* editing/execCommand/4920488.html: Added.
* fast/dom/Range/compareBoundaryPoints-1-expected.txt: Added.
* fast/dom/Range/compareBoundaryPoints-1.html: Added.
2007-01-17 Eric Seidel <eric@webkit.org>
Reviewed by Brady.
ce64c3b7059dab375961686ca2aa0956
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 769x36
text run at (0,0) width 769: "This tests for a bug in GMail's Editor, they try to extract the contents of a range that has had it's contents removed from the"
text run at (0,18) width 222: "document by an editing command. "
text run at (222,18) width 265: "You should see 'dogfood' unstyled below."
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 53x18
text run at (0,0) width 53: "dogfood"
caret: position 7 of child 0 {#text} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<p>This tests for a bug in GMail's Editor, they try to extract the contents of a range that has had it's contents removed from the document by an editing command. You should see 'dogfood' unstyled below.</p>
<div id="div" contenteditable="true">dog<a href="http://www.google.com/">food</a></div>
<script>
var div = document.getElementById("div");
var text = div.firstChild;
var link = div.lastChild;
div.focus();
var r = document.createRange();
r.setStart(text, 0);
r.setEnd(link, link.childNodes.length);
document.execCommand("SelectAll");
document.execCommand("RemoveFormat");
r.extractContents();
</script>
This tests to see that Range::compareBoundaryPoints throws a WRONG_DOCUMENT_ERROR exception if the two ranges are in different documents, or if one is detached.
food
<p>This tests to see that Range::compareBoundaryPoints throws a WRONG_DOCUMENT_ERROR exception if the two ranges are in different documents, or if one is detached.</p>
<div id="div" contenteditable="true">dog<a href="http://www.google.com/">food</a></div>
<ul id="console"></ul>
<script>
function log(str) {
var console = document.getElementById("console");
var li = document.createElement("li");
li.appendChild(document.createTextNode(str));
console.appendChild(li);
}
if (window.layoutTestController)
window.layoutTestController.dumpAsText();
var div = document.getElementById("div");
var text = div.firstChild;
var link = div.lastChild;
div.focus();
text.parentNode.removeChild(text);
var r1 = document.createRange();
r1.setStart(link, 0);
r1.setEnd(link, 0);
var r2 = document.createRange();
r2.setStart(text, 0);
r2.setEnd(text, 0);
try {
var compare = r1.compareBoundaryPoints(Range.START_TO_START, r2);
log("Error. compareBoundaryPoints should have thrown an exception.");
} catch (e) {
var expected = "Error: WRONG_DOCUMENT_ERR: DOM Exception 4";
if (e != expected)
log("Error. Exception thrown should have been: " + expected);
}
</script>
2007-01-17 Justin Garcia <justin.garcia@apple.com>
Reviewed by darin
<rdar://problem/4920488>
REGRESSION: A crash occurs at WebCore::Range::processContents () when removing formatting from selected text (that contains a link)
* dom/Range.cpp:
(WebCore::Range::commonAncestorContainer): Return null if the nodes
don't have a common ancestor. As a side effect, the public
commonAncestorContainer now sets an exception if the Range starts
in one document and ends in another, or starts or ends in a tree
that's been removed from the document. The spec doesn't cover
this and there is no precedent in other browsers for this case because
they don't allow invalid Ranges (you can create one with WebCore
by removing a node that contains the start/end of a Range).
(WebCore::Range::compareBoundaryPoints): If the the two positions
are in nodes that have no common ancestor, return null. This doesn't
change the behavior of the public compareBoundaryPoints: it already
throws an exception if the two positions are in nodes that don't have
a common ancestor. This follows the spec.
2007-01-17 John Sullivan <sullivan@apple.com>
The one word was typed by me, but only after debugging for a long time with Darin.
......
......@@ -156,9 +156,6 @@ Node *Range::commonAncestorContainer(Node *containerA, Node *containerB)
if (parentStart == parentEnd)
break;
}
if (!parentStart)
return containerA->document()->documentElement();
return parentStart;
}
......@@ -506,6 +503,8 @@ short Range::compareBoundaryPoints( Node *containerA, int offsetA, Node *contain
// case 4: containers A & B are siblings, or children of siblings
// ### we need to do a traversal here instead
Node *cmnRoot = commonAncestorContainer(containerA,containerB);
if (!cmnRoot)
return 0;
Node *childA = containerA;
while (childA && childA->parentNode() != cmnRoot)
childA = childA->parentNode();
......
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