WebCore:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2007 01:36:55 +0000 (01:36 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2007 01:36:55 +0000 (01:36 +0000)
        Reviewed by Darin.

        <rdar://problem/5368833>
        REGRESSION: Pasting a triple-clicked line of quoted text at the top of a message adds an extra, quoted line

        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::insertParagraphSeparator): Added an option for
        using a plain div to hold the new paragraph, instead of a clone of the previous
        block.
        * editing/CompositeEditCommand.h:
        * editing/InsertParagraphSeparatorCommand.cpp: Ditto.
        (WebCore::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand): Ditto.
        (WebCore::InsertParagraphSeparatorCommand::doApply): Ditto.
        * editing/InsertParagraphSeparatorCommand.h:
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply): Use a default block element when creating
        new paragraphs, so that empty paragraphs don't contain the block style of the previous
        one.
        Don't expand collapsed brs at the end of inserted content, this was the root of the bug.
        We'd copy <blockquote>hello<br></blockquote><br class="Apple-interchange-newline">
        and get an extra paragraph.  The removed code used to make sure that if the copied
        selection ends with a paragraph break that is represented in the copied markup by a
        regular br (not an interchange newline br), that that paragraph break appears in the
        pasted content, but shouldMergeEnd, which was introduced after this code was written,
        now takes care of that.
        (WebCore::ReplaceSelectionCommand::shouldRemoveEndBR): Inserted content should always
        displace placeholder brs, even if that inserted content ends with a br.
        * editing/markup.cpp:
        (WebCore::needInterchangeNewlineAfter): This code failed to add an interchange newline
        if the user copied <div>hello</div><br>, only don't add an interchange newline when
        copying ^hello<br>^<br>, because then the copied paragraph break will already be
        represented in the copied markup by a br.
        (WebCore::createMarkup):

LayoutTests:

        Reviewed by Darin.

        <rdar://problem/5368833>
        REGRESSION: Pasting a triple-clicked line of quoted text at the top of a message adds an extra, quoted line

        Tested for behavior that we no longer want to have:
        * editing/pasteboard/quirks-mode-br-2-expected.checksum: Removed.
        * editing/pasteboard/quirks-mode-br-2-expected.png: Removed.
        * editing/pasteboard/quirks-mode-br-2-expected.txt: Removed.
        * editing/pasteboard/quirks-mode-br-2.html: Removed.

        * platform/mac/editing/pasteboard: Added.

        Demonstrates bug:
        * editing/pasteboard/5368833.html: Added.
        * platform/mac/editing/pasteboard/5368833-expected.checksum: Added.
        * platform/mac/editing/pasteboard/5368833-expected.png: Added.
        * platform/mac/editing/pasteboard/5368833-expected.txt: Added.

        Regenerated these expected results to reflect new behavior:
        * editing/pasteboard/paste-text-012-expected.checksum: Removed.
        * editing/pasteboard/paste-text-012-expected.png: Removed.
        * editing/pasteboard/paste-text-012-expected.txt: Removed.
        * editing/pasteboard/paste-text-013-expected.checksum: Removed.
        * editing/pasteboard/paste-text-016-expected.checksum: Removed.
        * editing/pasteboard/paste-text-016-expected.png: Removed.
        * editing/pasteboard/paste-text-016-expected.txt: Removed.
        * platform/mac/editing/pasteboard/paste-text-012-expected.checksum: Added.
        * platform/mac/editing/pasteboard/paste-text-012-expected.png: Added.
        * platform/mac/editing/pasteboard/paste-text-012-expected.txt: Added.
        * platform/mac/editing/pasteboard/paste-text-013-expected.checksum: Added.
        * platform/mac/editing/pasteboard/paste-text-013-expected.png: Added.
        * platform/mac/editing/pasteboard/paste-text-013-expected.txt: Added.
        * platform/mac/editing/pasteboard/paste-text-016-expected.checksum: Added.
        * platform/mac/editing/pasteboard/paste-text-016-expected.png: Added.
        * platform/mac/editing/pasteboard/paste-text-016-expected.txt: Added.

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

