LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Apr 2007 23:45:40 +0000 (23:45 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Apr 2007 23:45:40 +0000 (23:45 +0000)
        Reviewed by darin

        <rdar://problem/4875189> List gets deleted when replacing contents

        Replacing the contents of a list:
        * editing/inserting/4875189-1-expected.checksum: Added.
        * editing/inserting/4875189-1-expected.png: Added.
        * editing/inserting/4875189-1-expected.txt: Added.
        * editing/inserting/4875189-1.html: Added.
        Of a floating div:
        * editing/inserting/4875189-2-expected.checksum: Added.
        * editing/inserting/4875189-2-expected.png: Added.
        * editing/inserting/4875189-2-expected.txt: Added.
        * editing/inserting/4875189-2.html: Added.
        Pasting a list on top of itself now creates a nested list:
        * editing/pasteboard/paste-4039777-fix-expected.checksum:
        * editing/pasteboard/paste-4039777-fix-expected.png:
        * editing/pasteboard/paste-4039777-fix-expected.txt:

WebCore:

        Reviewed by darin

        <rdar://problem/4875189> List gets deleted when replacing contents

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply): Don't expand
        to include elements, like lists, when deleting a selection
        to replace it.

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/inserting/4875189-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-1-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-1.html [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-2-expected.checksum [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-2-expected.png [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/inserting/4875189-2.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-4039777-fix-expected.checksum
LayoutTests/editing/pasteboard/paste-4039777-fix-expected.png
LayoutTests/editing/pasteboard/paste-4039777-fix-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/ReplaceSelectionCommand.cpp

index 1518b08..c348723 100644 (file)
@@ -2,6 +2,27 @@
 
         Reviewed by darin
         
+        <rdar://problem/4875189> List gets deleted when replacing contents
+
+        Replacing the contents of a list:
+        * editing/inserting/4875189-1-expected.checksum: Added.
+        * editing/inserting/4875189-1-expected.png: Added.
+        * editing/inserting/4875189-1-expected.txt: Added.
+        * editing/inserting/4875189-1.html: Added.
+        Of a floating div:
+        * editing/inserting/4875189-2-expected.checksum: Added.
+        * editing/inserting/4875189-2-expected.png: Added.
+        * editing/inserting/4875189-2-expected.txt: Added.
+        * editing/inserting/4875189-2.html: Added.
+        Pasting a list on top of itself now creates a nested list:
+        * editing/pasteboard/paste-4039777-fix-expected.checksum:
+        * editing/pasteboard/paste-4039777-fix-expected.png:
+        * editing/pasteboard/paste-4039777-fix-expected.txt:
+        
+2007-04-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by darin
+        
         <rdar://problem/5168598> Crash when deleting a link inside an input field
 
         * editing/deleting/5168598-expected.checksum: Added.
diff --git a/LayoutTests/editing/inserting/4875189-1-expected.checksum b/LayoutTests/editing/inserting/4875189-1-expected.checksum
new file mode 100644 (file)
index 0000000..fe04acd
--- /dev/null
@@ -0,0 +1 @@
+fe0ecf1e5bfff35952589c1d2bd98ec0
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/4875189-1-expected.png b/LayoutTests/editing/inserting/4875189-1-expected.png
new file mode 100644 (file)
index 0000000..814d25b
Binary files /dev/null and b/LayoutTests/editing/inserting/4875189-1-expected.png differ
diff --git a/LayoutTests/editing/inserting/4875189-1-expected.txt b/LayoutTests/editing/inserting/4875189-1-expected.txt
new file mode 100644 (file)
index 0000000..3a03ed4
--- /dev/null
@@ -0,0 +1,16 @@
+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 652x18
+          text run at (0,0) width 358: "This tests for a bug when replacing the contents of a list. "
+          text run at (358,0) width 294: "The list shouldn't be removed, just its contents."
+      RenderBlock {DIV} at (0,34) size 784x18
+        RenderBlock {UL} at (0,0) size 784x18
+          RenderListItem {LI} at (40,0) size 744x18
+            RenderListMarker at (-17,0) size 7x18: bullet
+            RenderText {#text} at (0,0) size 177x18
+              text run at (0,0) width 177: "This should be in a list item."
+caret: position 30 of child 0 {#text} of child 0 {LI} of child 0 {UL} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/4875189-1.html b/LayoutTests/editing/inserting/4875189-1.html
new file mode 100644 (file)
index 0000000..19532c5
--- /dev/null
@@ -0,0 +1,12 @@
+<p>This tests for a bug when replacing the contents of a list.  The list shouldn't be removed, just its contents.</p>
+<div contenteditable="true"><ul><li id="li">You shouldn't see this.</li></ul></div>
+
+<script>
+var r = document.createRange();
+var li = document.getElementById("li");
+r.setStart(li, 0);
+r.setEnd(li, li.childNodes.length);
+var selection = window.getSelection();
+selection.addRange(r);
+document.execCommand("InsertHTML", false, "This should be in a list item.")
+</script>
diff --git a/LayoutTests/editing/inserting/4875189-2-expected.checksum b/LayoutTests/editing/inserting/4875189-2-expected.checksum
new file mode 100644 (file)
index 0000000..5c6cc46
--- /dev/null
@@ -0,0 +1 @@
+4f0911e0d76b88089ae8cde7e128f855
\ No newline at end of file
diff --git a/LayoutTests/editing/inserting/4875189-2-expected.png b/LayoutTests/editing/inserting/4875189-2-expected.png
new file mode 100644 (file)
index 0000000..69dc0fb
Binary files /dev/null and b/LayoutTests/editing/inserting/4875189-2-expected.png differ
diff --git a/LayoutTests/editing/inserting/4875189-2-expected.txt b/LayoutTests/editing/inserting/4875189-2-expected.txt
new file mode 100644 (file)
index 0000000..0cfa5e7
--- /dev/null
@@ -0,0 +1,16 @@
+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 784x18
+          text run at (0,0) width 441: "This tests for a bug when replacing the contents of a floating element. "
+          text run at (441,0) width 343: "Just its contents should be removed during the replace."
+      RenderBlock {DIV} at (0,34) size 784x18
+        RenderText {#text} at (293,0) size 235x18
+          text run at (293,0) width 235: "This shouldn't be in the bordered div."
+        RenderBlock (floating) {DIV} at (0,0) size 293x20 [border: (1px solid #0000FF)]
+          RenderText {#text} at (1,1) size 291x18
+            text run at (1,1) width 291: "This should be in a floating blue bordered div."
+caret: position 47 of child 0 {#text} of child 1 {DIV} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/inserting/4875189-2.html b/LayoutTests/editing/inserting/4875189-2.html
new file mode 100644 (file)
index 0000000..ad9c104
--- /dev/null
@@ -0,0 +1,12 @@
+<p>This tests for a bug when replacing the contents of a floating element.  Just its contents should be removed during the replace.</p>
+<div contenteditable="true">This shouldn't be in the bordered div.<div id="div" style="float:left; border: 1px solid blue;">You shouldn't see this.</div></div>
+
+<script>
+var r = document.createRange();
+var div = document.getElementById("div");
+r.setStart(div, 0);
+r.setEnd(div, div.childNodes.length);
+var selection = window.getSelection();
+selection.addRange(r);
+document.execCommand("InsertHTML", false, "This should be in a floating blue bordered div.")
+</script>
index e2a667c..267f705 100644 (file)
@@ -1 +1 @@
-fb52bc43f6cb6d171ee4de58fbd35f60
\ No newline at end of file
+8f63a80f5f6a2f5420016e0c8464d2b4
\ No newline at end of file
index daf3078..3196985 100644 (file)
Binary files a/LayoutTests/editing/pasteboard/paste-4039777-fix-expected.png and b/LayoutTests/editing/pasteboard/paste-4039777-fix-expected.png differ
index 678782f..da77d38 100644 (file)
@@ -5,7 +5,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of #text > LI > UL > DIV > DIV > BODY > HTML > #document to 5 of #text > LI > UL > DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > LI > UL > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > LI > UL > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > LI > UL > DIV > LI > UL > DIV > DIV > BODY > HTML > #document to 1 of #text > LI > UL > DIV > LI > UL > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
@@ -51,26 +51,30 @@ layer at (0,0) size 800x600
                 RenderBR {BR} at (0,0) size 0x0
                 RenderText {#text} at (0,28) size 16x28
                   text run at (0,28) width 16: "C"
-      RenderBlock {DIV} at (0,364) size 784x188
-        RenderBlock {DIV} at (0,0) size 784x188 [border: (2px solid #FF0000)]
-          RenderBlock {UL} at (2,26) size 780x28
-            RenderListItem {LI} at (40,0) size 740x28
-              RenderListMarker at (-22,0) size 9x28: bullet
-              RenderText {#text} at (723,0) size 17x28
-                text run at (723,0) width 17: "A"
-          RenderBlock {DIV} at (2,78) size 780x56
-            RenderBlock {UL} at (0,0) size 780x56
-              RenderListItem {LI} at (40,0) size 740x56
+      RenderBlock {DIV} at (0,364) size 784x164
+        RenderBlock {DIV} at (0,0) size 784x164 [border: (2px solid #FF0000)]
+          RenderBlock {UL} at (2,26) size 780x112
+            RenderListItem {LI} at (40,0) size 740x112
+              RenderBlock (anonymous) at (0,0) size 740x28
                 RenderListMarker at (-22,0) size 9x28: bullet
-                RenderInline {A} at (0,0) size 16x28 [color=#0000EE]
-                  RenderText {#text} at (718,0) size 16x28
-                    text run at (718,0) width 16: "B"
-                RenderText {#text} at (734,0) size 6x28
-                  text run at (734,0) width 6: " "
-                RenderBR {BR} at (740,22) size 0x0
-                RenderText {#text} at (724,28) size 16x28
-                  text run at (724,28) width 16: "C"
-          RenderBlock (anonymous) at (2,158) size 780x28
-            RenderBR {BR} at (780,0) size 0x28
-          RenderBlock {DIV} at (2,186) size 780x0
-caret: position 1 of child 3 {#text} of child 0 {LI} of child 0 {UL} of child 1 {DIV} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+              RenderBlock {UL} at (0,28) size 740x28
+                RenderListItem {LI} at (40,0) size 700x28
+                  RenderListMarker at (-22,0) size 9x28: white bullet
+                  RenderText {#text} at (683,0) size 17x28
+                    text run at (683,0) width 17: "A"
+              RenderBlock {DIV} at (0,56) size 740x56
+                RenderBlock {UL} at (0,0) size 740x56
+                  RenderListItem {LI} at (40,0) size 700x56
+                    RenderListMarker at (-22,0) size 9x28: white bullet
+                    RenderInline {A} at (0,0) size 16x28 [color=#0000EE]
+                      RenderText {#text} at (678,0) size 16x28
+                        text run at (678,0) width 16: "B"
+                    RenderText {#text} at (694,0) size 6x28
+                      text run at (694,0) width 6: " "
+                    RenderBR {BR} at (700,22) size 0x0
+                    RenderText {#text} at (684,28) size 16x28
+                      text run at (684,28) width 16: "C"
+              RenderBlock (anonymous) at (0,112) size 740x0
+          RenderBlock {DIV} at (2,162) size 780x0
+            RenderBlock {UL} at (0,0) size 780x0
+caret: position 1 of child 3 {#text} of child 0 {LI} of child 0 {UL} of child 1 {DIV} of child 0 {LI} of child 1 {UL} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index bfad6c3..f7e63ba 100644 (file)
@@ -1,5 +1,16 @@
 2007-04-30  Justin Garcia  <justin.garcia@apple.com>
 
+        Reviewed by darin
+
+        <rdar://problem/4875189> List gets deleted when replacing contents
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::doApply): Don't expand
+        to include elements, like lists, when deleting a selection 
+        to replace it.
+
+2007-04-30  Justin Garcia  <justin.garcia@apple.com>
+
         Reviewed by ggaren
         
         Buildfix.  Leave in grammar checking machinery to 
index 2bc996c..dd81e02 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
                        projectRoot = "";
-                       shouldCheckCompatibility = 1;
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
index 0134732..6e50d02 100644 (file)
@@ -481,7 +481,7 @@ void ReplaceSelectionCommand::doApply()
         bool mergeBlocksAfterDelete = isEndOfParagraph(visibleEnd) || isStartOfBlock(visibleStart);
         // FIXME: We should only expand to include fully selected special elements if we are copying a 
         // selection and pasting it on top of itself.
-        deleteSelection(false, mergeBlocksAfterDelete, true);
+        deleteSelection(false, mergeBlocksAfterDelete, true, false);
         visibleStart = endingSelection().visibleStart();
         if (fragment.hasInterchangeNewlineAtStart()) {
             if (isEndOfParagraph(visibleStart) && !isStartOfParagraph(visibleStart)) {