LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jan 2007 01:00:36 +0000 (01:00 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Jan 2007 01:00:36 +0000 (01:00 +0000)
        Reviewed by harrison

        <rdar://problem/4916235>
        <rdar://problem/4857269>
        <rdar://problem/4916583>
        <rdar://problem/4928635>

        Fixed and removed FIXME:
        * editing/execCommand/create-list-from-range-selection-expected.checksum:
        * editing/execCommand/create-list-from-range-selection-expected.png:
        * editing/execCommand/create-list-from-range-selection-expected.txt:
        * editing/execCommand/create-list-from-range-selection.html:
        Added:
        * editing/deleting/4916235-1-expected.txt: Added.
        * editing/deleting/4916235-1.html: Added.
        * editing/execCommand/4916235-expected.txt: Added.
        * editing/execCommand/4916235.html: Added.
        * editing/execCommand/4916583-expected.checksum: Added.
        * editing/execCommand/4916583-expected.png: Added.
        * editing/execCommand/4916583-expected.txt: Added.
        * editing/execCommand/4916583.html: Added.
        * editing/execCommand/4928635-expected.txt: Added.
        * editing/execCommand/4928635.html: Added.
        Equivalent trees:
        * editing/execCommand/remove-list-item-1-expected.txt:
        * editing/execCommand/remove-list-items-expected.txt:
        * editing/execCommand/switch-list-type-expected.txt:
        Introduced an extraneous newline because of the poor substitute for
        VisiblePosition creation in shouldEmitNewlineAfterNode:
        * dom/xhtml/level3/core/nodecomparedocumentposition12-expected.txt:
        * dom/xhtml/level3/core/nodecomparedocumentposition17-expected.txt:
        * dom/xhtml/level3/core/nodeinsertbefore09-expected.txt:

WebCore:

        Reviewed by harrison

        <rdar://problem/4916235>
        eBay Editor: Crash occurs at WebCore::Range::startPosition() after applying ordered list styling to selected text
        <rdar://problem/4857269>
        REGRESSION: editing/execCommand/create-list-from-range-selection.html no longer works as intended
        <rdar://problem/4916583>
        eBay Editor: Removing a indent from a list item actually deletes the list item instead
        <rdar://problem/4928635>
        designMode outdent causes crash (11750)

        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::moveParagraphs): Fixed br insertion
        after the pruning of empty containers left over after the paragraph
        to move is removed.
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::DeleteSelectionCommand): There are
        bugs that leave the wrong number of line breaks after a deletion
        that expands to include special elements (lists/tables).  Added
        a workaround so that moveParagraphs can avoid these until they
        are fixed.
        (WebCore::DeleteSelectionCommand::initializeStartEnd): Ditto.
        (WebCore::DeleteSelectionCommand::initializePositionData): Ditto.
        * editing/DeleteSelectionCommand.h:
        * editing/TextIterator.cpp:
        (WebCore::TextIterator::advance): We used to not call exitNode for
        ancestors of a node where the next node in a pre-order traversal is
        the ranges's pastEndNode().  This is only correct for ancestors that
        contain the end of the range.
        (WebCore::shouldEmitNewlineAfterNode): Added, we should only emit newlines
        after blocks that have VisiblePositions after them.  VisiblePosition creation
        though is too expensive to do here, what I added here is an OK substitute.
        (WebCore::shouldEmitNewlineBeforeNode): Added.  No special logic yet.
        (WebCore::TextIterator::handleNonTextNode): Call shouldEmitNewlineBeforeNode.
        (WebCore::TextIterator::exitNode): Call shouldEmitNewlineAfterNode.
        (WebCore::SimplifiedBackwardsTextIterator::handleNonTextNode): Call
        shouldEmitNewlineAfterNode.

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

