LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jul 2006 22:01:54 +0000 (22:01 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jul 2006 22:01:54 +0000 (22:01 +0000)
        Reviewed by levi

        <rdar://problem/4242293>
        Poor paste fidelity of http://www.google.com/

        Removed one of the two extraneous newlines that are introduced on paste:
        * editing/pasteboard/paste-table-003-expected.checksum:
        * editing/pasteboard/paste-table-003-expected.png:
        * editing/pasteboard/paste-table-003-expected.txt:

        Fewer pastes remove nodes containing the selection b/c of
        the changes to interchange newlines:
        * editing/pasteboard/paste-line-endings-007-expected.txt:
        * editing/pasteboard/paste-line-endings-008-expected.txt:
        * editing/pasteboard/paste-line-endings-009-expected.txt:

        Added:
        * editing/pasteboard/4242293-1-expected.checksum: Added.
        * editing/pasteboard/4242293-1-expected.png: Added.
        * editing/pasteboard/4242293-1-expected.txt: Added.
        * editing/pasteboard/4242293-1.html: Added.
        * editing/pasteboard/4242293-expected.checksum: Added.
        * editing/pasteboard/4242293-expected.png: Added.
        * editing/pasteboard/4242293-expected.txt: Added.
        * editing/pasteboard/4242293.html: Added.

WebCore:

        Reviewed by levi

        More changes for:
        <rdar://problem/4242293>
        Poor paste fidelity of http://www.google.com/

        * editing/markup.cpp:
        (WebCore::needInterchangeNewlineAfter): Added.
        (WebCore::createMarkup):
        Only add an interchangeNewline if we're annotating for interchange.  Can't test
        this until we expose createMarkup in non-annotate mode (I'd expose Range::toHTML).
        Remove the FIXME about prepending the interchangeNewline before creating the rest
        of the markup.  Its correct to surround the interchangeNewline in ancestors of the
        adjusted startNode.
        Fixed the check to see if an interchangeNewline is needed (!inSameBlock).  This would
        add an interchangeNewline for a selection that started before a table.
        Removed the workaround for the bug where markup for a table was not included when
        selecting the contents of a table, since this change fixes the general problem of
        markup for ancestors of the startNode being left out.
        Don't leave out ancestors of the startNode as we leave their subtrees.  Execute the
        code to include them even if we closed ancestors in the ancestorsToClose list.

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/4242293-1-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293-1-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293-1.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/4242293.html [new file with mode: 0644]
LayoutTests/editing/pasteboard/paste-line-endings-007-expected.txt
LayoutTests/editing/pasteboard/paste-line-endings-008-expected.txt
LayoutTests/editing/pasteboard/paste-line-endings-009-expected.txt
LayoutTests/editing/pasteboard/paste-table-003-expected.checksum
LayoutTests/editing/pasteboard/paste-table-003-expected.png
LayoutTests/editing/pasteboard/paste-table-003-expected.txt
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/editing/markup.cpp

index 6ae93e7184cce4f719d5f55dcc82412cadafb9e5..b6273010710758deeac8758d6e4f6fc460ee6ccd 100644 (file)
@@ -1,3 +1,31 @@
+2006-07-27  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        <rdar://problem/4242293>
+        Poor paste fidelity of http://www.google.com/
+
+        Removed one of the two extraneous newlines that are introduced on paste:
+        * editing/pasteboard/paste-table-003-expected.checksum:
+        * editing/pasteboard/paste-table-003-expected.png:
+        * editing/pasteboard/paste-table-003-expected.txt:
+        
+        Fewer pastes remove nodes containing the selection b/c of 
+        the changes to interchange newlines:
+        * editing/pasteboard/paste-line-endings-007-expected.txt:
+        * editing/pasteboard/paste-line-endings-008-expected.txt:
+        * editing/pasteboard/paste-line-endings-009-expected.txt:
+        
+        Added:
+        * editing/pasteboard/4242293-1-expected.checksum: Added.
+        * editing/pasteboard/4242293-1-expected.png: Added.
+        * editing/pasteboard/4242293-1-expected.txt: Added.
+        * editing/pasteboard/4242293-1.html: Added.
+        * editing/pasteboard/4242293-expected.checksum: Added.
+        * editing/pasteboard/4242293-expected.png: Added.
+        * editing/pasteboard/4242293-expected.txt: Added.
+        * editing/pasteboard/4242293.html: Added.
+
 2006-07-28  Alexey Proskuryakov  <ap@nypop.com>
 
         Rolling out http://bugzilla.opendarwin.org/show_bug.cgi?id=6010 because of failing layout tests.
diff --git a/LayoutTests/editing/pasteboard/4242293-1-expected.checksum b/LayoutTests/editing/pasteboard/4242293-1-expected.checksum
new file mode 100644 (file)
index 0000000..788747f
--- /dev/null
@@ -0,0 +1 @@
+9171d82f2d374821d6df6faed806f23a
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/4242293-1-expected.png b/LayoutTests/editing/pasteboard/4242293-1-expected.png
new file mode 100644 (file)
index 0000000..940c929
Binary files /dev/null and b/LayoutTests/editing/pasteboard/4242293-1-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/4242293-1-expected.txt b/LayoutTests/editing/pasteboard/4242293-1-expected.txt
new file mode 100644 (file)
index 0000000..c425eff
--- /dev/null
@@ -0,0 +1,48 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > 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: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+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: shouldInsertNode:#document-fragment replacingDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > 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 {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 777x36
+          text run at (0,0) width 777: "This tests to make sure that createMarkup puts an interchange newline on the pasteboard for a selection ending at the end of"
+          text run at (0,18) width 54: "a block. "
+          text run at (54,18) width 371: "Both regions below should have contents that are identical."
+      RenderBlock {DIV} at (0,52) size 784x54
+        RenderBlock {DIV} at (0,0) size 784x36
+          RenderBlock {DIV} at (0,0) size 784x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+          RenderBlock (anonymous) at (0,18) size 784x18
+            RenderText {#text} at (0,0) size 20x18
+              text run at (0,0) width 20: "bar"
+        RenderBlock (anonymous) at (0,36) size 784x18
+          RenderText {#text} at (0,0) size 22x18
+            text run at (0,0) width 22: "baz"
+      RenderBlock {DIV} at (0,106) size 784x54
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+        RenderBlock {DIV} at (0,18) size 784x18
+          RenderText {#text} at (0,0) size 20x18
+            text run at (0,0) width 20: "bar"
+        RenderBlock (anonymous) at (0,36) size 784x18
+          RenderText {#text} at (0,0) size 22x18
+            text run at (0,0) width 22: "baz"
+caret: position 3 of child 2 {#text} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/4242293-1.html b/LayoutTests/editing/pasteboard/4242293-1.html
new file mode 100644 (file)
index 0000000..95e6e46
--- /dev/null
@@ -0,0 +1,19 @@
+<p>This tests to make sure that createMarkup puts an interchange newline on the pasteboard for a selection ending at the end of a block.  Both regions below should have contents that are identical.</p>
+
+<div id="copy" contenteditable="true"><div><div>foo</div>bar</div>baz</div>
+<div id="paste" contenteditable="true">foo</div>
+
+<script>
+var sel = window.getSelection();
+var e = document.getElementById("copy");
+sel.setPosition(e, 0);
+sel.modify("move", "forward", "word");
+sel.modify("extend", "forward", "line");
+sel.modify("extend", "forward", "line");
+document.execCommand("Copy");
+
+e = document.getElementById("paste");
+sel.setPosition(e, 0);
+sel.modify("move", "forward", "word");
+document.execCommand("Paste");
+</script>
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/4242293-expected.checksum b/LayoutTests/editing/pasteboard/4242293-expected.checksum
new file mode 100644 (file)
index 0000000..6cba87d
--- /dev/null
@@ -0,0 +1 @@
+2d5de629ab57d3f03bd0bc02a0dee5bb
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/4242293-expected.png b/LayoutTests/editing/pasteboard/4242293-expected.png
new file mode 100644 (file)
index 0000000..621d0cd
Binary files /dev/null and b/LayoutTests/editing/pasteboard/4242293-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/4242293-expected.txt b/LayoutTests/editing/pasteboard/4242293-expected.txt
new file mode 100644 (file)
index 0000000..f550a71
--- /dev/null
@@ -0,0 +1,50 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: 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 3 of #text > DIV > BODY > HTML > #document to 3 of #text > 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 {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 782x36
+          text run at (0,0) width 782: "This tests for a bug in createMarkup (markup for ancestors of the start of the selection wasn't being added to the pasteboard)."
+          text run at (0,18) width 338: "You should see the same thing in both regions below."
+      RenderBlock {P} at (0,52) size 784x18
+        RenderInline {B} at (0,0) size 438x18
+          RenderText {#text} at (0,0) size 438x18
+            text run at (0,0) width 438: "This demonstrates a bug: 'foo' is pulled out of its bordered block."
+      RenderBlock {DIV} at (0,86) size 784x73
+        RenderBlock {DIV} at (5,0) size 774x50 [border: (1px solid #FF0000)]
+          RenderBlock (anonymous) at (1,1) size 772x18
+            RenderText {#text} at (0,0) size 21x18
+              text run at (0,0) width 21: "foo"
+          RenderBlock {DIV} at (6,24) size 762x20 [border: (1px solid #0000FF)]
+            RenderText {#text} at (1,1) size 20x18
+              text run at (1,1) width 20: "bar"
+        RenderBlock (anonymous) at (0,55) size 784x18
+          RenderText {#text} at (0,0) size 22x18
+            text run at (0,0) width 22: "baz"
+      RenderBlock {DIV} at (0,159) size 784x78
+        RenderBlock (anonymous) at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 21x18
+            text run at (0,0) width 21: "foo"
+        RenderBlock {DIV} at (5,23) size 774x32 [border: (1px solid #FF0000)]
+          RenderBlock {DIV} at (6,6) size 762x20 [border: (1px solid #0000FF)]
+            RenderText {#text} at (1,1) size 20x18
+              text run at (1,1) width 20: "bar"
+        RenderBlock (anonymous) at (0,60) size 784x18
+          RenderText {#text} at (0,0) size 22x18
+            text run at (0,0) width 22: "baz"
+caret: position 3 of child 2 {#text} of child 6 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/4242293.html b/LayoutTests/editing/pasteboard/4242293.html
new file mode 100644 (file)
index 0000000..4f3800d
--- /dev/null
@@ -0,0 +1,13 @@
+<p>This tests for a bug in createMarkup (markup for ancestors of the start of the selection wasn't being added to the pasteboard).  You should see the same thing in both regions below.</p>
+<p><b>This demonstrates a bug: 'foo' is pulled out of its bordered block.</b></p>
+<div id="copy" contenteditable="true"><div style="margin: 5px; border: 1px solid red;">foo<div style="margin: 5px; border: 1px solid blue;">bar</div></div>baz</div>
+
+<div id="paste" contenteditable="true"></div>
+
+<script>
+window.getSelection().setPosition(document.getElementById("copy"));
+document.execCommand("SelectAll");
+document.execCommand("Copy");
+window.getSelection().setPosition(document.getElementById("paste"));
+document.execCommand("Paste");
+</script>
\ No newline at end of file
index 0fbed13a7e72d58312c25584d5df04d839872656..74e8c39e0959b2fdcc2db2da75a2d3000bedcb6f 100644 (file)
@@ -12,7 +12,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 9 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
index b251f3e6dd0cd24aed5907816a238609e564f25a..53ccd1518d332860b8c5117e6f71f1b650588a43 100644 (file)
@@ -12,7 +12,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
index 7b7ecfe968ecd5bbb59c8547702e537a9e805a97..41ff846d028a8422a2bc713dbacd2a10c3822100 100644 (file)
@@ -12,7 +12,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 8 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 8 of #text > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
index 0e18a972aa2af14604c5f1f4bf745d16a0fd9cac..bdc2ae7d07564a413ee0162483dc5d3a3b27db98 100644 (file)
@@ -1 +1 @@
-9697e5aa6aff2be0a6d9c1e2098d3c89
\ No newline at end of file
+d62a2c121b7d14ea52ea938b98f94bc3
\ No newline at end of file
index d2e1b29bc31b1599e829845c04648d5b6177ff47..0925036a4e409f42594a24bfaf9918dec113a3f3 100644 (file)
Binary files a/LayoutTests/editing/pasteboard/paste-table-003-expected.png and b/LayoutTests/editing/pasteboard/paste-table-003-expected.png differ
index 798fb3be089dc4eba7c82ec962290733eb768c8e..e08bed86ceec7b7b58ceabb4fb89d3529cd045af 100644 (file)
@@ -4,7 +4,7 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 9 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
-EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
 layer at (0,0) size 800x600
@@ -33,6 +33,4 @@ layer at (0,0) size 800x600
                   text run at (1,1) width 24: "two"
         RenderBlock (anonymous) at (0,24) size 784x18
           RenderBR {BR} at (0,0) size 0x18
-      RenderBlock {DIV} at (0,66) size 784x18
-        RenderBR {BR} at (0,0) size 0x18
-caret: position 0 of child 0 {BR} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 0 of child 1 {BR} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 17fe8c0bbd4f6669cc0e0328cd9c309a3b251c5d..1dda82e0e9f77d7b80722341f3d4fe86640cd7d6 100644 (file)
@@ -1,3 +1,27 @@
+2006-07-27  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by levi
+        
+        More changes for:
+        <rdar://problem/4242293>
+        Poor paste fidelity of http://www.google.com/
+
+        * editing/markup.cpp:
+        (WebCore::needInterchangeNewlineAfter): Added.
+        (WebCore::createMarkup): 
+        Only add an interchangeNewline if we're annotating for interchange.  Can't test 
+        this until we expose createMarkup in non-annotate mode (I'd expose Range::toHTML).
+        Remove the FIXME about prepending the interchangeNewline before creating the rest 
+        of the markup.  Its correct to surround the interchangeNewline in ancestors of the
+        adjusted startNode.
+        Fixed the check to see if an interchangeNewline is needed (!inSameBlock).  This would
+        add an interchangeNewline for a selection that started before a table.
+        Removed the workaround for the bug where markup for a table was not included when 
+        selecting the contents of a table, since this change fixes the general problem of 
+        markup for ancestors of the startNode being left out.
+        Don't leave out ancestors of the startNode as we leave their subtrees.  Execute the
+        code to include them even if we closed ancestors in the ancestorsToClose list.
+
 2006-07-28  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by John.
index f7a48b0bd3b004961fb755261fc0f0cd27d9726d..db36ecb0efb1703c12822314fc310e0331f9d7b5 100644 (file)
                FAE04190097596C9000540BE /* SVGImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE0418E097596C9000540BE /* SVGImageLoader.h */; };
 /* End PBXBuildFile section */
 
+/* Begin PBXBuildStyle section */
+               D03DFF0D0A7ABE43004C8F18 /* Development */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = NO;
+                       };
+                       name = Development;
+               };
+               D03DFF0E0A7ABE43004C8F18 /* Deployment */ = {
+                       isa = PBXBuildStyle;
+                       buildSettings = {
+                               COPY_PHASE_STRIP = YES;
+                       };
+                       name = Deployment;
+               };
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
                DD041FF009D9E3250010AF2A /* PBXContainerItemProxy */ = {
                        isa = PBXContainerItemProxy;
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       buildSettings = {
+                       };
+                       buildStyles = (
+                               D03DFF0D0A7ABE43004C8F18 /* Development */,
+                               D03DFF0E0A7ABE43004C8F18 /* Deployment */,
+                       );
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
index db1f394990f94c05a124d356e6dd6c29d71f210f..92844abbf31e254a74f30311c4111a751cf7d52b 100644 (file)
@@ -283,6 +283,12 @@ static void completeURLs(Node *node, const DeprecatedString &baseURL)
     }
 }
 
+static bool needInterchangeNewlineAfter(const VisiblePosition& v)
+{
+    VisiblePosition next = v.next();
+    return isEndOfParagraph(v) && isStartOfParagraph(next) && !next.deepEquivalent().upstream().node()->hasTagName(brTag);
+}
+
 // FIXME: Shouldn't we omit style info when annotate == DoNotAnnotateForInterchange? 
 // FIXME: At least, annotation and style info should probably not be included in range.markupString()
 DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotateForInterchange annotate)
@@ -313,37 +319,22 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
     Node *lastClosed = 0;
     Vector<Node*> ancestorsToClose;
 
-    // calculate the "default style" for this markup
+    // Calculate the "default style" for this markup.
     Position pos(doc->documentElement(), 0);
     RefPtr<CSSComputedStyleDeclaration> computedStyle = pos.computedStyle();
     RefPtr<CSSMutableStyleDeclaration> defaultStyle = computedStyle->copyInheritableProperties();
     
-    // FIXME: Shouldn't we do the interchangeNewLine and skip the node iff (annotate == AnnotateForInterchange)?
-    Node *startNode = range->startNode();
+    Node* startNode = range->startNode();
     VisiblePosition visibleStart(range->startPosition(), VP_DEFAULT_AFFINITY);
     VisiblePosition visibleEnd(range->endPosition(), VP_DEFAULT_AFFINITY);
-    if (!inSameBlock(visibleStart, visibleStart.next())) {
+    if (annotate && needInterchangeNewlineAfter(visibleStart)) {
         if (visibleStart == visibleEnd.previous())
             return interchangeNewlineString;
             
-        // FIXME: This adds a newline, but a later add of the ancestor could go before that newline (e.g. when startNode is tbody,
-        // we will later add a table, but the interchangeNewlineString will appear between the table and the tbody! for now, that
-        // does not happen with tables because of code below that moves startNode to the table when at tbody)
         markups.append(interchangeNewlineString);
-        startNode = startNode->traverseNextNode();
-    }
-
-    // no use having a tbody without its table
-    // NOTE: need sibling check because startNode might be anonymous text (like newlines)
-    // FIXME: This would not be needed if ancestor adding applied to more than just the lastClosed
-    for (Node *n = startNode; n; n = n->nextSibling()) {
-        if (n->hasTagName(tbodyTag)) {
-            startNode = startNode->parent();
-            break;
-        }
+        startNode = visibleStart.next().deepEquivalent().node();
     }
 
-    // Iterate through the nodes of the range.
     Node *next;
     for (Node *n = startNode; n != pastEnd; n = next) {
         next = n->traverseNextNode();
@@ -368,7 +359,7 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
             }
             
             // Check if the node is the last leaf of a tree.
-            if (n->nextSibling() == 0 || next == pastEnd) {
+            if (!n->nextSibling() || next == pastEnd) {
                 if (!ancestorsToClose.isEmpty()) {
                     // Close up the ancestors.
                     do {
@@ -380,23 +371,23 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
                         lastClosed = ancestor;
                         ancestorsToClose.removeLast();
                     } while (!ancestorsToClose.isEmpty());
-                } else {
-                    if (next != pastEnd) {
-                        Node *nextParent = next->parentNode();
-                        if (n != nextParent) {
-                            for (Node *parent = n->parent(); parent != 0 && parent != nextParent; parent = parent->parentNode()) {
-                                // All ancestors not in the ancestorsToClose list should either be a) unrendered:
-                                if (!parent->renderer())
-                                    continue;
-                                // or b) ancestors that we never encountered during a pre-order traversal starting at startNode:
-                                ASSERT(startNode->isAncestor(parent));
-                                markups.prepend(startMarkup(parent, range, annotate, defaultStyle.get()));
-                                markups.append(endMarkup(parent));
-                                if (nodes)
-                                    nodes->append(parent);
-                                lastClosed = parent;
-                            }
-                        }
+                }
+                
+                // Surround the currently accumulated markup with markup for ancestors we never opened as we leave the subtree(s) rooted at those ancestors.
+                Node* nextParent = next ? next->parentNode() : 0;
+                if (next != pastEnd && n != nextParent) {
+                    Node* lastAncestorClosedOrSelf = n->isAncestor(lastClosed) ? lastClosed : n;
+                    for (Node *parent = lastAncestorClosedOrSelf->parent(); parent != 0 && parent != nextParent; parent = parent->parentNode()) {
+                        // All ancestors that aren't in the ancestorsToClose list should either be a) unrendered:
+                        if (!parent->renderer())
+                            continue;
+                        // or b) ancestors that we never encountered during a pre-order traversal starting at startNode:
+                        ASSERT(startNode->isAncestor(parent));
+                        markups.prepend(startMarkup(parent, range, annotate, defaultStyle.get()));
+                        markups.append(endMarkup(parent));
+                        if (nodes)
+                            nodes->append(parent);
+                        lastClosed = parent;
                     }
                 }
             }
@@ -439,10 +430,8 @@ DeprecatedString createMarkup(const Range *range, Vector<Node*>* nodes, EAnnotat
         }
     }
 
-    if (annotate) {
-        if (!inSameBlock(visibleEnd, visibleEnd.previous()))
-            markups.append(interchangeNewlineString);
-    }
+    if (annotate && needInterchangeNewlineAfter(visibleEnd.previous()))
+        markups.append(interchangeNewlineString);
 
     // Retain the Mail quote level by including all ancestor mail block quotes.
     for (Node *ancestor = commonAncestorBlock; ancestor; ancestor = ancestor->parentNode()) {