28 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/5368833.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-text-012-expected.checksum [deleted file]
LayoutTests/editing/pasteboard/paste-text-013-expected.checksum [deleted file]
LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.checksum [deleted file]
LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.png [deleted file]
LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.txt [deleted file]
LayoutTests/editing/pasteboard/quirks-mode-br-2.html [deleted file]
LayoutTests/platform/mac/editing/pasteboard/5368833-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/5368833-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/5368833-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.png [moved from LayoutTests/editing/pasteboard/paste-text-012-expected.png with 96% similarity]
LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.txt [moved from LayoutTests/editing/pasteboard/paste-text-012-expected.txt with 79% similarity]
LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/paste-text-016-expected.checksum [moved from LayoutTests/editing/pasteboard/paste-text-016-expected.checksum with 100% similarity]
LayoutTests/platform/mac/editing/pasteboard/paste-text-016-expected.png [moved from LayoutTests/editing/pasteboard/paste-text-016-expected.png with 100% similarity]
LayoutTests/platform/mac/editing/pasteboard/paste-text-016-expected.txt [moved from LayoutTests/editing/pasteboard/paste-text-016-expected.txt with 92% similarity]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/CompositeEditCommand.cpp
WebCore/editing/CompositeEditCommand.h
WebCore/editing/InsertParagraphSeparatorCommand.cpp
WebCore/editing/InsertParagraphSeparatorCommand.h
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/markup.cpp

index b3b9792df3fee3f53f453965e48210ab9488cef4..853a41be3b780b03ee2c8639feaa3e2aaf259020 100644 (file)
@@ -1,3 +1,42 @@
+2007-08-30  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin.
+        
+        <rdar://problem/5368833> 
+        REGRESSION: Pasting a triple-clicked line of quoted text at the top of a message adds an extra, quoted line
+        
+        Tested for behavior that we no longer want to have:
+        * editing/pasteboard/quirks-mode-br-2-expected.checksum: Removed.
+        * editing/pasteboard/quirks-mode-br-2-expected.png: Removed.
+        * editing/pasteboard/quirks-mode-br-2-expected.txt: Removed.
+        * editing/pasteboard/quirks-mode-br-2.html: Removed.
+        
+        * platform/mac/editing/pasteboard: Added.
+        
+        Demonstrates bug:
+        * editing/pasteboard/5368833.html: Added.
+        * platform/mac/editing/pasteboard/5368833-expected.checksum: Added.
+        * platform/mac/editing/pasteboard/5368833-expected.png: Added.
+        * platform/mac/editing/pasteboard/5368833-expected.txt: Added.
+        
+        Regenerated these expected results to reflect new behavior:
+        * editing/pasteboard/paste-text-012-expected.checksum: Removed.
+        * editing/pasteboard/paste-text-012-expected.png: Removed.
+        * editing/pasteboard/paste-text-012-expected.txt: Removed.
+        * editing/pasteboard/paste-text-013-expected.checksum: Removed.
+        * editing/pasteboard/paste-text-016-expected.checksum: Removed.
+        * editing/pasteboard/paste-text-016-expected.png: Removed.
+        * editing/pasteboard/paste-text-016-expected.txt: Removed.
+        * platform/mac/editing/pasteboard/paste-text-012-expected.checksum: Added.
+        * platform/mac/editing/pasteboard/paste-text-012-expected.png: Added.
+        * platform/mac/editing/pasteboard/paste-text-012-expected.txt: Added.
+        * platform/mac/editing/pasteboard/paste-text-013-expected.checksum: Added.
+        * platform/mac/editing/pasteboard/paste-text-013-expected.png: Added.
+        * platform/mac/editing/pasteboard/paste-text-013-expected.txt: Added.
+        * platform/mac/editing/pasteboard/paste-text-016-expected.checksum: Added.
+        * platform/mac/editing/pasteboard/paste-text-016-expected.png: Added.
+        * platform/mac/editing/pasteboard/paste-text-016-expected.txt: Added.
+
 2007-08-30  Mitz Pettel  <mitz@webkit.org>
 
         Reviewed by Dave Hyatt.