26 files changed:
LayoutTests/ChangeLog
LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition12-expected.txt
LayoutTests/dom/xhtml/level3/core/nodecomparedocumentposition17-expected.txt
LayoutTests/dom/xhtml/level3/core/nodeinsertbefore09-expected.txt
LayoutTests/editing/deleting/4916235-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/deleting/4916235-1.html [new file with mode: 0644]
LayoutTests/editing/execCommand/4916235-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/4916235.html [new file with mode: 0644]
LayoutTests/editing/execCommand/4916583-expected.checksum [new file with mode: 0644]
LayoutTests/editing/execCommand/4916583-expected.png [new file with mode: 0644]
LayoutTests/editing/execCommand/4916583-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/4916583.html [new file with mode: 0644]
LayoutTests/editing/execCommand/4928635-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/4928635.html [new file with mode: 0644]
LayoutTests/editing/execCommand/create-list-from-range-selection-expected.checksum
LayoutTests/editing/execCommand/create-list-from-range-selection-expected.png
LayoutTests/editing/execCommand/create-list-from-range-selection-expected.txt
LayoutTests/editing/execCommand/create-list-from-range-selection.html
LayoutTests/editing/execCommand/remove-list-item-1-expected.txt
LayoutTests/editing/execCommand/remove-list-items-expected.txt
LayoutTests/editing/execCommand/switch-list-type-expected.txt
WebCore/ChangeLog
WebCore/editing/CompositeEditCommand.cpp
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/DeleteSelectionCommand.h
WebCore/editing/TextIterator.cpp

index 7644eea398d06b45a9423c1886150ac08def3d0a..74bed2611b7a0f757050f447e834031248052f76 100644 (file)
@@ -1,3 +1,39 @@
+2007-01-23  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4916235>
+        <rdar://problem/4857269>
+        <rdar://problem/4916583>
+        <rdar://problem/4928635>
+        
+        Fixed and removed FIXME:
+        * editing/execCommand/create-list-from-range-selection-expected.checksum:
+        * editing/execCommand/create-list-from-range-selection-expected.png:
+        * editing/execCommand/create-list-from-range-selection-expected.txt:
+        * editing/execCommand/create-list-from-range-selection.html:
+        Added:
+        * editing/deleting/4916235-1-expected.txt: Added.
+        * editing/deleting/4916235-1.html: Added.
+        * editing/execCommand/4916235-expected.txt: Added.
+        * editing/execCommand/4916235.html: Added.
+        * editing/execCommand/4916583-expected.checksum: Added.
+        * editing/execCommand/4916583-expected.png: Added.
+        * editing/execCommand/4916583-expected.txt: Added.
+        * editing/execCommand/4916583.html: Added.
+        * editing/execCommand/4928635-expected.txt: Added.
+        * editing/execCommand/4928635.html: Added.
+        Equivalent trees:
+        * editing/execCommand/remove-list-item-1-expected.txt:
+        * editing/execCommand/remove-list-items-expected.txt:
+        * editing/execCommand/switch-list-type-expected.txt:
+        Introduced an extraneous newline because of the poor substitute for
+        VisiblePosition creation in shouldEmitNewlineAfterNode:
+        * dom/xhtml/level3/core/nodecomparedocumentposition12-expected.txt:
+        * dom/xhtml/level3/core/nodecomparedocumentposition17-expected.txt:
+        * dom/xhtml/level3/core/nodeinsertbefore09-expected.txt: 
+
+
 2007-01-23  Mark Rowe  <mrowe@apple.com>
 
         Reviewed by Adele.
index 65c9caeb13cd383b489d1602c72c331809376507..4c2e3718f28a34a9229affee48d4ea08b7c4f5fa 100644 (file)
@@ -1,3 +1,4 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition12
 Status error
 Message        TypeError: Value undefined (result of expression doc.compareDocumentPosition) is not object.
+
index c564bf1b2476170170be4d16b5f02942cf4169ff..23c9a56642300aefcc6d218db866bde814e81b0b 100644 (file)
@@ -1,3 +1,4 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodecomparedocumentposition17
 Status error
 Message        TypeError: Value undefined (result of expression pi1.compareDocumentPosition) is not object.
+
index 4c9362c7f48e81ba09191062dcbf03e0a28465a0..1633e4772de6507aa8ce8b6f068abe890848a758 100644 (file)
@@ -1,2 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeinsertbefore09
 Status Success
