LayoutTests:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Sep 2006 22:01:33 +0000 (22:01 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Sep 2006 22:01:33 +0000 (22:01 +0000)
        Reviewed by harrison

        * editing/pasteboard/pasting-tabs-expected.checksum: Added.
        * editing/pasteboard/pasting-tabs-expected.png: Added.
        * editing/pasteboard/pasting-tabs-expected.txt: Added.
        * editing/pasteboard/pasting-tabs.html: Added.

WebCore:

        Reviewed by harrison

        <rdar://problem/4727383> REGRESSION: Pasting plain text with tabs into Blot converts the tabs to single spaces

        Pasting plain text results in a match style paste, and the insertion
        position is whitespace normal, which clobbers the whitespace:pre on
        tab spans.  Skip changes to the whitespace mode when computing a style
        change for tab spans or the text nodes inside tab spans.

        * editing/ApplyStyleCommand.cpp:
        (WebCore::StyleChange::init): Don't change the whitespace mode inside
        tab spans.

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

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/pasting-tabs-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/pasting-tabs-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/pasting-tabs-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/pasting-tabs.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/ApplyStyleCommand.cpp

index 27fcddfcb8de1b7e04678d3d5deb9f473d7d56be..392f60889c9bfe75eb49f5ab5903281ac0950f44 100644 (file)
@@ -1,3 +1,12 @@
+2006-09-19  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+
+        * editing/pasteboard/pasting-tabs-expected.checksum: Added.
+        * editing/pasteboard/pasting-tabs-expected.png: Added.
+        * editing/pasteboard/pasting-tabs-expected.txt: Added.
+        * editing/pasteboard/pasting-tabs.html: Added.
+
 2006-09-18  Adam Roben  <aroben@apple.com>
 
         Reviewed by Adele.
diff --git a/LayoutTests/editing/pasteboard/pasting-tabs-expected.checksum b/LayoutTests/editing/pasteboard/pasting-tabs-expected.checksum
new file mode 100644 (file)
index 0000000..eddac35
--- /dev/null
@@ -0,0 +1 @@
+517a364c4709c3ee40b86110382697f8
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/pasting-tabs-expected.png b/LayoutTests/editing/pasteboard/pasting-tabs-expected.png
new file mode 100644 (file)
index 0000000..fe76f06
Binary files /dev/null and b/LayoutTests/editing/pasteboard/pasting-tabs-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/pasting-tabs-expected.txt b/LayoutTests/editing/pasteboard/pasting-tabs-expected.txt
new file mode 100644 (file)
index 0000000..5a88500
--- /dev/null
@@ -0,0 +1,37 @@
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of #text > DIV to 0 of #text > DIV toDOMRange:range from 0 of #text > DIV to 11 of #text > DIV affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+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: shouldInsertText:Tab->       <-Tab 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 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > 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 {P} at (0,0) size 784x36
+        RenderText {#text} at (0,0) size 766x36
+          text run at (0,0) width 647: "This tests copying plain text with tabs and pasting it into an editable region using paste and match tyle. "
+          text run at (647,0) width 119: "The tabs should be"
+          text run at (0,18) width 65: "preserved."
+      RenderBlock (anonymous) at (0,52) size 784x32
+        RenderTextField {TEXTAREA} at (2,2) size 163x28 [bgcolor=#FFFFFF] [border: (1px solid #000000)]
+        RenderText {#text} at (0,0) size 0x0
+      RenderBlock {DIV} at (0,84) size 784x18
+        RenderBlock {DIV} at (0,0) size 784x18
+          RenderText {#text} at (0,0) size 39x18
+            text run at (0,0) width 39: "Tab->"
+          RenderInline {SPAN} at (0,0) size 25x18
+            RenderText {#text} at (39,0) size 25x18
+              text run at (39,0) width 25: "\x{9}"
+          RenderText {#text} at (64,0) size 39x18
+            text run at (64,0) width 39: "<-Tab"
+layer at (11,63) size 161x26
+  RenderBlock {DIV} at (1,1) size 161x26
+    RenderText {#text} at (3,0) size 84x13
+      text run at (3,0) width 84: "Tab->\x{9}<-Tab"
+caret: position 5 of child 2 {#text} of child 0 {DIV} of child 4 {DIV} of child 0 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/pasteboard/pasting-tabs.html b/LayoutTests/editing/pasteboard/pasting-tabs.html
new file mode 100644 (file)
index 0000000..8d7eb16
--- /dev/null
@@ -0,0 +1,14 @@
+<p>This tests copying plain text with tabs and pasting it into an editable region using paste and match tyle.  The tabs should be preserved.</p>
+<textarea id="textarea">Tab->  <-Tab</textarea>
+
+<div id="div" contenteditable="true"></div>
+
+<script>
+var textarea = document.getElementById("textarea");
+textarea.setSelectionRange(0, 0);
+document.execCommand("SelectAll");
+document.execCommand("Copy");
+var div = document.getElementById("div");
+window.getSelection().setPosition(div, 0);
+document.execCommand("PasteAndMatchStyle");
+</script>
\ No newline at end of file
index 1c80509dad7fd91a111120001880768ef9ace214..de613a19de821ee2ec2f54b33409522fa5e2801f 100644 (file)
@@ -1,3 +1,18 @@
+2006-09-19  Justin Garcia  <justin.garcia@apple.com>
+
+        Reviewed by harrison
+        
+        <rdar://problem/4727383> REGRESSION: Pasting plain text with tabs into Blot converts the tabs to single spaces
+
+        Pasting plain text results in a match style paste, and the insertion
+        position is whitespace normal, which clobbers the whitespace:pre on 
+        tab spans.  Skip changes to the whitespace mode when computing a style
+        change for tab spans or the text nodes inside tab spans.
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::StyleChange::init): Don't change the whitespace mode inside
+        tab spans.
+
 2006-09-19  David Hyatt  <hyatt@apple.com>
 
         Fix for bug 5298, shape=default not supported for image maps.  Implement
index 1874f1d9cdfb09992b3d4d8336fd4c32435a204f..5071cb4e272b805dd54003ee123a5a2a2b4fe336 100644 (file)
@@ -109,6 +109,10 @@ void StyleChange::init(PassRefPtr<CSSStyleDeclaration> style, const Position &po
         if (position.isNotNull() && currentlyHasStyle(position, property))
             continue;
         
+        // Changing the whitespace style in a tab span would collapse the tab into a space.
+        if (property->id() == CSS_PROP_WHITE_SPACE && (isTabSpanTextNode(position.node()) || isTabSpanNode((position.node()))))
+            continue;
+        
         // If needed, figure out if this change is a legacy HTML style change.
         if (m_usesLegacyStyles && checkForLegacyHTMLStyleChange(property))
             continue;