Title: [219666] trunk
Revision
219666
Author
megan_gard...@apple.com
Date
2017-07-19 16:57:38 -0700 (Wed, 19 Jul 2017)

Log Message

Don't write file URLs to iOS Pasteboard
https://bugs.webkit.org/show_bug.cgi?id=174647
<rdar://problem/33199730>

Reviewed by Wenson Hsieh.

Source/WebCore:

Tests updated to reflect the changes. We are no longer vending file URLs in Drag & Drop and Copy/Paste.

* editing/ios/EditorIOS.mm:
(WebCore::Editor::writeImageToPasteboard):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::write):

Tools:

Updating tests to reflect the lack of file URLs for images.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(checkTypeIdentifierAndIsNotOtherTypeIdentifier):
(checkEstimatedSize):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219665 => 219666)


--- trunk/Source/WebCore/ChangeLog	2017-07-19 23:38:06 UTC (rev 219665)
+++ trunk/Source/WebCore/ChangeLog	2017-07-19 23:57:38 UTC (rev 219666)
@@ -1,3 +1,18 @@
+2017-07-19  Megan Gardner  <megan_gard...@apple.com>
+
+        Don't write file URLs to iOS Pasteboard
+        https://bugs.webkit.org/show_bug.cgi?id=174647
+        <rdar://problem/33199730>
+
+        Reviewed by Wenson Hsieh.
+
+        Tests updated to reflect the changes. We are no longer vending file URLs in Drag & Drop and Copy/Paste.
+
+        * editing/ios/EditorIOS.mm:
+        (WebCore::Editor::writeImageToPasteboard):
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::write):
+
 2017-07-19  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Setting the minimum font size preference doesn’t affect absolute line-height values, so lines overlap

Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (219665 => 219666)


--- trunk/Source/WebCore/editing/ios/EditorIOS.mm	2017-07-19 23:38:06 UTC (rev 219665)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm	2017-07-19 23:57:38 UTC (rev 219666)
@@ -207,8 +207,12 @@
     ASSERT(cachedImage);
 
     auto imageSourceURL = imageElement.document().completeURL(stripLeadingAndTrailingHTMLSpaces(imageElement.imageSourceURL()));
-    pasteboardImage.url.url = "" ? imageSourceURL : url;
-    pasteboardImage.url.title = title;
+
+    auto pasteboardImageURL = url.isEmpty() ? imageSourceURL : url;
+    if (!pasteboardImageURL.isLocalFile()) {
+        pasteboardImage.url.url = ""
+        pasteboardImage.url.title = title;
+    }
     pasteboardImage.suggestedName = imageSourceURL.lastPathComponent();
     pasteboardImage.imageSize = image->size();
     pasteboardImage.resourceMIMEType = pasteboard.resourceMIMEType(cachedImage->response().mimeType());

Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (219665 => 219666)


--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2017-07-19 23:38:06 UTC (rev 219665)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2017-07-19 23:57:38 UTC (rev 219666)
@@ -325,7 +325,8 @@
     RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
     if (!pasteboardImage.resourceMIMEType.isNull()) {
         [representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType];
-        [representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL];
+        if (!pasteboardImage.url.url.isNull())
+            [representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL];
     }
 
     // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.

Modified: trunk/Tools/ChangeLog (219665 => 219666)


--- trunk/Tools/ChangeLog	2017-07-19 23:38:06 UTC (rev 219665)
+++ trunk/Tools/ChangeLog	2017-07-19 23:57:38 UTC (rev 219666)
@@ -1,3 +1,18 @@
+2017-07-19  Megan Gardner  <megan_gard...@apple.com>
+
+        Don't write file URLs to iOS Pasteboard
+        https://bugs.webkit.org/show_bug.cgi?id=174647
+        <rdar://problem/33199730>
+
+        Reviewed by Wenson Hsieh.
+
+        Updating tests to reflect the lack of file URLs for images.
+
+        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+        (checkTypeIdentifierAndIsNotOtherTypeIdentifier):
+        (checkEstimatedSize):
+        (TestWebKitAPI::TEST):
+
 2017-07-19  Brady Eidson  <beid...@apple.com>
 
         iBooks sometimes crashes when closing a book.

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (219665 => 219666)


--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2017-07-19 23:38:06 UTC (rev 219665)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm	2017-07-19 23:57:38 UTC (rev 219666)
@@ -114,6 +114,13 @@
     EXPECT_TRUE([registeredTypes indexOfObject:firstType] < [registeredTypes indexOfObject:secondType]);
 }
 