+
diff --git a/LayoutTests/editing/deleting/4916235-1-expected.txt b/LayoutTests/editing/deleting/4916235-1-expected.txt
new file mode 100644 (file)
index 0000000..305cf67
--- /dev/null
@@ -0,0 +1,6 @@
+This tests for a bug in moveParagraphs that would cause an empty paragraph to collapse.
+
+There should be an empty paragraph below this one.
+
+There should be an empty paragraph above this one.
+
diff --git a/LayoutTests/editing/deleting/4916235-1.html b/LayoutTests/editing/deleting/4916235-1.html
new file mode 100644 (file)
index 0000000..1dd41b3
--- /dev/null
@@ -0,0 +1,15 @@
+<p>This tests for a bug in moveParagraphs that would cause an empty paragraph to collapse.</p>
+<div id="div" contenteditable="true">There should be an empty paragraph below this one.<div>There should be an empty paragraph below this one.</div><br>There should be an empty paragraph above this one.</div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+var div = document.getElementById("div");
+var sel = window.getSelection();
+
+sel.setPosition(div, 0);
+sel.modify("move", "forward", "character");
+sel.modify("extend", "forward", "line");
+document.execCommand("Delete");
+</script>
diff --git a/LayoutTests/editing/execCommand/4916235-expected.txt b/LayoutTests/editing/execCommand/4916235-expected.txt
new file mode 100644 (file)
index 0000000..bcfd380
--- /dev/null
@@ -0,0 +1,5 @@
+This tests for a crash when performing InsertOrderedList on an unordered list item. You should see 'foo' and 'bar' each in their own ordered list items.
+
+foo
+bar
+
diff --git a/LayoutTests/editing/execCommand/4916235.html b/LayoutTests/editing/execCommand/4916235.html
new file mode 100644 (file)
index 0000000..a8e07fc
--- /dev/null
@@ -0,0 +1,17 @@
+<p>This tests for a crash when performing InsertOrderedList on an unordered list item.  You should see 'foo' and 'bar' each in their own ordered list items.</p>
+<div id="div" contenteditable="true"><ul><li id="li1">foo</li><li id="li2">bar<br></li></ul></div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+var li = document.getElementById("li1");
+var sel = window.getSelection();
+
+sel.setBaseAndExtent(li, 0, li, li.childNodes.length);
+document.execCommand("InsertOrderedList");
+
+li = document.getElementById("li2");
+sel.setBaseAndExtent(li, 0, li, li.childNodes.length);
+document.execCommand("InsertOrderedList");
+</script>
diff --git a/LayoutTests/editing/execCommand/4916583-expected.checksum b/LayoutTests/editing/execCommand/4916583-expected.checksum
new file mode 100644 (file)
index 0000000..0384f14
--- /dev/null
@@ -0,0 +1 @@
+7a06fe9b1d6b1f4db98f589322292462
\ No newline at end of file
diff --git a/LayoutTests/editing/execCommand/4916583-expected.png b/LayoutTests/editing/execCommand/4916583-expected.png
new file mode 100644 (file)
index 0000000..f10d90a
Binary files /dev/null and b/LayoutTests/editing/execCommand/4916583-expected.png differ
diff --git a/LayoutTests/editing/execCommand/4916583-expected.txt b/LayoutTests/editing/execCommand/4916583-expected.txt
new file mode 100644 (file)
index 0000000..0a9fe8b
--- /dev/null
@@ -0,0 +1,20 @@
+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 767x18
+          text run at (0,0) width 368: "This tests for a bug when outdenting an indented list item. "
+          text run at (368,0) width 399: "You should see 'foo' and 'bar' each in their own list item below."
+      RenderBlock {DIV} at (0,34) size 784x36
+        RenderBlock {UL} at (0,0) size 784x36
+          RenderListItem {LI} at (40,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+          RenderListItem {LI} at (40,18) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+            RenderText {#text} at (0,0) size 20x18
+              text run at (0,0) width 20: "bar"
+caret: position 0 of child 0 {#text} of child 1 {LI} of child 0 {UL} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/execCommand/4916583.html b/LayoutTests/editing/execCommand/4916583.html
new file mode 100644 (file)
index 0000000..d0f31e9
--- /dev/null
@@ -0,0 +1,10 @@
+<p>This tests for a bug when outdenting an indented list item.  You should see 'foo' and 'bar' each in their own list item below.</p>
+<div id="div" contenteditable="true"><ul><li>foo</li><ul><li id="li">bar<br></li></ul></ul></div>
+
+<script>
+var li = document.getElementById("li");
+var sel = window.getSelection();
+
+sel.setPosition(li, 0);
+document.execCommand("Outdent");
+</script>
diff --git a/LayoutTests/editing/execCommand/4928635-expected.txt b/LayoutTests/editing/execCommand/4928635-expected.txt
new file mode 100644 (file)
index 0000000..7a11e5c
--- /dev/null
@@ -0,0 +1,4 @@
+This tests for a crash when outdenting an indented paragraph. You should see 'foo' in a single level list item.
+
+foo
+
diff --git a/LayoutTests/editing/execCommand/4928635.html b/LayoutTests/editing/execCommand/4928635.html
new file mode 100644 (file)
index 0000000..288d928
--- /dev/null
@@ -0,0 +1,13 @@
+<p>This tests for a crash when outdenting an indented paragraph.  You should see 'foo' in a single level list item.</p>
+<div contenteditable="true"><ul><ul><li id="li">foo<br></li></ul></ul></div>
+
+<script>
+if (window.layoutTestController)
+    window.layoutTestController.dumpAsText();
+    
+var li = document.getElementById("li");
+var sel = window.getSelection();
+
+sel.setPosition(li, li.childNodes.length);
+document.execCommand("Outdent");
+</script>
index 33a52b79a0d27deed2b766bedbfa42f9c2adc053..f743cb3e66bd7aba5eb8e1b171a35cde6c7c9076 100644 (file)
@@ -1 +1 @@
-faa44b9a0e599d64d8ad837d19d613b9
\ No newline at end of file
+df73fe3bb7ebfa11d32d699f1d302fba
\ No newline at end of file
index 06f5a4cb4fc7323ddbf4a581060474b992fb5df1..da1e7a40eaedfc7a2446980bf8a2b80197759ce8 100644 (file)
Binary files a/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.png and b/LayoutTests/editing/execCommand/create-list-from-range-selection-expected.png differ
index f1925d27ce222f375873d42d4dccd93f318dec40..bb27d8894e1f070b8d06d73b28da692174543b2d 100644 (file)
@@ -10,49 +10,40 @@ layer 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 784x72
-        RenderText {#text} at (0,0) size 636x18
-          text run at (0,0) width 636: "This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content. "
-        RenderInline {B} at (0,0) size 781x72
-          RenderText {#text} at (636,0) size 781x72
-            text run at (636,0) width 138: "This test used to end"
-            text run at (0,18) width 781: "with a flat list from 1 to 6, with a selection extending from just before the last \"o\" in \"1. asdfoo\" to just after the \"a\""
-            text run at (0,36) width 538: "in \"6. baz\". This result changed with John's rangeCompliantEquivalent fixes in"
-            text run at (0,54) width 400: "CompositeEditCommand::moveParagraphs on 11/30/2006."
-      RenderBlock {DIV} at (0,88) size 784x126
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 632x18
+          text run at (0,0) width 632: "This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content."
+      RenderBlock {DIV} at (0,34) size 784x108
         RenderBlock (anonymous) at (0,0) size 784x0
-        RenderBlock {OL} at (0,0) size 784x126
-          RenderListItem {LI} at (40,0) size 744x36
-            RenderBlock (anonymous) at (0,0) size 744x18
-              RenderListMarker at (-20,0) size 16x18: "1"
-            RenderBlock {OL} at (0,18) size 744x18
-              RenderListItem {LI} at (40,0) size 704x18
-                RenderListMarker at (-20,0) size 16x18: "1"
-                RenderText {#text} at (0,0) size 21x18
-                  text run at (0,0) width 21: "asd"
-                RenderInline {SPAN} at (0,0) size 21x18
-                  RenderText {#text} at (21,0) size 21x18
-                    text run at (21,0) width 21: "foo"
-          RenderListItem {LI} at (40,36) size 744x18
+        RenderBlock {OL} at (0,0) size 784x108
+          RenderListItem {LI} at (40,0) size 744x18
+            RenderListMarker at (-20,0) size 16x18: "1"
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "asd"
+            RenderInline {SPAN} at (0,0) size 21x18
+              RenderText {#text} at (21,0) size 21x18
+                text run at (21,0) width 21: "foo"
+          RenderListItem {LI} at (40,18) size 744x18
             RenderListMarker at (-20,0) size 16x18: "2"
             RenderText {#text} at (0,0) size 20x18
               text run at (0,0) width 20: "bar"
-          RenderListItem {LI} at (40,54) size 744x18
+          RenderListItem {LI} at (40,36) size 744x18
             RenderListMarker at (-20,0) size 16x18: "3"
             RenderText {#text} at (0,0) size 22x18
               text run at (0,0) width 22: "baz"
-          RenderListItem {LI} at (40,72) size 744x18
+          RenderListItem {LI} at (40,54) size 744x18
             RenderListMarker at (-20,0) size 16x18: "4"
             RenderText {#text} at (0,0) size 21x18
               text run at (0,0) width 21: "foo"
-          RenderListItem {LI} at (40,90) size 744x18
+          RenderListItem {LI} at (40,72) size 744x18
             RenderListMarker at (-20,0) size 16x18: "5"
             RenderText {#text} at (0,0) size 20x18
               text run at (0,0) width 20: "bar"
-          RenderListItem {LI} at (40,108) size 744x18
+          RenderListItem {LI} at (40,90) size 744x18
             RenderListMarker at (-20,0) size 16x18: "6"
             RenderInline {SPAN} at (0,0) size 22x18
               RenderText {#text} at (0,0) size 22x18
                 text run at (0,0) width 22: "baz"
-        RenderBlock (anonymous) at (0,142) size 784x0
-caret: position 2 of child 0 {#text} of child 0 {SPAN} of child 5 {LI} of child 0 {OL} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+        RenderBlock (anonymous) at (0,124) size 784x0
+selection start: position 2 of child 0 {#text} of child 1 {SPAN} of child 0 {LI} of child 0 {OL} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 2 of child 0 {#text} of child 0 {SPAN} of child 5 {LI} of child 0 {OL} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 241a8ba6622ed96f44c68e319d5e6d83621c5f4c..c8c005d347aa073a41b5be34485abc6084481d41 100644 (file)
@@ -2,10 +2,7 @@
 if (window.layoutTestController)
      layoutTestController.dumpEditingCallbacks();
 </script>
-<p>This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content.
-<b>This test used to end with a flat list from 1 to 6, with a selection extending from just before the last "o"
-in "1. asdfoo" to just after the "a" in "6. baz". This result changed with John's rangeCompliantEquivalent
-fixes in CompositeEditCommand::moveParagraphs on 11/30/2006.</b></p>
+<p>This tests Insert{Un}OrderedList on a range selection that contains a mix of list and non-list content.</p>
 <div id="test" contenteditable="true">asd<span id="start">foo</span><br><ul><li>bar</li></ul>baz<br>foo<ol><li>bar</li></ol><span id="end">baz</span></div>
 <script>
 var s = window.getSelection();
index 269e44a87c6c79a7e19a204be6c0fcd777898ad8..2de6185bbab9ab8311bb4d5d0bfd18d58cb46572 100644 (file)
@@ -15,7 +15,6 @@ layer at (0,0) size 800x600
           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: bullet
             RenderText {#text} at (0,0) size 21x18
index d2015622319c51fcfc6e26c4a1280277548e947b..8f5a612fb1cb291f2cb0217a521b21d804924354 100644 (file)
@@ -87,4 +87,4 @@ layer at (0,0) size 800x600
           RenderInline {SPAN} at (0,0) size 170x18
             RenderText {#text} at (0,18) size 170x18
               text run at (0,18) width 170: "This should not be in a list."
-caret: position 0 of child 0 {#text} of child 15 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {#text} of child 16 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 9da75696870d5c7554c28bef2b238a4026d2c452..426c8773b2d9a287d5f73f7a4b5c04ed3012ed68 100644 (file)
@@ -95,6 +95,7 @@ layer at (0,0) size 800x600
           RenderText {#text} at (0,0) size 170x18
             text run at (0,0) width 170: "This should not be in a list."
           RenderBR {BR} at (170,14) size 0x0
+          RenderText {#text} at (0,0) size 0x0
           RenderInline {SPAN} at (0,0) size 0x0
         RenderBlock (anonymous) at (0,316) size 784x18
           RenderBlock {OL} at (0,0) size 784x18
@@ -105,4 +106,4 @@ layer at (0,0) size 800x600
                   text run at (0,0) width 206: "This should be in an ordered list."
         RenderBlock (anonymous) at (0,350) size 784x0
           RenderInline {SPAN} at (0,0) size 0x0
-caret: position 0 of child 0 {#text} of child 0 {SPAN} of child 0 {LI} of child 0 {OL} of child 10 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {#text} of child 0 {SPAN} of child 0 {LI} of child 0 {OL} of child 11 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index b4d20a76fab24ad2f7fc549ff94b65a63fb1a285..07084a2cdec57f8216074bf4667b7bb51c06c6c9 100644 (file)
@@ -1,3 +1,43 @@
+2007-01-24  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+
+        <rdar://problem/4916235>
+        eBay Editor: Crash occurs at WebCore::Range::startPosition() after applying ordered list styling to selected text
+        <rdar://problem/4857269>
+        REGRESSION: editing/execCommand/create-list-from-range-selection.html no longer works as intended
+        <rdar://problem/4916583>
+        eBay Editor: Removing a indent from a list item actually deletes the list item instead
+        <rdar://problem/4928635>
+        designMode outdent causes crash (11750)
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::moveParagraphs): Fixed br insertion
+        after the pruning of empty containers left over after the paragraph
+        to move is removed.
+        * editing/DeleteSelectionCommand.cpp:
+        (WebCore::DeleteSelectionCommand::DeleteSelectionCommand): There are
+        bugs that leave the wrong number of line breaks after a deletion 
+        that expands to include special elements (lists/tables).  Added 
+        a workaround so that moveParagraphs can avoid these until they 
+        are fixed.
+        (WebCore::DeleteSelectionCommand::initializeStartEnd): Ditto.
+        (WebCore::DeleteSelectionCommand::initializePositionData): Ditto.
+        * editing/DeleteSelectionCommand.h:
+        * editing/TextIterator.cpp:
+        (WebCore::TextIterator::advance): We used to not call exitNode for
+        ancestors of a node where the next node in a pre-order traversal is 
+        the ranges's pastEndNode().  This is only correct for ancestors that
+        contain the end of the range.
+        (WebCore::shouldEmitNewlineAfterNode): Added, we should only emit newlines
+        after blocks that have VisiblePositions after them.  VisiblePosition creation
+        though is too expensive to do here, what I added here is an OK substitute.
+        (WebCore::shouldEmitNewlineBeforeNode): Added.  No special logic yet.
+        (WebCore::TextIterator::handleNonTextNode): Call shouldEmitNewlineBeforeNode.
+        (WebCore::TextIterator::exitNode): Call shouldEmitNewlineAfterNode.
+        (WebCore::SimplifiedBackwardsTextIterator::handleNonTextNode): Call
+        shouldEmitNewlineAfterNode.
+
 2007-01-24  Darin Adler  <darin@apple.com>
 
         Reviewed by Mark Rowe.
index b01445cac9fad8f220bfc923ecfee98fc9985d09..ee7aa15f112ae964c82c1deb406cdbb233b6f18f 100644 (file)
@@ -728,6 +728,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     }
     
     VisiblePosition beforeParagraph = startOfParagraphToMove.previous();
+    VisiblePosition afterParagraph(endOfParagraphToMove.next());
 
     // We upstream() the end and downstream() the start so that we don't include collapsed whitespace in the move.
     // When we paste a fragment, spaces after the end and before the start are treated as though they were rendered.    
@@ -744,7 +745,7 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     RefPtr<DocumentFragment> fragment = startOfParagraphToMove != endOfParagraphToMove ? createFragmentFromMarkup(document(), range->toHTML(), "") : 0;
     
     setEndingSelection(Selection(start, end, DOWNSTREAM));
-    deleteSelection(false, false);
+    applyCommandToComposite(new DeleteSelectionCommand(document(), false, false, false, false));
 
     ASSERT(destination.deepEquivalent().node()->inDocument());
     
@@ -778,8 +779,15 @@ void CompositeEditCommand::moveParagraphs(const VisiblePosition& startOfParagrap
     // baz
     // Imagine moving 'bar' to ^.  'bar' will be deleted and its div pruned.  That would
     // cause 'baz' to collapse onto the line with 'foobar' unless we insert a br.
-    if (beforeParagraph.isNotNull() && !isEndOfParagraph(beforeParagraph))
+    // Must recononicalize these two VisiblePositions after the pruning above.
+    beforeParagraph = VisiblePosition(beforeParagraph.deepEquivalent());
+    afterParagraph = VisiblePosition(afterParagraph.deepEquivalent());
+    if (beforeParagraph.isNotNull() && (!isEndOfParagraph(beforeParagraph) || beforeParagraph == afterParagraph)) {
+        // FIXME: Trim text between beforeParagraph and afterParagraph if they aren't equal.
         insertNodeAt(createBreakElement(document()).get(), beforeParagraph.deepEquivalent().node(), beforeParagraph.deepEquivalent().offset());
+        // Need an updateLayout here in case inserting the br has split a text node.
+        updateLayout();
+    }
         
     RefPtr<Range> startToDestinationRange(new Range(document(), Position(document(), 0), rangeCompliantEquivalent(destination.deepEquivalent())));
     destinationIndex = TextIterator::rangeLength(startToDestinationRange.get());
index 76760e9f6beb6c119d22f29628b3d3d970827cdf..0ed20976d610c245b35bcc8ebca9f9a909e0799c 100644 (file)
@@ -46,12 +46,13 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
+DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
     : CompositeEditCommand(document), 
       m_hasSelectionToDelete(false), 
       m_smartDelete(smartDelete), 
       m_mergeBlocksAfterDelete(mergeBlocksAfterDelete),
       m_replace(replace),
+      m_expandForSpecialElements(expandForSpecialElements),
       m_startBlock(0),
       m_endBlock(0),
       m_typingStyle(0),
@@ -59,12 +60,13 @@ DeleteSelectionCommand::DeleteSelectionCommand(Document *document, bool smartDel
 {
 }
 
-DeleteSelectionCommand::DeleteSelectionCommand(const Selection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace)
+DeleteSelectionCommand::DeleteSelectionCommand(const Selection& selection, bool smartDelete, bool mergeBlocksAfterDelete, bool replace, bool expandForSpecialElements)
     : CompositeEditCommand(selection.start().node()->document()), 
       m_hasSelectionToDelete(true), 
       m_smartDelete(smartDelete), 
       m_mergeBlocksAfterDelete(mergeBlocksAfterDelete),
       m_replace(replace),
+      m_expandForSpecialElements(expandForSpecialElements),
       m_selectionToDelete(selection),
       m_startBlock(0),
       m_endBlock(0),
@@ -73,13 +75,13 @@ DeleteSelectionCommand::DeleteSelectionCommand(const Selection& selection, bool
 {
 }
 
-void DeleteSelectionCommand::initializeStartEnd()
+void DeleteSelectionCommand::initializeStartEnd(Position& start, Position& end)
 {
     Node* startSpecialContainer = 0;
     Node* endSpecialContainer = 0;
  
-    Position start = m_selectionToDelete.start();
-    Position end = m_selectionToDelete.end();
+    start = m_selectionToDelete.start();
+    end = m_selectionToDelete.end();
  
     // For HRs, we'll get a position at (HR,1) when hitting delete from the beginning of the previous line, or (HR,0) when forward deleting,
     // but in these cases, we want to delete it, so manually expand the selection
@@ -88,6 +90,10 @@ void DeleteSelectionCommand::initializeStartEnd()
     else if (end.node()->hasTagName(hrTag))
         end = Position(end.node(), 1);
     
+    // FIXME: This is only used so that moveParagraphs can avoid the bugs in special element expanion.
+    if (!m_expandForSpecialElements)
+        return;
+    
     while (VisiblePosition(start) == m_selectionToDelete.visibleStart() && VisiblePosition(end) == m_selectionToDelete.visibleEnd()) {
         startSpecialContainer = 0;
         endSpecialContainer = 0;
@@ -111,16 +117,17 @@ void DeleteSelectionCommand::initializeStartEnd()
             end = e;
         }
     }
-    m_upstreamStart = start.upstream();
-    m_downstreamStart = start.downstream();
-    m_upstreamEnd = end.upstream();
-    m_downstreamEnd = end.downstream();
 }
 
 void DeleteSelectionCommand::initializePositionData()
 {
-    initializeStartEnd();
+    Position start, end;
+    initializeStartEnd(start, end);
+    
+    m_upstreamStart = start.upstream();
+    m_downstreamStart = start.downstream();
+    m_upstreamEnd = end.upstream();
+    m_downstreamEnd = end.downstream();
     
     Node* startCell = enclosingTableCell(m_upstreamStart.node());
     Node* endCell = enclosingTableCell(m_downstreamEnd.node());
index 473eb30ff31581206dc6da535cccd054252a65d7..00ceebbbaf8b2b41e313c60c23baee1208c3a1d0 100644 (file)
@@ -32,8 +32,8 @@ namespace WebCore {
 
 class DeleteSelectionCommand : public CompositeEditCommand { 
 public:
-    DeleteSelectionCommand(Document*, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
-    DeleteSelectionCommand(const Selection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false);
+    DeleteSelectionCommand(Document*, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
+    DeleteSelectionCommand(const Selection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
 
     virtual void doApply();
     virtual EditAction editingAction() const;
@@ -41,7 +41,7 @@ public:
 private:
     virtual bool preservesTypingStyle() const;
 
-    void initializeStartEnd();
+    void initializeStartEnd(Position&, Position&);
     void initializePositionData();
     void saveTypingStyleState();
     void saveFullySelectedAnchor();
@@ -61,6 +61,7 @@ private:
     bool m_mergeBlocksAfterDelete;
     bool m_needPlaceholder;
     bool m_replace;
+    bool m_expandForSpecialElements;
 
     // This data is transient and should be cleared at the end of the doApply function.
     Selection m_selectionToDelete;
index 5cdce8deb8b8d9abc741c44a471169754b2c8954..48418dffd1a65dba96229f6bc240820c2788f23a 100644 (file)
@@ -177,9 +177,10 @@ void TextIterator::advance()
         if (!next) {
             next = m_node->nextSibling();
             if (!next) {
-                if (m_node->traverseNextNode() == m_pastEndNode)
-                    break;
+                bool pastEnd = m_node->traverseNextNode() == m_pastEndNode;
                 while (!next && m_node->parentNode()) {
+                    if (pastEnd && m_node->parentNode() == m_endContainer || m_endContainer->isDescendantOf(m_node->parentNode()))
+                        return;
                     m_node = m_node->parentNode();
                     exitNode();
                     if (m_positionNode) {
@@ -440,6 +441,17 @@ static bool shouldEmitNewlinesBeforeAndAfterNode(Node* node)
     return !r->isInline() && r->isRenderBlock() && !r->isBody();
 }
 
+static bool shouldEmitNewlineAfterNode(Node* node)
+{
+    // FIXME: It should be better but slower to create a VisiblePosition here.
+    return shouldEmitNewlinesBeforeAndAfterNode(node) && node->traverseNextSibling();
+}
+
+static bool shouldEmitNewlineBeforeNode(Node* node)
+{
+    return shouldEmitNewlinesBeforeAndAfterNode(node); 
+}
+
 static bool shouldEmitExtraNewlineForNode(Node* node)
 {
     // When there is a significant collapsed bottom margin, emit an extra
@@ -479,7 +491,7 @@ bool TextIterator::handleNonTextNode()
         // only add the tab or newline if not at the start of a line
         if (shouldEmitTabBeforeNode(m_node))
             emitCharacter('\t', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
-        else if (shouldEmitNewlinesBeforeAndAfterNode(m_node))
+        else if (shouldEmitNewlineBeforeNode(m_node))
             emitCharacter('\n', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
         else if (shouldEmitSpaceBeforeAndAfterNode(m_node))
             emitCharacter(' ', m_lastTextNode->parentNode(), m_lastTextNode, 0, 1);
@@ -490,7 +502,7 @@ bool TextIterator::handleNonTextNode()
 
 void TextIterator::exitNode()
 {
-    if (m_lastTextNode && shouldEmitNewlinesBeforeAndAfterNode(m_node)) {
+    if (m_lastTextNode && shouldEmitNewlineAfterNode(m_node)) {
         // use extra newline to represent margin bottom, as needed
         bool addNewline = shouldEmitExtraNewlineForNode(m_node);
         
@@ -721,7 +733,7 @@ bool SimplifiedBackwardsTextIterator::handleNonTextNode()
     // We can use a linefeed in place of a tab because this simple iterator is only used to
     // find boundaries, not actual content.  A linefeed breaks words, sentences, and paragraphs.
     if (shouldEmitNewlineForNode(m_node) ||
-        shouldEmitNewlinesBeforeAndAfterNode(m_node) ||
+        shouldEmitNewlineAfterNode(m_node) ||
         shouldEmitTabBeforeNode(m_node))
         emitNewline();