[Qt] Add smart paste support
authorrobert@webkit.org <robert@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 May 2010 10:02:49 +0000 (10:02 +0000)
committerrobert@webkit.org <robert@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 1 May 2010 10:02:49 +0000 (10:02 +0000)
2010-05-01  Robert Hogan  <robert@webkit.org>

        Reviewed by Simon Hausmann.

        [Qt] Add smart paste support

        https://bugs.webkit.org/show_bug.cgi?id=38136

        Add platform specific results.

        Unskip tests:
         editing/pasteboard/smart-paste-001.html
         editing/pasteboard/smart-paste-002.html
         editing/pasteboard/smart-paste-003.html
         editing/pasteboard/smart-paste-004.html
         editing/pasteboard/smart-paste-005.html
         editing/pasteboard/smart-paste-006.html
         editing/pasteboard/smart-paste-007.html

        * platform/qt/Skipped:
        * platform/qt/editing/pasteboard/smart-paste-001-expected.txt: Added.
        * platform/qt/editing/pasteboard/smart-paste-002-expected.txt: Added.
        * platform/qt/editing/pasteboard/smart-paste-003-expected.txt: Added.
        * platform/qt/editing/pasteboard/smart-paste-004-expected.txt: Added.
        * platform/qt/editing/pasteboard/smart-paste-005-expected.txt: Added.
        * platform/qt/editing/pasteboard/smart-paste-006-expected.txt:
        * platform/qt/editing/pasteboard/smart-paste-007-expected.txt: Added.

        * Api/qwebpage.cpp:
        (QWebPagePrivate::QWebPagePrivate): Enable smart paste support by default.

        * WebCore.pro:
        * editing/qt/SmartReplaceQt.cpp: Added.
        (WebCore::isCharacterSmartReplaceExempt):
        * platform/qt/PasteboardQt.cpp:
        (WebCore::Pasteboard::writeSelection):
        (WebCore::Pasteboard::canSmartReplace):

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/qt/Skipped
LayoutTests/platform/qt/editing/pasteboard/smart-paste-001-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/editing/pasteboard/smart-paste-002-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/editing/pasteboard/smart-paste-003-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/editing/pasteboard/smart-paste-004-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/editing/pasteboard/smart-paste-005-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/editing/pasteboard/smart-paste-006-expected.txt
LayoutTests/platform/qt/editing/pasteboard/smart-paste-007-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.pro
WebCore/editing/qt/SmartReplaceQt.cpp [new file with mode: 0644]
WebCore/platform/qt/PasteboardQt.cpp
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/ChangeLog

index 71fceea..fcb0ef0 100644 (file)
@@ -1,3 +1,31 @@
+2010-05-01  Robert Hogan  <robert@webkit.org>
+
+        Reviewed by Simon Hausmann.
+
+        [Qt] Add smart paste support
+
+        https://bugs.webkit.org/show_bug.cgi?id=38136
+
+        Add platform specific results.
+
+        Unskip tests:
+         editing/pasteboard/smart-paste-001.html
+         editing/pasteboard/smart-paste-002.html
+         editing/pasteboard/smart-paste-003.html
+         editing/pasteboard/smart-paste-004.html
+         editing/pasteboard/smart-paste-005.html
+         editing/pasteboard/smart-paste-006.html
+         editing/pasteboard/smart-paste-007.html
+
+        * platform/qt/Skipped:
+        * platform/qt/editing/pasteboard/smart-paste-001-expected.txt: Added.
+        * platform/qt/editing/pasteboard/smart-paste-002-expected.txt: Added.
+        * platform/qt/editing/pasteboard/smart-paste-003-expected.txt: Added.
+        * platform/qt/editing/pasteboard/smart-paste-004-expected.txt: Added.
+        * platform/qt/editing/pasteboard/smart-paste-005-expected.txt: Added.
+        * platform/qt/editing/pasteboard/smart-paste-006-expected.txt:
+        * platform/qt/editing/pasteboard/smart-paste-007-expected.txt: Added.
+
 2010-04-30  Yoshiki Hayashi  <yhayashi@google.com>
 
         Reviewed by Shinichiro Hamaji.