diff --git a/LayoutTests/editing/pasteboard/5368833.html b/LayoutTests/editing/pasteboard/5368833.html
new file mode 100644 (file)
index 0000000..5adb2c1
--- /dev/null
@@ -0,0 +1,21 @@
+<style>
+blockquote {
+    color: blue;
+    border-left: 2px solid blue;
+    padding-left: 5px;
+    margin: 0px;
+}
+</style>
+
+<p>We copy and paste a blockquoted paragraph plus a paragraph break.  The paragraph break shouldn't be inside the blockquote on paste.  You should see 'hello' (blockquoted), empty paragraph, 'hello' (blockquoted), empty paragraph.</p>
+<div id="div" contenteditable="true"><br><blockquote id="blockquote" type="cite">hello<br></blockquote><br></div>
+
+<script>
+div = document.getElementById("div");
+blockquote = document.getElementById("blockquote");
+sel = window.getSelection();
+sel.setBaseAndExtent(blockquote, 0, div, 2);
+document.execCommand("Copy");
+sel.setPosition(div, 0);
+document.execCommand("Paste");
+</script>
diff --git a/LayoutTests/editing/pasteboard/paste-text-012-expected.checksum b/LayoutTests/editing/pasteboard/paste-text-012-expected.checksum
deleted file mode 100644 (file)
index 22b8f1d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-cda9e0569c21b21dc9754f14ad4b9d35
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/paste-text-013-expected.checksum b/LayoutTests/editing/pasteboard/paste-text-013-expected.checksum
deleted file mode 100644 (file)
index 9507708..0000000
+++ /dev/null
@@ -1 +0,0 @@
-79fecc450db924122caf2118082956fe
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.checksum b/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.checksum
deleted file mode 100644 (file)
index 6b61025..0000000
+++ /dev/null
@@ -1 +0,0 @@
-3deb7831806c061de3c72727f91df4c6
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.png b/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.png
deleted file mode 100644 (file)
index e40824f..0000000
Binary files a/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.png and /dev/null differ
diff --git a/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.txt b/LayoutTests/editing/pasteboard/quirks-mode-br-2-expected.txt
deleted file mode 100644 (file)
index 706c2a4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-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: 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 784x584
-      RenderBlock {P} at (0,0) size 784x54
-        RenderText {#text} at (0,0) size 779x54
-          text run at (0,0) width 779: "This is a test to make sure that the final <br> in an incoming fragment is interpretted strictly in quirks mode (where brs at the"
-          text run at (0,18) width 184: "end of blocks are collapsed). "
-          text run at (184,18) width 545: "This test used to fail because placeholders where the paste occured were removed after"
-          text run at (0,36) width 175: "incoming brs were handled."
-      RenderBlock {P} at (0,70) size 784x18
-        RenderText {#text} at (0,0) size 385x18
-          text run at (0,0) width 385: "There should be two blank lines in the editable region below."
-      RenderBlock {DIV} at (0,104) size 784x36
-        RenderBR {BR} at (0,0) size 0x18
-        RenderBR {BR} at (0,18) size 0x18
-caret: position 0 of child 1 {BR} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/quirks-mode-br-2.html b/LayoutTests/editing/pasteboard/quirks-mode-br-2.html
deleted file mode 100644 (file)
index ee5e300..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<script>
-if (window.layoutTestController)
-     layoutTestController.dumpEditingCallbacks();
-</script>
-<p>This is a test to make sure that the final &lt;br&gt; in an incoming fragment is interpretted strictly in quirks mode (where brs at the end of blocks are collapsed).  This test used to fail because placeholders where the paste occured were removed after incoming brs were handled.</p>
-
-<p>There should be two blank lines in the editable region below.</p>
-<div id="test" contenteditable="true"><br class="webkit-block-placeholder"></div>
-
-<script>
-var s = window.getSelection();
-var e = document.getElementById("test");
-
-s.setPosition(e, 0);
-document.execCommand("InsertHTML", false, "<br>");
-</script>
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.checksum b/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.checksum
new file mode 100644 (file)
index 0000000..dec11a4
--- /dev/null
@@ -0,0 +1 @@
+1b17d32e2c37d90ab63d9974206fecbc
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.png b/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.png
new file mode 100644 (file)
index 0000000..37e0dd6
Binary files /dev/null and b/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.txt b/LayoutTests/platform/mac/editing/pasteboard/5368833-expected.txt
new file mode 100644 (file)
index 0000000..6bf131e
--- /dev/null
@@ -0,0 +1,27 @@
+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 784x36
+        RenderText {#text} at (0,0) size 784x36
+          text run at (0,0) width 435: "We copy and paste a blockquoted paragraph plus a paragraph break. "
+          text run at (435,0) width 349: "The paragraph break shouldn't be inside the blockquote"
+          text run at (0,18) width 60: "on paste. "
+          text run at (60,18) width 600: "You should see 'hello' (blockquoted), empty paragraph, 'hello' (blockquoted), empty paragraph."
+      RenderBlock {DIV} at (0,52) size 784x72
+        RenderBlock {BLOCKQUOTE} at (0,0) size 784x18 [color=#0000FF] [border: (2px solid #0000FF)]
+          RenderText {#text} at (7,0) size 31x18
+            text run at (7,0) width 31: "hello"
+          RenderBR {BR} at (38,14) size 0x0
+        RenderBlock (anonymous) at (0,18) size 784x0
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderInline {FONT} at (0,0) size 0x18 [color=#0000FF]
+            RenderBR {BR} at (0,0) size 0x18
+        RenderBlock {BLOCKQUOTE} at (0,36) size 784x18 [color=#0000FF] [border: (2px solid #0000FF)]
+          RenderText {#text} at (7,0) size 31x18
+            text run at (7,0) width 31: "hello"
+          RenderBR {BR} at (38,14) size 0x0
+        RenderBlock (anonymous) at (0,54) size 784x18
+          RenderBR {BR} at (0,0) size 0x18
+caret: position 0 of child 0 {BR} of child 0 {FONT} of child 1 {DIV} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.checksum b/LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.checksum
new file mode 100644 (file)
index 0000000..9ceb435
--- /dev/null
@@ -0,0 +1 @@
+55457e75fe5c22964d712a4b78cd01f9
\ No newline at end of file
similarity index 96%
rename from LayoutTests/editing/pasteboard/paste-text-012-expected.png
rename to LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.png
index e93919a43c416ec82e6003d52dc2fc1c57fa94df..6b727499cf6bf9bd1476aa5665d80191ef4b5765 100644 (file)
Binary files a/LayoutTests/editing/pasteboard/paste-text-012-expected.png and b/LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.png differ
similarity index 79%
rename from LayoutTests/editing/pasteboard/paste-text-012-expected.txt
rename to LayoutTests/platform/mac/editing/pasteboard/paste-text-012-expected.txt
index 2aa43785636b12beb1175b7eb70120d016ce070d..db34f090623dc36750b28b87f79d5b9b8b84bd2a 100644 (file)
@@ -7,7 +7,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-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 > DIV > SPAN > DIV > BODY > HTML > #document to 0 of BLOCKQUOTE > DIV > DIV > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > DIV > SPAN > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > SPAN > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
@@ -30,17 +30,17 @@ layer at (0,0) size 800x600
           RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
             RenderText {#text} at (0,0) size 32x28
               text run at (0,0) width 32: "foo"
-      RenderBlock {DIV} at (0,140) size 784x184 [border: (2px solid #FF0000)]
+      RenderBlock {DIV} at (0,140) size 784x160 [border: (2px solid #FF0000)]
         RenderBlock (anonymous) at (14,14) size 756x0
           RenderInline {SPAN} at (0,0) size 0x0
-        RenderBlock (anonymous) at (14,14) size 756x156
-          RenderBlock {DIV} at (0,0) size 756x156 [border: (2px solid #FF0000)]
+        RenderBlock (anonymous) at (14,14) size 756x132
+          RenderBlock {DIV} at (0,0) size 756x132 [border: (2px solid #FF0000)]
             RenderBlock {DIV} at (14,38) size 728x80
               RenderBlock {BLOCKQUOTE} at (40,0) size 648x28
                 RenderText {#text} at (0,0) size 32x28
                   text run at (0,0) width 32: "foo"
-              RenderBlock {BLOCKQUOTE} at (40,52) size 648x28
+              RenderBlock {DIV} at (0,52) size 728x28
                 RenderBR {BR} at (0,0) size 0x28
-        RenderBlock (anonymous) at (14,170) size 756x0
+        RenderBlock (anonymous) at (14,146) size 756x0
           RenderInline {SPAN} at (0,0) size 0x0
-caret: position 0 of child 0 {BR} of child 1 {BLOCKQUOTE} of child 0 {DIV} of child 0 {DIV} of child 0 {SPAN} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {BR} of child 1 {DIV} of child 0 {DIV} of child 0 {DIV} of child 0 {SPAN} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.checksum b/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.checksum
new file mode 100644 (file)
index 0000000..00e72e7
--- /dev/null
@@ -0,0 +1 @@
+72aab1ae0c4d75a0064e90d8b699616d
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.png b/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.png
new file mode 100644 (file)
index 0000000..49d9a68
Binary files /dev/null and b/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.png differ
diff --git a/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.txt b/LayoutTests/platform/mac/editing/pasteboard/paste-text-013-expected.txt
new file mode 100644 (file)
index 0000000..384cb18
--- /dev/null
@@ -0,0 +1,47 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 10 of BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > 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 784x584
+      RenderBlock (anonymous) at (0,0) size 784x54
+        RenderText {#text} at (0,0) size 85x18
+          text run at (0,0) width 85: "See this bug: "
+        RenderInline {A} at (0,0) size 167x18 [color=#0000EE]
+          RenderText {#text} at (85,0) size 167x18
+            text run at (85,0) width 167: "<rdar://problem/3918712>"
+        RenderText {#text} at (252,0) size 781x54
+          text run at (252,0) width 488: " \"Paste as Quotation\" in Mail just pastes (<blockquote> tag seems to be lost). "
+          text run at (0,18) width 781: "Should see one box with blockquoted \"foo\" text, followed by another box with an \"x\" (not in a blockquote) and \"foo\" (in a "
+          text run at (0,36) width 79: "blockquote)."
+      RenderBlock {DIV} at (0,54) size 784x24
+      RenderBlock {DIV} at (0,78) size 784x104 [border: (2px solid #FF0000)]
+        RenderBlock {DIV} at (14,38) size 756x28
+          RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+            RenderText {#text} at (0,0) size 32x28
+              text run at (0,0) width 32: "foo"
+      RenderBlock {DIV} at (0,182) size 784x56 [border: (2px solid #FF0000)]
+        RenderText {#text} at (14,14) size 12x28
+          text run at (14,14) width 12: "x"
+      RenderBlock {DIV} at (0,238) size 784x132 [border: (2px solid #FF0000)]
+        RenderBlock {DIV} at (14,38) size 756x80
+          RenderBlock {BLOCKQUOTE} at (40,0) size 676x28
+            RenderText {#text} at (0,0) size 32x28
+              text run at (0,0) width 32: "foo"
+          RenderBlock {DIV} at (0,52) size 756x28
+            RenderBR {BR} at (0,0) size 0x28
+caret: position 0 of child 0 {BR} of child 1 {DIV} of child 0 {DIV} of child 8 {DIV} of child 1 {BODY} of child 0 {HTML} of document
similarity index 92%
rename from LayoutTests/editing/pasteboard/paste-text-016-expected.txt
rename to LayoutTests/platform/mac/editing/pasteboard/paste-text-016-expected.txt
index 51491abe5591f8a725673ac62326898a2414aa28..70334f59826c47c438a45beaea0e20127b0eb3ef 100644 (file)
@@ -20,7 +20,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 2 of P > DIV > DIV > BODY > HTML > #document to 2 of P > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of P > P > DIV > DIV > BODY > HTML > #document to 0 of P > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > P > DIV > DIV > BODY > HTML > #document to 0 of DIV > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
@@ -50,7 +50,7 @@ layer at (0,0) size 800x600
             RenderBlock {P} at (0,28) size 756x28
               RenderText {#text} at (0,0) size 130x28
                 text run at (0,0) width 130: "***TEST***"
-            RenderBlock {P} at (0,56) size 756x28
+            RenderBlock {DIV} at (0,56) size 756x28
               RenderBR {BR} at (0,0) size 0x28
             RenderBlock (anonymous) at (0,84) size 756x28
               RenderText {#text} at (0,0) size 128x28
@@ -65,4 +65,4 @@ layer at (0,0) size 800x600
               text run at (0,0) width 6: " "
           RenderBlock {P} at (14,182) size 756x28
             RenderBR {BR} at (0,0) size 0x28
-caret: position 0 of child 0 {BR} of child 3 {P} of child 0 {P} of child 1 {DIV} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 0 {BR} of child 3 {DIV} of child 0 {P} of child 1 {DIV} of child 7 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 90780147d0fc0331db759d00d9eb9fd7e18a1487..ef1d50afc649852b3f79d58e47ca170e34f130b4 100644 (file)
@@ -1,3 +1,39 @@
+2007-08-29  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by Darin.
+
+        <rdar://problem/5368833> 
+        REGRESSION: Pasting a triple-clicked line of quoted text at the top of a message adds an extra, quoted line
+
+        * editing/CompositeEditCommand.cpp:
+        (WebCore::CompositeEditCommand::insertParagraphSeparator): Added an option for
+        using a plain div to hold the new paragraph, instead of a clone of the previous
+        block.
+        * editing/CompositeEditCommand.h:
+        * editing/InsertParagraphSeparatorCommand.cpp: Ditto.
+        (WebCore::InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand): Ditto.
+        (WebCore::InsertParagraphSeparatorCommand::doApply): Ditto.
+        * editing/InsertParagraphSeparatorCommand.h:
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::doApply): Use a default block element when creating
+        new paragraphs, so that empty paragraphs don't contain the block style of the previous
+        one.
+        Don't expand collapsed brs at the end of inserted content, this was the root of the bug.
+        We'd copy <blockquote>hello<br></blockquote><br class="Apple-interchange-newline">
+        and get an extra paragraph.  The removed code used to make sure that if the copied 
+        selection ends with a paragraph break that is represented in the copied markup by a 
+        regular br (not an interchange newline br), that that paragraph break appears in the 
+        pasted content, but shouldMergeEnd, which was introduced after this code was written, 
+        now takes care of that.
+        (WebCore::ReplaceSelectionCommand::shouldRemoveEndBR): Inserted content should always
+        displace placeholder brs, even if that inserted content ends with a br.
+        * editing/markup.cpp:
+        (WebCore::needInterchangeNewlineAfter): This code failed to add an interchange newline
+        if the user copied <div>hello</div><br>, only don't add an interchange newline when
+        copying ^hello<br>^<br>, because then the copied paragraph break will already be 
+        represented in the copied markup by a br.
+        (WebCore::createMarkup):
+
 2007-08-30  David Harrison  <harrison@apple.com>
 
         Reviewed by Darin.
index 264df56b6de3786cb48f55b8ed02f4a1ae38d2e6..1d415af7f30a198a5f8d39195bb3aef58024cfc0 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
-                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index 0e16e48e718bd40b1ddfcbb361ba5cdea802d402..b2c67c00fbe1b8e9888f8f234336a264add8afe8 100644 (file)
@@ -117,9 +117,9 @@ void CompositeEditCommand::removeStyledElement(Element* element)
     applyCommandToComposite(new ApplyStyleCommand(element, true));
 }
 
-void CompositeEditCommand::insertParagraphSeparator()
+void CompositeEditCommand::insertParagraphSeparator(bool useDefaultParagraphElement)
 {
-    applyCommandToComposite(new InsertParagraphSeparatorCommand(document()));
+    applyCommandToComposite(new InsertParagraphSeparatorCommand(document(), useDefaultParagraphElement));
 }
 
 void CompositeEditCommand::insertNodeBefore(Node* insertChild, Node* refChild)
index 5dff09e71d81c7095cf689acd4f0b582e04b2e2e..6597720bde4c9617e9c10a32f43ece52f666a27d 100644 (file)
@@ -58,7 +58,7 @@ protected:
     void insertNodeAfter(Node* insertChild, Node* refChild);
     void insertNodeAt(Node* insertChild, const Position&);
     void insertNodeBefore(Node* insertChild, Node* refChild);
-    void insertParagraphSeparator();
+    void insertParagraphSeparator(bool useDefaultParagraphElement = false);
     void insertTextIntoNode(Text* node, int offset, const String& text);
     void joinTextNodes(Text*, Text*);
     void rebalanceWhitespace();
index 5f161b8ad0b4d34dd56bf44d03cf71c1bf05bff2..cd7682824500dbca84f2c2e6c489caa565a02e84 100644 (file)
@@ -42,8 +42,9 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document) 
-    : CompositeEditCommand(document)
+InsertParagraphSeparatorCommand::InsertParagraphSeparatorCommand(Document *document, bool useDefaultParagraphElement) 
+    : CompositeEditCommand(document),
+      m_useDefaultParagraphElement(useDefaultParagraphElement)
 {
 }
 
@@ -136,7 +137,9 @@ void InsertParagraphSeparatorCommand::doApply()
     if (startBlock == startBlock->rootEditableElement()) {
         blockToInsert = static_pointer_cast<Node>(createDefaultParagraphElement(document()));
         nestNewBlock = true;
-    } else
+    } else if (m_useDefaultParagraphElement)
+        blockToInsert = static_pointer_cast<Node>(createDefaultParagraphElement(document()));
+    else
         blockToInsert = startBlock->cloneNode(false);
     
     //---------------------------------------------------------------------
index 3f889319c0f5ec06b72c5f6bef561d968ec82372..d866ed5fd8fdbb14b3bddb6574a1331bb297ee3c 100644 (file)
@@ -32,7 +32,7 @@ namespace WebCore {
 
 class InsertParagraphSeparatorCommand : public CompositeEditCommand {
 public:
-    InsertParagraphSeparatorCommand(Document*);
+    InsertParagraphSeparatorCommand(Document*, bool useDefaultParagraphElement = false);
 
     virtual void doApply();
 
@@ -43,6 +43,8 @@ private:
     virtual bool preservesTypingStyle() const;
 
     RefPtr<CSSMutableStyleDeclaration> m_style;
+    
+    bool m_useDefaultParagraphElement;
 };
 
 }
index 88ba297fb142a0827f6819f2f2a073ace39558c7..aec25d942967a9bb905c07a24e577153be7a78bd 100644 (file)
@@ -410,6 +410,8 @@ void ReplaceSelectionCommand::removeRedundantStyles(Node* mailBlockquoteEnclosin
 
         // Remove empty style spans.
         if (isStyleSpan(element) && !element->hasChildNodes()) {
+            if (m_firstNodeInserted == m_lastLeafInserted && m_firstNodeInserted == element)
+                m_firstNodeInserted = 0;
             if (m_firstNodeInserted == element)
                 m_firstNodeInserted = element->traverseNextSibling();
             if (m_lastLeafInserted == element)
@@ -611,6 +613,9 @@ void ReplaceSelectionCommand::doApply()
     
     removeRedundantStyles(mailBlockquoteEnclosingSelectionStart);
     
+    if (!m_firstNodeInserted)
+        return;
+    
     endOfInsertedContent = positionAtEndOfInsertedContent();
     startOfInsertedContent = positionAtStartOfInsertedContent();
     
@@ -652,7 +657,9 @@ void ReplaceSelectionCommand::doApply()
         if (selectionEndWasEndOfParagraph || !isEndOfParagraph(endOfInsertedContent) || next.isNull()) {
             if (!isStartOfParagraph(endOfInsertedContent)) {
                 setEndingSelection(endOfInsertedContent);
-                insertParagraphSeparator();
+                // Use a default paragraph element (a plain div) for the empty paragraph, using the last paragraph
+                // block's style seems to annoy users.
+                insertParagraphSeparator(true);
 
                 // Select up to the paragraph separator that was added.
                 lastPositionToSelect = endingSelection().visibleStart().deepEquivalent();
@@ -662,14 +669,6 @@ void ReplaceSelectionCommand::doApply()
             // Select up to the beginning of the next paragraph.
             lastPositionToSelect = next.deepEquivalent().downstream();
         }
-
-    } else if (m_lastLeafInserted->hasTagName(brTag)) {
-        // We want to honor the last incoming line break, so, if it will collapse away because of quirks mode, 
-        // add an extra one.
-        // FIXME: This will expand a br inside a block: <div><br></div>
-        // FIXME: Should we expand all incoming brs that collapse because of quirks mode?
-        if (!document()->inStrictMode() && isEndOfBlock(endOfInsertedContent) && !isStartOfParagraph(endOfInsertedContent))
-            insertNodeBeforeAndUpdateNodesInserted(createBreakElement(document()).get(), m_lastLeafInserted.get());
             
     } else if (shouldMergeEnd(selectionEndWasEndOfParagraph)) {
         // Bail to avoid infinite recursion.
@@ -759,7 +758,7 @@ bool ReplaceSelectionCommand::shouldRemoveEndBR(Node* endBR)
         !document()->inStrictMode() && isEndOfBlock(visiblePos) && !isStartOfParagraph(visiblePos) ||
         // A br that was originally holding a line open should be displaced by inserted content or turned into a line break.
         // A br that was originally acting as a line break should still be acting as a line break, not as a placeholder.
-        isStartOfParagraph(visiblePos) && isEndOfParagraph(visiblePos) && !m_lastLeafInserted->hasTagName(brTag);
+        isStartOfParagraph(visiblePos) && isEndOfParagraph(visiblePos);
 }
 
 void ReplaceSelectionCommand::completeHTMLReplacement(const Position &lastPositionToSelect)
index 2a4282417a8bfd50233d9b99606ff9e245abb198..60e3b7786d5054f4be7bc93bd4c309a7d1187924 100644 (file)
@@ -422,7 +422,10 @@ static void completeURLs(Node* node, const String& baseURL)
 static bool needInterchangeNewlineAfter(const VisiblePosition& v)
 {
     VisiblePosition next = v.next();
-    return isEndOfParagraph(v) && isStartOfParagraph(next) && !next.deepEquivalent().upstream().node()->hasTagName(brTag);
+    Node* upstreamNode = next.deepEquivalent().upstream().node();
+    Node* downstreamNode = v.deepEquivalent().downstream().node();
+    // Add an interchange newline if a paragraph break is selected and a br won't already be added to the markup to represent it.
+    return isEndOfParagraph(v) && isStartOfParagraph(next) && !(upstreamNode->hasTagName(brTag) && upstreamNode == downstreamNode);
 }
 
 static PassRefPtr<CSSMutableStyleDeclaration> styleFromMatchedRulesAndInlineDecl(Node* node)
@@ -663,6 +666,7 @@ DeprecatedString createMarkup(const Range* range, Vector<Node*>* nodes, EAnnotat
         }
     }
 
+    // FIXME: The interchange newline should be placed in the block that it's in, not after all of the content, unconditionally.
     if (annotate && needInterchangeNewlineAfter(visibleEnd.previous()))
         markups.append(interchangeNewlineString);