LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2006 21:59:43 +0000 (21:59 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Sep 2006 21:59:43 +0000 (21:59 +0000)
        Reviewed by john

        * editing/execCommand/indent-empty-root-expected.checksum: Added.
        * editing/execCommand/indent-empty-root-expected.png: Added.
        * editing/execCommand/indent-empty-root-expected.txt: Added.
        * editing/execCommand/indent-empty-root.html: Added.

WebCore:

        Reviewed by john

        <http://bugzilla.opendarwin.org/show_bug.cgi?id=11002>
        Gmail Editor: Crash at WebCore::SplitElementCommand::doApply() when attempting to indent in a new message

        * editing/IndentOutdentCommand.cpp:
        (WebCore::IndentOutdentCommand::indentRegion): Special case
        an empty root editable element.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16563 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/indent-empty-root-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-empty-root-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-empty-root-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/indent-empty-root.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/IndentOutdentCommand.cpp

index 9d42fe739cba45ce617b8b051e05ef3036e6cf5f..eda76c463cb37f81e4040698019d3ff30c6ac5de 100644 (file)
@@ -1,3 +1,12 @@
+2006-09-25  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+
+        * editing/execCommand/indent-empty-root-expected.checksum: Added.
+        * editing/execCommand/indent-empty-root-expected.png: Added.
+        * editing/execCommand/indent-empty-root-expected.txt: Added.
+        * editing/execCommand/indent-empty-root.html: Added.
+
 2006-09-24  Eric Seidel  <eric@eseidel.com>
 
         Reviewed by mjs.
diff --git a/LayoutTests/editing/execCommand/indent-empty-root-expected.checksum b/LayoutTests/editing/execCommand/indent-empty-root-expected.checksum
new file mode 100644 (file)
index 0000000..395bc01
--- /dev/null
@@ -0,0 +1 @@
+3163e8bd957297fceddf64a8046905ea
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/indent-empty-root-expected.png b/LayoutTests/editing/execCommand/indent-empty-root-expected.png
new file mode 100644 (file)
index 0000000..d8b5f7f
Binary files /dev/null and b/LayoutTests/editing/execCommand/indent-empty-root-expected.png differ
diff --git a/LayoutTests/editing/execCommand/indent-empty-root-expected.txt b/LayoutTests/editing/execCommand/indent-empty-root-expected.txt
new file mode 100644 (file)
index 0000000..ad8c0a9
--- /dev/null
@@ -0,0 +1,18 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of BLOCKQUOTE > DIV > BODY > HTML > #document to 0 of BLOCKQUOTE > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+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 784x576
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 291x18
+          text run at (0,0) width 291: "This tests Indent in an empty editable element."
+      RenderBlock {DIV} at (0,34) size 784x18
+        RenderBlock {BLOCKQUOTE} at (40,0) size 704x18
+          RenderBR {BR} at (0,0) size 0x18
+caret: position 0 of child 0 {BR} of child 0 {BLOCKQUOTE} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/indent-empty-root.html b/LayoutTests/editing/execCommand/indent-empty-root.html
new file mode 100644 (file)
index 0000000..98efedf
--- /dev/null
@@ -0,0 +1,11 @@
+<body>
+<p>This tests Indent in an empty editable element.</p>
+<div id="div" contentEditable="true"></div>
+
+<script>
+var div = document.getElementById("div");
+var sel = window.getSelection();
+sel.setPosition(div, 0);
+document.execCommand("Indent");
+</script>
+</body>
\ No newline at end of file
index 9f254451f39d57672fc8500dff116957d6ae5892..24a27b9be5eae32ab3016bffe9f31dde51e9fce6 100644 (file)
@@ -1,3 +1,14 @@
+2006-09-25  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <http://bugzilla.opendarwin.org/show_bug.cgi?id=11002>
+        Gmail Editor: Crash at WebCore::SplitElementCommand::doApply() when attempting to indent in a new message
+        
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::indentRegion): Special case
+        an empty root editable element.
+
 2006-09-25  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Steve
index b0e3cab9c591d1f76e958fec19a9cf8f76156a2c..00aacf25ecc8f82bd55d01c08291871e3aa5982b 100644 (file)
@@ -112,6 +112,18 @@ void IndentOutdentCommand::indentRegion()
     ASSERT(!startOfSelection.isNull());
     ASSERT(!endOfSelection.isNull());
     
+    // 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()) {
+        RefPtr<Node> blockquote = createElement(document(), "blockquote");
+        insertNodeAt(blockquote.get(), startNode, 0);
+        RefPtr<Node> placeholder = createBreakElement(document());
+        appendNode(placeholder.get(), blockquote.get());
+        setEndingSelection(Selection(Position(placeholder.get(), 0), DOWNSTREAM));
+        return;
+    }
+    
     Node* previousListNode = 0;
     Node* newListNode = 0;
     Node* newBlockquote = 0;