Performing data interaction with plain text into a contenteditable does not insert...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Apr 2017 21:17:59 +0000 (21:17 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Apr 2017 21:17:59 +0000 (21:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171381

Reviewed by Tim Horton.

Attempt to read plain-text-conformant UTI types as kUTTypePlainText before reading them as kUTTypeText.
This allows WebItemProviderPasteboard to properly materialize an NSString in -valuesForPasteboardType:
inItemSet: using a pre-loaded NSData blob.

This scenario is covered by DataInteractionTests.ExternalSourceUTF8PlainTextOnly, but DataInteractionTests
are temporarily disabled due to incompatibilities with the current internal SDK.

* platform/ios/PasteboardIOS.mm:
(WebCore::readPasteboardWebContentDataForType):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/ios/PasteboardIOS.mm

index 0674265..ffbc6b0 100644 (file)
@@ -1,3 +1,20 @@
+2017-04-27  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Performing data interaction with plain text into a contenteditable does not insert any content
+        https://bugs.webkit.org/show_bug.cgi?id=171381
+
+        Reviewed by Tim Horton.
+
+        Attempt to read plain-text-conformant UTI types as kUTTypePlainText before reading them as kUTTypeText.
+        This allows WebItemProviderPasteboard to properly materialize an NSString in -valuesForPasteboardType:
+        inItemSet: using a pre-loaded NSData blob.
+
+        This scenario is covered by DataInteractionTests.ExternalSourceUTF8PlainTextOnly, but DataInteractionTests
+        are temporarily disabled due to incompatibilities with the current internal SDK.
+
+        * platform/ios/PasteboardIOS.mm:
+        (WebCore::readPasteboardWebContentDataForType):
+
 2017-04-27  Chris Dumez  <cdumez@apple.com>
 
         Element.getBoundingClientRect() / getClientRects() should return a DOMRect types
index 0593760..7d4254f 100644 (file)
@@ -201,6 +201,11 @@ static bool readPasteboardWebContentDataForType(PasteboardWebContentReader& read
         return !url.isNull() && reader.readURL(url, title);
     }
 
+    if (UTTypeConformsTo((CFStringRef)type, kUTTypePlainText)) {
+        String string = strategy.readStringFromPasteboard(itemIndex, kUTTypePlainText, pasteboardName);
+        return !string.isNull() && reader.readPlainText(string);
+    }
+
     if (UTTypeConformsTo((CFStringRef)type, kUTTypeText)) {
         String string = strategy.readStringFromPasteboard(itemIndex, kUTTypeText, pasteboardName);
         return !string.isNull() && reader.readPlainText(string);