index 25039fd..b976e50 100644 (file)
@@ -461,19 +461,15 @@ editing/pasteboard/paste-text-008.html
 editing/pasteboard/paste-text-013.html
 editing/pasteboard/paste-xml.xhtml
 editing/pasteboard/select-element-1.html
-editing/pasteboard/smart-paste-001.html
-editing/pasteboard/smart-paste-002.html
-editing/pasteboard/smart-paste-003.html
-editing/pasteboard/smart-paste-004.html
-editing/pasteboard/smart-paste-005.html
-editing/pasteboard/smart-paste-007.html
-editing/pasteboard/smart-paste-008.html
 editing/pasteboard/smart-drag-drop.html
 editing/pasteboard/subframe-dragndrop-1.html
 editing/pasteboard/testcase-9507.html
 editing/pasteboard/undoable-fragment-removes.html
 editing/pasteboard/unrendered-br.html
 
+#Extra trailing space in pasted content
+editing/pasteboard/smart-paste-008.html
+
 # ------- failures due to missing support for particular XSLT features
 # xsl:output
 fast/xsl/xslt-doc-enc.xml
@@ -2056,7 +2052,6 @@ editing/pasteboard/paste-unrendered-select.html
 editing/pasteboard/pasting-object.html
 editing/pasteboard/pasting-tabs.html
 editing/pasteboard/prevent-block-nesting-01.html
-editing/pasteboard/smart-paste-006.html
 editing/pasteboard/styled-element-markup.html
 editing/selection/13804.html
 editing/selection/3690703-2.html