+static void checkTypeIdentifierAndIsNotOtherTypeIdentifier(DataInteractionSimulator *simulator, NSString *firstType, NSString *secondType)
+{
+    NSArray *registeredTypes = [simulator.sourceItemProviders.firstObject registeredTypeIdentifiers];
+    EXPECT_TRUE([registeredTypes containsObject:firstType]);
+    EXPECT_FALSE([registeredTypes containsObject:secondType]);
+}
+
 static void checkTypeIdentifierIsRegisteredAtIndex(DataInteractionSimulator *simulator, NSString *type, NSUInteger index)
 {
     NSArray *registeredTypes = [simulator.sourceItemProviders.firstObject registeredTypeIdentifiers];
@@ -121,6 +128,13 @@
     EXPECT_WK_STREQ(type.UTF8String, [registeredTypes[index] UTF8String]);
 }
 
+static void checkEstimatedSize(DataInteractionSimulator *simulator, CGSize estimatedSize)
+{
+    UIItemProvider *sourceItemProvider = [simulator sourceItemProviders].firstObject;
+    EXPECT_EQ(estimatedSize.width, sourceItemProvider.estimatedDisplayedSize.width);
+    EXPECT_EQ(estimatedSize.height, sourceItemProvider.estimatedDisplayedSize.height);
+}
+
 static void checkSuggestedNameAndEstimatedSize(DataInteractionSimulator *simulator, NSString *suggestedName, CGSize estimatedSize)
 {
     UIItemProvider *sourceItemProvider = [simulator sourceItemProviders].firstObject;
@@ -166,8 +180,8 @@
     EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
     EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
     checkSelectionRectsWithLogging(@[ makeCGRectValue(1, 201, 215, 174) ], [dataInteractionSimulator finalSelectionRects]);
-    checkTypeIdentifierPrecedesOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
-    checkSuggestedNameAndEstimatedSize(dataInteractionSimulator.get(), @"icon.png", { 215, 174 });
+    checkTypeIdentifierAndIsNotOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
+    checkEstimatedSize(dataInteractionSimulator.get(), { 215, 174 });
 }
 
 TEST(DataInteractionTests, CanStartDragOnEnormousImage)
@@ -190,16 +204,14 @@
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
 
-    NSURL *imageURL = [NSURL fileURLWithPath:[webView editorValue]];
-    EXPECT_WK_STREQ("icon.png", imageURL.lastPathComponent);
+    EXPECT_WK_STREQ("", [webView editorValue]);
 
     NSArray *observedEventNames = [dataInteractionSimulator observedEventNames];
     EXPECT_TRUE([observedEventNames containsObject:DataInteractionEnterEventName]);
     EXPECT_TRUE([observedEventNames containsObject:DataInteractionOverEventName]);
     EXPECT_TRUE([observedEventNames containsObject:DataInteractionPerformOperationEventName]);
-
-    checkTypeIdentifierPrecedesOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
-    checkSuggestedNameAndEstimatedSize(dataInteractionSimulator.get(), @"icon.png", { 215, 174 });
+    checkTypeIdentifierAndIsNotOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
+    checkEstimatedSize(dataInteractionSimulator.get(), { 215, 174 });
 }
 
 TEST(DataInteractionTests, ImageInLinkToInput)
@@ -225,9 +237,8 @@
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator runFrom:CGPointMake(100, 50) to:CGPointMake(100, 300)];
 
-    NSURL *imageURL = [NSURL fileURLWithPath:[webView editorValue]];
-    EXPECT_WK_STREQ("icon.png", imageURL.lastPathComponent);
-    checkSuggestedNameAndEstimatedSize(dataInteractionSimulator.get(), @"icon.png", { 215, 174 });
+    EXPECT_WK_STREQ("", [webView editorValue]);
+    checkEstimatedSize(dataInteractionSimulator.get(), { 215, 174 });
     checkTypeIdentifierIsRegisteredAtIndex(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, 0);
 }
 
@@ -1003,8 +1014,8 @@
     RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get()]);
     [dataInteractionSimulator runFrom:CGPointMake(200, 400) to:CGPointMake(200, 150)];
     EXPECT_WK_STREQ("PASS", [webView stringByEvaluatingJavaScript:@"target.textContent"].UTF8String);
-    checkTypeIdentifierPrecedesOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
-    checkSuggestedNameAndEstimatedSize(dataInteractionSimulator.get(), @"large-red-square.png", { 2000, 2000 });
+    checkTypeIdentifierAndIsNotOtherTypeIdentifier(dataInteractionSimulator.get(), (NSString *)kUTTypePNG, (NSString *)kUTTypeFileURL);
+    checkEstimatedSize(dataInteractionSimulator.get(), { 2000, 2000 });
 }
 
 TEST(DataInteractionTests, LinkWithEmptyHREF)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to