Commit 67027a94 authored by justing's avatar justing

LayoutTests:

        Reviewed by harrison

        <rdar://problem/5119244> 
        Crash when indenting a selected ToDo
        
        * editing/execCommand/5119244-expected.checksum: Added.
        * editing/execCommand/5119244-expected.png: Added.
        * editing/execCommand/5119244-expected.txt: Added.
        * editing/execCommand/5119244.html: Added.

WebCore:

        Reviewed by harrison

        <rdar://problem/5119244> 
        Crash when indenting a selected ToDo
        
        indentRegion() was using the old (incorrect) editable root 
        getter, which returned null for a valid, editable position, 
        causing the crash.

        * editing/IndentOutdentCommand.cpp:
        (WebCore::IndentOutdentCommand::indentRegion):
        The editable root for a position is editableRootForPosition(p),
        not p.node()->rootEditableElement(), because of VisiblePositions 
        before/after tables, replaced elements and others.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20926 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 889c96c8
2007-04-17 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
<rdar://problem/5119244>
Crash when indenting a selected ToDo
* editing/execCommand/5119244-expected.checksum: Added.
* editing/execCommand/5119244-expected.png: Added.
* editing/execCommand/5119244-expected.txt: Added.
* editing/execCommand/5119244.html: Added.
2007-04-17 Justin Garcia <justin.garcia@apple.com>
Reviewed by hyatt
5b52b459515939b8f29d99d42256174d
\ 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 784x18
RenderText {#text} at (0,0) size 432x18
text run at (0,0) width 432: "This tests for a crash indent a selection that starts just before a ToDo."
RenderText {#text} at (0,0) size 0x0
RenderBlock {DIV} at (0,34) size 784x24
RenderBlock {BLOCKQUOTE} at (40,0) size 744x24
RenderTable {TABLE} at (0,0) size 130x24
RenderTableSection {TBODY} at (0,0) size 130x24
RenderTableRow {TR} at (0,2) size 130x20
RenderTableCell {TD} at (2,2) size 18x20 [r=0 c=0 rs=1 cs=1]
RenderText {#text} at (1,1) size 16x18
text run at (1,1) width 16: "\x{21D2}"
RenderTableCell {TD} at (22,2) size 14x20 [r=0 c=1 rs=1 cs=1]
RenderText {#text} at (1,1) size 12x18
text run at (1,1) width 12: "\x{23B7}"
RenderTableCell {TD} at (38,2) size 90x20 [bgcolor=#FF8811] [r=0 c=2 rs=1 cs=1]
RenderText {#text} at (1,1) size 88x18
text run at (1,1) width 88: "ToDo content"
RenderBlock (anonymous) at (0,24) size 744x0
RenderBlock (anonymous) at (0,24) size 784x0
caret: position 0 of child 0 {TABLE} of child 0 {BLOCKQUOTE} of child 1 {DIV} of child 0 {BODY} of child 0 {HTML} of document
<p>This tests for a crash indent a selection that starts just before a ToDo.</div>
<div id="div" contenteditable="true"><table contenteditable="false"><tr><td>&#x21D2;</td><td>&#x23B7;</td><td contenteditable="true" style="background-color: #f81;">ToDo content</td></tr></table></div>
<script>
var sel = window.getSelection();
var div = document.getElementById("div");
sel.setPosition(div, 0);
document.execCommand("Indent");
</script>
2007-04-17 Justin Garcia <justin.garcia@apple.com>
Reviewed by harrison
<rdar://problem/5119244>
Crash when indenting a selected ToDo
indentRegion() was using the old (incorrect) editable root
getter, which returned null for a valid, editable position,
causing the crash.
* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::indentRegion):
The editable root for a position is editableRootForPosition(p),
not p.node()->rootEditableElement(), because of VisiblePositions
before/after tables, replaced elements and others.
2007-04-17 Justin Garcia <justin.garcia@apple.com>
Reviewed by hyatt
......@@ -141,10 +141,10 @@ void IndentOutdentCommand::indentRegion()
// Special case empty root editable elements because there's nothing to split
// and there's nothing to move.
Node* startNode = startOfSelection.deepEquivalent().downstream().node();
if (startNode == startNode->rootEditableElement()) {
Position start = startOfSelection.deepEquivalent().downstream();
if (start.node() == editableRootForPosition(start)) {
RefPtr<Node> blockquote = createIndentBlockquoteElement(document());
insertNodeAt(blockquote.get(), startNode, 0);
insertNodeAt(blockquote.get(), start.node(), 0);
RefPtr<Node> placeholder = createBreakElement(document());
appendNode(placeholder.get(), blockquote.get());
setEndingSelection(Selection(Position(placeholder.get(), 0), DOWNSTREAM));
......@@ -186,8 +186,8 @@ void IndentOutdentCommand::indentRegion()
// Create a new blockquote and insert it as a child of the root editable element. We accomplish
// this by splitting all parents of the current paragraph up to that point.
RefPtr<Node> blockquote = createIndentBlockquoteElement(document());
Node* startNode = startOfParagraph(endOfCurrentParagraph).deepEquivalent().node();
Node* startOfNewBlock = splitTreeToNode(startNode, startNode->rootEditableElement());
Position start = startOfParagraph(endOfCurrentParagraph).deepEquivalent();
Node* startOfNewBlock = splitTreeToNode(start.node(), editableRootForPosition(start));
insertNodeBefore(blockquote.get(), startOfNewBlock);
newBlockquote = blockquote.get();
insertionPoint = prepareBlockquoteLevelForInsertion(endOfCurrentParagraph, &newBlockquote);
......
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