diff --git a/LayoutTests/platform/qt/editing/pasteboard/smart-paste-001-expected.txt b/LayoutTests/platform/qt/editing/pasteboard/smart-paste-001-expected.txt
new file mode 100644 (file)
index 0000000..d19557c
--- /dev/null
@@ -0,0 +1,42 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 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 DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > 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 {DIV} at (0,0) size 784x226 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x61
+          RenderText {#text} at (0,0) size 77x31
+            text run at (0,0) width 77: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,31) size 618x29
+            text run at (0,31) width 618: "Smart paste when pasting after a word at the end of a line."
+        RenderBlock {DIV} at (14,91) size 756x121
+          RenderText {#text} at (0,0) size 214x31
+            text run at (0,0) width 214: "Expected Results: "
+          RenderBR {BR} at (214,24) size 0x0
+          RenderText {#text} at (0,31) size 726x59
+            text run at (0,31) width 726: "A space should be added between the preexisting word and the word"
+            text run at (0,61) width 383: "that's pasted. It should like this this: "
+          RenderBR {BR} at (383,84) size 0x0
+          RenderText {#text} at (0,91) size 86x29
+            text run at (0,91) width 86: "test test"
+      RenderBlock {DIV} at (0,250) size 784x34
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 40x29
+            text run at (2,2) width 40: "test"
+          RenderText {#text} at (42,2) size 47x29
+            text run at (42,2) width 47: " test"
+        RenderBlock (anonymous) at (0,34) size 784x0
+          RenderText {#text} at (0,0) size 0x0
+caret: position 5 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/qt/editing/pasteboard/smart-paste-002-expected.txt b/LayoutTests/platform/qt/editing/pasteboard/smart-paste-002-expected.txt
new file mode 100644 (file)
index 0000000..c4d1bf4
--- /dev/null
@@ -0,0 +1,42 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 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 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: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > 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 {DIV} at (0,0) size 784x226 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x61
+          RenderText {#text} at (0,0) size 77x31
+            text run at (0,0) width 77: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,31) size 699x29
+            text run at (0,31) width 699: "Smart paste when pasting at the beginning of a line before a word."
+        RenderBlock {DIV} at (14,91) size 756x121
+          RenderText {#text} at (0,0) size 214x31
+            text run at (0,0) width 214: "Expected Results: "
+          RenderBR {BR} at (214,24) size 0x0
+          RenderText {#text} at (0,31) size 726x59
+            text run at (0,31) width 726: "A space should be added after the pasted word before the preexising"
+            text run at (0,61) width 299: "word. It should like this this: "
+          RenderBR {BR} at (299,84) size 0x0
+          RenderText {#text} at (0,91) size 86x29
+            text run at (0,91) width 86: "test test"
+      RenderBlock {DIV} at (0,250) size 784x34
+        RenderBlock (anonymous) at (0,0) size 784x0
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 47x29
+            text run at (2,2) width 47: "test "
+          RenderText {#text} at (49,2) size 40x29
+            text run at (49,2) width 40: "test"
+caret: position 5 of child 0 {#text} of child 0 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/qt/editing/pasteboard/smart-paste-003-expected.txt b/LayoutTests/platform/qt/editing/pasteboard/smart-paste-003-expected.txt
new file mode 100644 (file)
index 0000000..cd43655
--- /dev/null
@@ -0,0 +1,46 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 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 DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) 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 {DIV} at (0,0) size 784x286 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x91
+          RenderText {#text} at (0,0) size 77x31
+            text run at (0,0) width 77: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,31) size 664x59
+            text run at (0,31) width 664: "Smart paste when pasting after a word and before a space and"
+            text run at (0,61) width 145: "another word."
+        RenderBlock {DIV} at (14,121) size 756x151
+          RenderText {#text} at (0,0) size 214x31
+            text run at (0,0) width 214: "Expected Results: "
+          RenderBR {BR} at (214,24) size 0x0
+          RenderText {#text} at (0,31) size 726x89
+            text run at (0,31) width 726: "A space should be added between the preexisting word and the word"
+            text run at (0,61) width 690: "that's pasted. No space should be added after the pasted word. It"
+            text run at (0,91) width 213: "should like this this: "
+          RenderBR {BR} at (213,114) size 0x0
+          RenderText {#text} at (0,121) size 132x29
+            text run at (0,121) width 132: "test test test"
+      RenderBlock {DIV} at (0,310) size 784x34
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 40x29
+            text run at (2,2) width 40: "test"
+          RenderText {#text} at (42,2) size 47x29
+            text run at (42,2) width 47: " test"
+          RenderText {#text} at (89,2) size 47x29
+            text run at (89,2) width 47: " test"
+        RenderBlock (anonymous) at (0,34) size 784x0
+caret: position 5 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/qt/editing/pasteboard/smart-paste-004-expected.txt b/LayoutTests/platform/qt/editing/pasteboard/smart-paste-004-expected.txt
new file mode 100644 (file)
index 0000000..0110c2a
--- /dev/null
@@ -0,0 +1,47 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 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 DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 6 of #text > DIV > DIV > BODY > HTML > #document to 6 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) 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 {DIV} at (0,0) size 784x256 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x91
+          RenderText {#text} at (0,0) size 77x31
+            text run at (0,0) width 77: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,31) size 687x59
+            text run at (0,31) width 687: "Smart paste when pasting after word and a space before another"
+            text run at (0,61) width 58: "word."
+        RenderBlock {DIV} at (14,121) size 756x121
+          RenderText {#text} at (0,0) size 214x31
+            text run at (0,0) width 214: "Expected Results: "
+          RenderBR {BR} at (214,24) size 0x0
+          RenderText {#text} at (0,31) size 675x59
+            text run at (0,31) width 675: "A space should be added after the pasted word before the other"
+            text run at (0,61) width 186: "preexisting word. "
+            text run at (186,61) width 234: "It should like this this: "
+          RenderBR {BR} at (420,84) size 0x0
+          RenderText {#text} at (0,91) size 132x29
+            text run at (0,91) width 132: "test test test"
+      RenderBlock {DIV} at (0,280) size 784x34
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 46x29
+            text run at (2,2) width 46: "test "
+          RenderText {#text} at (48,2) size 47x29
+            text run at (48,2) width 47: "test "
+          RenderText {#text} at (95,2) size 40x29
+            text run at (95,2) width 40: "test"
+        RenderBlock (anonymous) at (0,34) size 784x0
+caret: position 5 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/qt/editing/pasteboard/smart-paste-005-expected.txt b/LayoutTests/platform/qt/editing/pasteboard/smart-paste-005-expected.txt
new file mode 100644 (file)
index 0000000..51cc386
--- /dev/null
@@ -0,0 +1,47 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 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 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: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 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: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 3 of #text > DIV > DIV > BODY > HTML > #document to 3 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 6 of #text > DIV > DIV > BODY > HTML > #document to 6 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 {DIV} at (0,0) size 784x226 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x61
+          RenderText {#text} at (0,0) size 77x31
+            text run at (0,0) width 77: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,31) size 528x29
+            text run at (0,31) width 528: "Smart paste when pasting in the middle of a word."
+        RenderBlock {DIV} at (14,91) size 756x121
+          RenderText {#text} at (0,0) size 214x31
+            text run at (0,0) width 214: "Expected Results: "
+          RenderBR {BR} at (214,24) size 0x0
+          RenderText {#text} at (0,31) size 715x59
+            text run at (0,31) width 715: "Spaces should be added before and after the pasted word. It should"
+            text run at (0,61) width 143: "look like this: "
+          RenderBR {BR} at (143,84) size 0x0
+          RenderText {#text} at (0,91) size 93x29
+            text run at (0,91) width 93: "te test st"
+      RenderBlock {DIV} at (0,250) size 784x34
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 21x29
+            text run at (2,2) width 21: "te"
+          RenderText {#text} at (23,2) size 54x29
+            text run at (23,2) width 54: " test "
+          RenderText {#text} at (77,2) size 20x29
+            text run at (77,2) width 20: "st"
+        RenderBlock (anonymous) at (0,34) size 784x0
+caret: position 6 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index f1d7c68..6fe5bcc 100644 (file)
@@ -25,30 +25,30 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x600
   RenderBlock {HTML} at (0,0) size 800x600
     RenderBody {BODY} at (8,8) size 784x584
-      RenderBlock {DIV} at (0,0) size 784x238 [border: (2px solid #0000FF)]
-        RenderBlock {DIV} at (14,14) size 756x65
-          RenderText {#text} at (0,0) size 77x33
+      RenderBlock {DIV} at (0,0) size 784x226 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x61
+          RenderText {#text} at (0,0) size 77x31
             text run at (0,0) width 77: "Tests: "
           RenderBR {BR} at (0,0) size 0x0
-          RenderText {#text} at (0,33) size 713x31
-            text run at (0,33) width 713: "Smart paste when pasting between smart paste exempt characters."
-        RenderBlock {DIV} at (14,95) size 756x129
-          RenderText {#text} at (0,0) size 214x33
+          RenderText {#text} at (0,31) size 713x29
+            text run at (0,31) width 713: "Smart paste when pasting between smart paste exempt characters."
+        RenderBlock {DIV} at (14,91) size 756x121
+          RenderText {#text} at (0,0) size 214x31
             text run at (0,0) width 214: "Expected Results: "
           RenderBR {BR} at (214,24) size 0x0
-          RenderText {#text} at (0,33) size 730x63
-            text run at (0,33) width 730: "No spaces should be added before or after the pasted word. It should"
-            text run at (0,65) width 143: "look like this: "
-          RenderBR {BR} at (143,88) size 0x0
-          RenderText {#text} at (0,97) size 55x31
-            text run at (0,97) width 55: "-test-"
-      RenderBlock {DIV} at (0,262) size 784x36
-        RenderBlock {DIV} at (0,0) size 784x36 [border: (2px solid #FF0000)]
-          RenderText {#text} at (2,2) size 8x31
+          RenderText {#text} at (0,31) size 730x59
+            text run at (0,31) width 730: "No spaces should be added before or after the pasted word. It should"
+            text run at (0,61) width 143: "look like this: "
+          RenderBR {BR} at (143,84) size 0x0
+          RenderText {#text} at (0,91) size 55x29
+            text run at (0,91) width 55: "-test-"
+      RenderBlock {DIV} at (0,250) size 784x34
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 8x29
             text run at (2,2) width 8: "-"
-          RenderText {#text} at (10,2) size 39x31
-            text run at (10,2) width 39: "test"
-          RenderText {#text} at (49,2) size 8x31
-            text run at (49,2) width 8: "-"
-        RenderBlock (anonymous) at (0,36) size 784x0
+          RenderText {#text} at (10,2) size 40x29
+            text run at (10,2) width 40: "test"
+          RenderText {#text} at (50,2) size 8x29
+            text run at (50,2) width 8: "-"
+        RenderBlock (anonymous) at (0,34) size 784x0
 caret: position 4 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/platform/qt/editing/pasteboard/smart-paste-007-expected.txt b/LayoutTests/platform/qt/editing/pasteboard/smart-paste-007-expected.txt
new file mode 100644 (file)
index 0000000..df0c4b9
--- /dev/null
@@ -0,0 +1,56 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 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 DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 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: shouldDeleteDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 5 of #text > DIV > DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 2 of #text > DIV > DIV > BODY > HTML > #document to 2 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 1 of #text > DIV > DIV > BODY > HTML > #document givenAction:WebViewInsertActionPasted
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) 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 {DIV} at (0,0) size 784x226 [border: (2px solid #0000FF)]
+        RenderBlock {DIV} at (14,14) size 756x61
+          RenderText {#text} at (0,0) size 77x31
+            text run at (0,0) width 77: "Tests: "
+          RenderBR {BR} at (0,0) size 0x0
+          RenderText {#text} at (0,31) size 506x29
+            text run at (0,31) width 506: "Smart paste when pasting between two periods."
+        RenderBlock {DIV} at (14,91) size 756x121
+          RenderText {#text} at (0,0) size 214x31
+            text run at (0,0) width 214: "Expected Results: "
+          RenderBR {BR} at (214,24) size 0x0
+          RenderText {#text} at (0,31) size 688x59
+            text run at (0,31) width 688: "A space should be added before, but not after the pasted word. It"
+            text run at (0,61) width 219: "should look like this: "
+          RenderBR {BR} at (219,84) size 0x0
+          RenderText {#text} at (0,91) size 60x29
+            text run at (0,91) width 60: ". test."
+      RenderBlock {DIV} at (0,250) size 784x34
+        RenderBlock {DIV} at (0,0) size 784x34 [border: (2px solid #FF0000)]
+          RenderText {#text} at (2,2) size 7x29
+            text run at (2,2) width 7: "."
+          RenderText {#text} at (9,2) size 47x29
+            text run at (9,2) width 47: " test"
+          RenderText {#text} at (56,2) size 7x29
+            text run at (56,2) width 7: "."
+        RenderBlock (anonymous) at (0,34) size 784x0
+caret: position 5 of child 1 {#text} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index dba7ace..9f0bcaf 100644 (file)
@@ -1,3 +1,18 @@
+2010-05-01  Robert Hogan  <robert@webkit.org>
+
+        Reviewed by Simon Hausmann.
+
+        [Qt] Add smart paste support
+
+        https://bugs.webkit.org/show_bug.cgi?id=38136
+
+        * WebCore.pro:
+        * editing/qt/SmartReplaceQt.cpp: Added.
+        (WebCore::isCharacterSmartReplaceExempt):
+        * platform/qt/PasteboardQt.cpp:
+        (WebCore::Pasteboard::writeSelection):
+        (WebCore::Pasteboard::canSmartReplace):
+
 2010-04-30  Yoshiki Hayashi  <yhayashi@google.com>
 
         Reviewed by Shinichiro Hamaji.
index ef6021d..56ddadb 100644 (file)
@@ -569,7 +569,6 @@ SOURCES += \
     editing/ReplaceSelectionCommand.cpp \
     editing/SelectionController.cpp \
     editing/SetNodeAttributeCommand.cpp \
-    editing/SmartReplace.cpp \
     editing/SmartReplaceICU.cpp \
     editing/SplitElementCommand.cpp \
     editing/SplitTextNodeCommand.cpp \
@@ -2079,6 +2078,7 @@ SOURCES += \
     platform/network/qt/DnsPrefetchHelper.cpp \
     platform/network/qt/QNetworkReplyHandler.cpp \
     editing/qt/EditorQt.cpp \
+    editing/qt/SmartReplaceQt.cpp \
     platform/qt/ClipboardQt.cpp \
     platform/qt/ContextMenuItemQt.cpp \
     platform/qt/ContextMenuQt.cpp \
diff --git a/WebCore/editing/qt/SmartReplaceQt.cpp b/WebCore/editing/qt/SmartReplaceQt.cpp
new file mode 100644 (file)
index 0000000..1436afe
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2010 Robert Hogan <robert@roberthogan.net>.  All rights reserved.
+ * Copyright (C) 2007,2008,2009 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SmartReplace.h"
+
+namespace WebCore {
+
+bool isCharacterSmartReplaceExempt(UChar32 c, bool isPreviousCharacter)
+{
+    QChar d(c);
+    if (d.isSpace())
+        return true;
+    if (!isPreviousCharacter && d.isPunct())
+        return true;
+
+    if ((c >= 0x1100 && c <= (0x1100 + 256))          // Hangul Jamo (0x1100 - 0x11FF)
+        || (c >= 0x2E80 && c <= (0x2E80 + 352))       // CJK & Kangxi Radicals (0x2E80 - 0x2FDF)
+        || (c >= 0x2FF0 && c <= (0x2FF0 + 464))       // Ideograph Deseriptions, CJK Symbols, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, & Bopomofo Ext (0x2FF0 - 0x31BF)
+        || (c >= 0x3200 && c <= (0x3200 + 29392))     // Enclosed CJK, CJK Ideographs (Uni Han & Ext A), & Yi (0x3200 - 0xA4CF)
+        || (c >= 0xAC00 && c <= (0xAC00 + 11183))     // Hangul Syllables (0xAC00 - 0xD7AF)
+        || (c >= 0xF900 && c <= (0xF900 + 352))       // CJK Compatibility Ideographs (0xF900 - 0xFA5F)
+        || (c >= 0xFE30 && c <= (0xFE30 + 32))        // CJK Compatibility From (0xFE30 - 0xFE4F)
+        || (c >= 0xFF00 && c <= (0xFF00 + 240))       // Half/Full Width Form (0xFF00 - 0xFFEF)
+        || (c >= 0x20000 && c <= (0x20000 + 0xA6D7))  // CJK Ideograph Exntension B
+        || (c >= 0x2F800 && c <= (0x2F800 + 0x021E))) // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)
+       return true;
+
+    const char prev[] = "([\"\'#$/-`{\0";
+    const char next[] = ")].,;:?\'!\"%*-/}\0";
+    const char* str = (isPreviousCharacter) ? prev : next;
+    for (int i = 0; i < strlen(str); ++i) {
+        if (str[i] == c)
+          return true;
+    }
+
+    return false;
+}
+
+}
index 70ec546..484fa60 100644 (file)
@@ -58,7 +58,7 @@ Pasteboard* Pasteboard::generalPasteboard()
     return pasteboard;
 }
 
-void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame)
+void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame)
 {
     QMimeData* md = new QMimeData;
     QString text = frame->selectedText();
@@ -74,10 +74,14 @@ void Pasteboard::writeSelection(Range* selectedRange, bool, Frame* frame)
     QApplication::clipboard()->setMimeData(md, m_selectionMode ?
             QClipboard::Selection : QClipboard::Clipboard);
 #endif
+    if (canSmartCopyOrDelete)
+        md->setData("application/vnd.qtwebkit.smartpaste", QByteArray());
 }
 
 bool Pasteboard::canSmartReplace()
 {
+    if (QApplication::clipboard()->mimeData()->hasFormat((QLatin1String("application/vnd.qtwebkit.smartpaste"))))
+        return true;
     return false;
 }
 
index 5c5f79f..a581b32 100644 (file)
@@ -290,7 +290,7 @@ QWebPagePrivate::QWebPagePrivate(QWebPage *qq)
 #ifndef QT_NO_CONTEXTMENU
     currentContextMenu = 0;
 #endif
-    smartInsertDeleteEnabled = false;
+    smartInsertDeleteEnabled = true;
     selectTrailingWhitespaceEnabled = false;
 
     history.d = new QWebHistoryPrivate(page->backForwardList());
index 2724f40..40598a7 100644 (file)
@@ -1,3 +1,14 @@
+2010-05-01  Robert Hogan  <robert@webkit.org>
+
+        Reviewed by Simon Hausmann.
+
+        [Qt] Add smart paste support
+
+        https://bugs.webkit.org/show_bug.cgi?id=38136
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::QWebPagePrivate): Enable smart paste support by default.
+
 2010-04-29  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.