LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2006 19:56:27 +0000 (19:56 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2006 19:56:27 +0000 (19:56 +0000)
        Reviewed by john

        <rdar://problem/4747695>
        Gmail Editor: Crash at WebCore::Range::startPosition() when decreasing a indent

        * editing/deleting/list-item-1-expected.checksum: Added.
        * editing/deleting/list-item-1-expected.png: Added.
        * editing/deleting/list-item-1-expected.txt: Added.
        * editing/deleting/list-item-1.html: Added.
        * editing/execCommand/remove-list-item-1-expected.checksum: Added.
        * editing/execCommand/remove-list-item-1-expected.png: Added.
        * editing/execCommand/remove-list-item-1-expected.txt: Added.
        * editing/execCommand/remove-list-item-1.html: Added.

WebCore:

        Reviewed by john

        <rdar://problem/4747695>
        Gmail Editor: Crash at WebCore::Range::startPosition() when decreasing a indent

        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::initializeStartEnd): Stop expanding
        to select special elements that are fully selected after expansion
        moves to positions that are visually distinct from the originals.
        * editing/InsertListCommand.cpp:
        (WebCore::InsertListCommand::doApply): If the content of the list
        item will be moved into another list, put it in a list item.

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

12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/list-item-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/deleting/list-item-1-expected.png [new file with mode: 0644]
LayoutTests/editing/deleting/list-item-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/list-item-1.html [new file with mode: 0644]
LayoutTests/editing/execCommand/remove-list-item-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/remove-list-item-1-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/remove-list-item-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/remove-list-item-1.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/InsertListCommand.cpp

index e1fa504b187697559336ddfd5dd612b87d97cecc..528536e6327286d0ec5f452b2786c705d95eeccc 100644 (file)
@@ -1,3 +1,19 @@
+2006-09-26  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <rdar://problem/4747695> 
+        Gmail Editor: Crash at WebCore::Range::startPosition() when decreasing a indent
+
+        * editing/deleting/list-item-1-expected.checksum: Added.
+        * editing/deleting/list-item-1-expected.png: Added.
+        * editing/deleting/list-item-1-expected.txt: Added.
+        * editing/deleting/list-item-1.html: Added.
+        * editing/execCommand/remove-list-item-1-expected.checksum: Added.
+        * editing/execCommand/remove-list-item-1-expected.png: Added.
+        * editing/execCommand/remove-list-item-1-expected.txt: Added.
+        * editing/execCommand/remove-list-item-1.html: Added.
+
 2006-09-26  David Harrison  <harrison@apple.com>
 
         Reviewed by John and TimH.
