[iOS] Pasting rich content does not perform a two-step paste
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jul 2014 00:12:02 +0000 (00:12 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Jul 2014 00:12:02 +0000 (00:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134795

Reviewed by Benjamin Poulain.

Source/WebCore:
UIKit requires writing something (anything!) to a particular pasteboard
during copy in order to flag the content as rich. When a paste occurs,
UIKit will read this flag and perform a two-step paste.

Test: platform/ios-sim/editing/pasteboard/two-step-paste.html

* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::write):

LayoutTests:
Copy and paste some text, and make sure that the two step paste occurred.
The mechanism for detecting this is whether or not styles have changed appropriately.

* platform/ios-sim/editing/pasteboard/two-step-paste-expected.txt: Added.
* platform/ios-sim/editing/pasteboard/two-step-paste.html: Added.

Tools:
Two-step paste requires setting InputViewObeysDOMFocus on the UIWebBrowserView.

* DumpRenderTree/mac/DumpRenderTree.mm:
(createWebViewAndOffscreenWindow):

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

LayoutTests/ChangeLog
LayoutTests/platform/ios-sim/editing/pasteboard/two-step-paste-expected.txt [new file with mode: 0644]
LayoutTests/platform/ios-sim/editing/pasteboard/two-step-paste.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm

index a93ec8228f38b96d6a3373c84de939ddda1aff20..7dc98047640c6f4acdb708321a2b92ed7df382cd 100644 (file)
@@ -1,3 +1,16 @@
+2014-07-10  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Pasting rich content does not perform a two-step paste
+        https://bugs.webkit.org/show_bug.cgi?id=134795
+
+        Reviewed by Benjamin Poulain.
+
+        Copy and paste some text, and make sure that the two step paste occurred.
+        The mechanism for detecting this is whether or not styles have changed appropriately.
+
+        * platform/ios-sim/editing/pasteboard/two-step-paste-expected.txt: Added.
+        * platform/ios-sim/editing/pasteboard/two-step-paste.html: Added.
+
 2014-07-10  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         [EFL] Unreviewed EFL gardening.
diff --git a/LayoutTests/platform/ios-sim/editing/pasteboard/two-step-paste-expected.txt b/LayoutTests/platform/ios-sim/editing/pasteboard/two-step-paste-expected.txt
new file mode 100644 (file)
index 0000000..8a85d92
--- /dev/null
@@ -0,0 +1,10 @@
+The following test does a copy and a paste of contenteditable content. It then makes sure that the paste involved a two-step paste. The mechanism it uses to verify this is to determine if some styles change appropriately.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS t.style.color is not "rgb(153, 153, 153)"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+This is some text
diff --git a/LayoutTests/platform/ios-sim/editing/pasteboard/two-step-paste.html b/LayoutTests/platform/ios-sim/editing/pasteboard/two-step-paste.html
new file mode 100644 (file)
index 0000000..73c1869
--- /dev/null
@@ -0,0 +1,31 @@
+<html>
+<head>
+<script src="../../../../resources/js-test-pre.js"></script>
+<script src="../../../../editing/editing.js"></script>
+</head>
+<body>
+    <div id="container" contenteditable="true">
+        <p id="paragraph" style="color: rgb(153, 153, 153);">This is some text</p>
+    </div>
+    <script>
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        description("The following test does a copy and a paste of contenteditable content. It then makes sure that the paste involved a two-step paste. The mechanism it uses to verify this is to determine if some styles change appropriately.");
+
+        var container = document.getElementById("container");
+        var selection = window.getSelection();
+        var range = document.createRange();
+        container.focus();
+        range.selectNodeContents(container);
+        selection.removeAllRanges();
+        selection.addRange(range);
+
+        copyCommand();
+        pasteCommand();
+
+        var t = document.getElementById("paragraph");
+        shouldNotBe("t.style.color", "\"rgb(153, 153, 153)\"");
+    </script>
+<script src="../../../../resources/js-test-post.js"></script>
+</html>
index 40596c28199b2e8283c610f53f52fa0d96af0adc..063f8b06c20f825f861fb4ee9599d7681b24feda 100644 (file)
@@ -1,3 +1,19 @@
+2014-07-10  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Pasting rich content does not perform a two-step paste
+        https://bugs.webkit.org/show_bug.cgi?id=134795
+
+        Reviewed by Benjamin Poulain.
+
+        UIKit requires writing something (anything!) to a particular pasteboard
+        during copy in order to flag the content as rich. When a paste occurs,
+        UIKit will read this flag and perform a two-step paste.
+
+        Test: platform/ios-sim/editing/pasteboard/two-step-paste.html
+
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::write):
+
 2014-07-09  Andy Estes  <aestes@apple.com>
 
         [iOS] Some QuickLook documents are not displayed as previews
index 920ca447017f5ab10664c5e863e299b9c76a5b24..43931cc551cb4fdd871ae4e06fcb8a09914da8c0 100644 (file)
@@ -154,8 +154,12 @@ void PlatformPasteboard::write(const PasteboardWebContent& content)
 {
     RetainPtr<NSDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
 
-    if (content.dataInWebArchiveFormat)
+    if (content.dataInWebArchiveFormat) {
         [representations setValue:(NSData *)content.dataInWebArchiveFormat->createNSData().get() forKey:WebArchivePboardType];
+        // Flag for UIKit to know that this copy contains rich content. This will trigger a two-step paste.
+        NSString* webIOSPastePboardType = @"iOS rich content paste pasteboard type";
+        [representations setValue:webIOSPastePboardType forKey:webIOSPastePboardType];
+    }
 
     if (content.dataInRTFDFormat)
         [representations setValue:content.dataInRTFDFormat->createNSData().get() forKey:(NSString *)kUTTypeRTFD];
index 79dad9700c3ba7a1100de7a07851613379bc201f..19a4ae43220f02ccca9de999d49327c5a257dd55 100644 (file)
@@ -1,3 +1,15 @@
+2014-07-10  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [iOS] Pasting rich content does not perform a two-step paste
+        https://bugs.webkit.org/show_bug.cgi?id=134795
+
+        Reviewed by Benjamin Poulain.
+
+        Two-step paste requires setting InputViewObeysDOMFocus on the UIWebBrowserView.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (createWebViewAndOffscreenWindow):
+
 2014-07-10  Carlos Garcia Campos  <cgarcia@igalia.com> and Martin Robinson  <mrobinson@igalia.com>
 
         [GTK][CMake] Add a 'distcheck' target
index 0cb42b2672952cd9a7008c74d1c8270aa3b4f35e..12ea43ee50a4b72c0fed8b1bec0f29871ec54c61 100644 (file)
@@ -673,7 +673,7 @@ WebView *createWebViewAndOffscreenWindow()
     WebView *webView = [[WebView alloc] initWithFrame:rect frameName:nil groupName:@"org.webkit.DumpRenderTree"];
 #else
     UIWebBrowserView *webBrowserView = [[[DumpRenderTreeBrowserView alloc] initWithFrame:layoutTestViewportRect] autorelease];
-
+    [webBrowserView setInputViewObeysDOMFocus:YES];
     WebView *webView = [[webBrowserView webView] retain];
     [webView setGroupName:@"org.webkit.DumpRenderTree"];
 #endif