diff --git a/LayoutTests/editing/deleting/list-item-1-expected.checksum b/LayoutTests/editing/deleting/list-item-1-expected.checksum
new file mode 100644 (file)
index 0000000..5596db9
--- /dev/null
@@ -0,0 +1 @@
+9f1c55259f96d59388221dfee3d1cdb6
\ No newline at end of file
diff --git a/LayoutTests/editing/deleting/list-item-1-expected.png b/LayoutTests/editing/deleting/list-item-1-expected.png
new file mode 100644 (file)
index 0000000..0978d66
Binary files /dev/null and b/LayoutTests/editing/deleting/list-item-1-expected.png differ
diff --git a/LayoutTests/editing/deleting/list-item-1-expected.txt b/LayoutTests/editing/deleting/list-item-1-expected.txt
new file mode 100644 (file)
index 0000000..8fa2fb5
--- /dev/null
@@ -0,0 +1,31 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldDeleteDOMRange:range from 0 of #text > LI > UL > UL > DIV > BODY > HTML > #document to 3 of #text > LI > UL > UL > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of UL > DIV > BODY > HTML > #document to 0 of UL > 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 784x36
+        RenderText {#text} at (0,0) size 760x36
+          text run at (0,0) width 264: "This test deletes the contents of a sub-list. "
+          text run at (264,0) width 296: "Since it is fully selected, it should be removed. "
+          text run at (560,0) width 200: "But the list item below it should"
+          text run at (0,18) width 51: "remain. "
+        RenderInline {B} at (0,0) size 561x18
+          RenderText {#text} at (51,18) size 561x18
+            text run at (51,18) width 561: "The fact that the caret ends up in an orphaned list child might be considered a bug."
+      RenderBlock {DIV} at (0,52) size 784x36
+        RenderBlock {UL} at (0,0) size 784x36
+          RenderBlock (anonymous) at (40,0) size 744x18
+            RenderBR {BR} at (0,0) size 0x18
+          RenderListItem {LI} at (40,18) size 744x18
+            RenderListMarker at (-17,0) size 7x18
+            RenderBR {BR} at (0,0) size 0x18
+caret: position 0 of child 0 {BR} of child 0 {UL} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/deleting/list-item-1.html b/LayoutTests/editing/deleting/list-item-1.html
new file mode 100644 (file)
index 0000000..3d3f005
--- /dev/null
@@ -0,0 +1,13 @@
+<body>
+<p>This test deletes the contents of a sub-list.  Since it is fully selected, it should be removed.  But the list item below it should remain. <b>The fact that the caret ends up in an orphaned list child might be considered a bug.</b></p>
+<div id="div" contentEditable="true"><ul><ul><li>foo</li></ul><li><br></li></ul></div>
+
+<script>
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+sel.modify("extend", "forward", "word");
+document.execCommand("Delete");
+</script>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/remove-list-item-1-expected.checksum b/LayoutTests/editing/execCommand/remove-list-item-1-expected.checksum
new file mode 100644 (file)
index 0000000..42af995
--- /dev/null
@@ -0,0 +1 @@
+f71e9baa7942de1f2c72720ec80e9ac6
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/remove-list-item-1-expected.png b/LayoutTests/editing/execCommand/remove-list-item-1-expected.png
new file mode 100644 (file)
index 0000000..14dbc58
Binary files /dev/null and b/LayoutTests/editing/execCommand/remove-list-item-1-expected.png differ
diff --git a/LayoutTests/editing/execCommand/remove-list-item-1-expected.txt b/LayoutTests/editing/execCommand/remove-list-item-1-expected.txt
new file mode 100644 (file)
index 0000000..fb70926
--- /dev/null
@@ -0,0 +1,23 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of LI > UL > DIV > BODY > HTML > #document to 0 of LI > UL > 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 288x18
+          text run at (0,0) width 288: "Outdenting a sublist should remove one level."
+      RenderBlock {DIV} at (0,34) size 784x18
+        RenderBlock {UL} at (0,0) size 784x18
+          RenderBlock (anonymous) at (40,0) size 744x0
+          RenderListItem {LI} at (40,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+caret: position 0 of child 0 {#text} of child 0 {LI} of child 0 {UL} of child 3 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/remove-list-item-1.html b/LayoutTests/editing/execCommand/remove-list-item-1.html
new file mode 100644 (file)
index 0000000..5f32ac0
--- /dev/null
@@ -0,0 +1,12 @@
+<body>
+<p>Outdenting a sublist should remove one level.</p>
+<div id="div" contentEditable="true"><ul><ul><li>foo</li></ul></ul></div>
+
+<script>
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+document.execCommand("Outdent");
+</script>
+</body>
\ No newline at end of file
index bfe70da006ca8bd6908b5c366a7ea3ff2f0a0280..ceb777580b89a9e265377c2ba6698cbafbc3ae8f 100644 (file)
@@ -1,3 +1,18 @@
+2006-09-26  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by john
+        
+        <rdar://problem/4747695> 
+        Gmail Editor: Crash at WebCore::Range::startPosition() when decreasing a indent
+        
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::initializeStartEnd): Stop expanding
+        to select special elements that are fully selected after expansion
+        moves to positions that are visually distinct from the originals.
+        * editing/InsertListCommand.cpp:
+        (WebCore::InsertListCommand::doApply): If the content of the list 
+        item will be moved into another list, put it in a list item.
+
 2006-09-26  Geoffrey Garen <ggaren@apple.com>
 
         Reviewed by Darin.
index 5e8f6a6ed05b53ad30c7930ed4240b87f72739b8..aab99e3a305c9dbfc380717e7906ae6e3fe8525f 100644 (file)
@@ -86,7 +86,7 @@ void DeleteSelectionCommand::initializeStartEnd()
     else if (end.node()->hasTagName(hrTag))
         end = Position(end.node(), 1);
     
-    while (1) {
+    while (VisiblePosition(start) == m_selectionToDelete.visibleStart() && VisiblePosition(end) == m_selectionToDelete.visibleEnd()) {
         startSpecialContainer = 0;
         endSpecialContainer = 0;
     
index bf4d6ccc21122f094814d7fa6f4fd4b0eef36deb..b62452619dacf02577619a365090f84895296e65 100644 (file)
@@ -131,13 +131,20 @@ void InsertListCommand::doApply()
         // When removing a list, we must always create a placeholder to act as a point of insertion
         // for the list content being removed.
         RefPtr<Element> placeholder = createBreakElement(document());
+        RefPtr<Node> nodeToInsert = placeholder;
+        // If the content of the list item will be moved into another list, put it in a list item
+        // so that we don't create an orphaned list child.
+        if (enclosingList(listNode)) {
+            nodeToInsert = createListItemElement(document());
+            appendNode(placeholder.get(), nodeToInsert.get());
+        }
         if (nextListChild && previousListChild) {
             splitElement(static_cast<Element *>(listNode), nextListChild);
-            insertNodeBefore(placeholder.get(), listNode);
+            insertNodeBefore(nodeToInsert.get(), listNode);
         } else if (nextListChild)
-            insertNodeBefore(placeholder.get(), listNode);
+            insertNodeBefore(nodeToInsert.get(), listNode);
         else
-            insertNodeAfter(placeholder.get(), listNode);
+            insertNodeAfter(nodeToInsert.get(), listNode);
         VisiblePosition insertionPoint = VisiblePosition(Position(placeholder.get(), 0));
         moveParagraphs(start, end, insertionPoint, true);
     }