Title: [248624] branches/safari-608-branch
Revision
248624
Author
[email protected]
Date
2019-08-13 13:01:27 -0700 (Tue, 13 Aug 2019)

Log Message

Cherry-pick r248166. rdar://problem/54237837

    [macOS 10.15] Image dragged from Safari does not appear in Notes
    https://bugs.webkit.org/show_bug.cgi?id=188490
    <rdar://problem/39462717>

    Reviewed by Andy Estes.

    Source/WebKit:

    Removes some logic that clears out the cached promised drag image in the UI process when WebKit is asked to
    provide TIFF image data. This prevents the drop destination from asking for promised image data, if anything
    else (e.g. the system) also asks the web view to provide the same data. Additionally, this logic didn't
    previously guarantee that the promised image would be cleared anyways, since it is dependent on the drop target
    actually requesting the promised image in order to perform the cleanup.

    In lieu of clearing the promised drag image when it's requested, we instead clear it out upon mainframe
    navigation, in PageClientImpl::didCommitLoadForMainFrame.

    Test: DragAndDropTests.MultiplePromisedImageDataRequests

    * UIProcess/Cocoa/WebViewImpl.h:
    * UIProcess/Cocoa/WebViewImpl.mm:
    (WebKit::WebViewImpl::clearPromisedDragImage):
    (WebKit::WebViewImpl::pasteboardChangedOwner):
    (WebKit::WebViewImpl::provideDataForPasteboard):

    Fix the bug by not immediately clearing out the promised drag image.

    * UIProcess/mac/PageClientImplMac.mm:
    (WebKit::PageClientImpl::didCommitLoadForMainFrame):

    Tools:

    Add a test to verify that promised image data can be delivered to multiple pasteboards when performing a drop.

    * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:

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

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (248623 => 248624)


--- branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-13 20:01:24 UTC (rev 248623)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog	2019-08-13 20:01:27 UTC (rev 248624)
@@ -1,5 +1,78 @@
 2019-08-13  Alan Coon  <[email protected]>
 
+        Cherry-pick r248166. rdar://problem/54237837
+
+    [macOS 10.15] Image dragged from Safari does not appear in Notes
+    https://bugs.webkit.org/show_bug.cgi?id=188490
+    <rdar://problem/39462717>
+    
+    Reviewed by Andy Estes.
+    
+    Source/WebKit:
+    
+    Removes some logic that clears out the cached promised drag image in the UI process when WebKit is asked to
+    provide TIFF image data. This prevents the drop destination from asking for promised image data, if anything
+    else (e.g. the system) also asks the web view to provide the same data. Additionally, this logic didn't
+    previously guarantee that the promised image would be cleared anyways, since it is dependent on the drop target
+    actually requesting the promised image in order to perform the cleanup.
+    
+    In lieu of clearing the promised drag image when it's requested, we instead clear it out upon mainframe
+    navigation, in PageClientImpl::didCommitLoadForMainFrame.
+    
+    Test: DragAndDropTests.MultiplePromisedImageDataRequests
+    
+    * UIProcess/Cocoa/WebViewImpl.h:
+    * UIProcess/Cocoa/WebViewImpl.mm:
+    (WebKit::WebViewImpl::clearPromisedDragImage):
+    (WebKit::WebViewImpl::pasteboardChangedOwner):
+    (WebKit::WebViewImpl::provideDataForPasteboard):
+    
+    Fix the bug by not immediately clearing out the promised drag image.
+    
+    * UIProcess/mac/PageClientImplMac.mm:
+    (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+    
+    Tools:
+    
+    Add a test to verify that promised image data can be delivered to multiple pasteboards when performing a drop.
+    
+    * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-02  Wenson Hsieh  <[email protected]>
+
+            [macOS 10.15] Image dragged from Safari does not appear in Notes
+            https://bugs.webkit.org/show_bug.cgi?id=188490
+            <rdar://problem/39462717>
+
+            Reviewed by Andy Estes.
+
+            Removes some logic that clears out the cached promised drag image in the UI process when WebKit is asked to
+            provide TIFF image data. This prevents the drop destination from asking for promised image data, if anything
+            else (e.g. the system) also asks the web view to provide the same data. Additionally, this logic didn't
+            previously guarantee that the promised image would be cleared anyways, since it is dependent on the drop target
+            actually requesting the promised image in order to perform the cleanup.
+
+            In lieu of clearing the promised drag image when it's requested, we instead clear it out upon mainframe
+            navigation, in PageClientImpl::didCommitLoadForMainFrame.
+
+            Test: DragAndDropTests.MultiplePromisedImageDataRequests
+
+            * UIProcess/Cocoa/WebViewImpl.h:
+            * UIProcess/Cocoa/WebViewImpl.mm:
+            (WebKit::WebViewImpl::clearPromisedDragImage):
+            (WebKit::WebViewImpl::pasteboardChangedOwner):
+            (WebKit::WebViewImpl::provideDataForPasteboard):
+
+            Fix the bug by not immediately clearing out the promised drag image.
+
+            * UIProcess/mac/PageClientImplMac.mm:
+            (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+
+2019-08-13  Alan Coon  <[email protected]>
+
         Cherry-pick r248550. rdar://problem/54237677
 
     Contextual menu Hide and Show Link Previews should not have a symbol

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (248623 => 248624)


--- branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2019-08-13 20:01:24 UTC (rev 248623)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2019-08-13 20:01:27 UTC (rev 248624)
@@ -602,6 +602,7 @@
     bool effectiveUserInterfaceLevelIsElevated();
 
     void takeFocus(WebCore::FocusDirection);
+    void clearPromisedDragImage();
 
 private:
 #if HAVE(TOUCH_BAR)

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (248623 => 248624)


--- branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-08-13 20:01:24 UTC (rev 248623)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2019-08-13 20:01:27 UTC (rev 248624)
@@ -4205,9 +4205,14 @@
     m_promisedImage = image;
 }
 
+void WebViewImpl::clearPromisedDragImage()
+{
+    m_promisedImage = nullptr;
+}
+
 void WebViewImpl::pasteboardChangedOwner(NSPasteboard *pasteboard)
 {
-    m_promisedImage = nullptr;
+    clearPromisedDragImage();
     m_promisedFilename = emptyString();
     m_promisedURL = emptyString();
 }
@@ -4214,12 +4219,9 @@
 
 void WebViewImpl::provideDataForPasteboard(NSPasteboard *pasteboard, NSString *type)
 {
-    // FIXME: need to support NSRTFDPboardType
-
-    if ([type isEqual:WebCore::legacyTIFFPasteboardType()] && m_promisedImage) {
+    // FIXME: Need to support NSRTFDPboardType.
+    if ([type isEqual:WebCore::legacyTIFFPasteboardType()] && m_promisedImage)
         [pasteboard setData:(__bridge NSData *)m_promisedImage->tiffRepresentation() forType:WebCore::legacyTIFFPasteboardType()];
-        m_promisedImage = nullptr;
-    }
 }
 
 static BOOL fileExists(NSString *path)

Modified: branches/safari-608-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (248623 => 248624)


--- branches/safari-608-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2019-08-13 20:01:24 UTC (rev 248623)
+++ branches/safari-608-branch/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2019-08-13 20:01:27 UTC (rev 248624)
@@ -289,6 +289,7 @@
 {
     m_impl->updateSupportsArbitraryLayoutModes();
     m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
+    m_impl->clearPromisedDragImage();
 }
 
 void PageClientImpl::didFinishLoadingDataForCustomContentProvider(const String& suggestedFilename, const IPC::DataReference& dataReference)

Modified: branches/safari-608-branch/Tools/ChangeLog (248623 => 248624)


--- branches/safari-608-branch/Tools/ChangeLog	2019-08-13 20:01:24 UTC (rev 248623)
+++ branches/safari-608-branch/Tools/ChangeLog	2019-08-13 20:01:27 UTC (rev 248624)
@@ -1,5 +1,60 @@
 2019-08-13  Alan Coon  <[email protected]>
 
+        Cherry-pick r248166. rdar://problem/54237837
+
+    [macOS 10.15] Image dragged from Safari does not appear in Notes
+    https://bugs.webkit.org/show_bug.cgi?id=188490
+    <rdar://problem/39462717>
+    
+    Reviewed by Andy Estes.
+    
+    Source/WebKit:
+    
+    Removes some logic that clears out the cached promised drag image in the UI process when WebKit is asked to
+    provide TIFF image data. This prevents the drop destination from asking for promised image data, if anything
+    else (e.g. the system) also asks the web view to provide the same data. Additionally, this logic didn't
+    previously guarantee that the promised image would be cleared anyways, since it is dependent on the drop target
+    actually requesting the promised image in order to perform the cleanup.
+    
+    In lieu of clearing the promised drag image when it's requested, we instead clear it out upon mainframe
+    navigation, in PageClientImpl::didCommitLoadForMainFrame.
+    
+    Test: DragAndDropTests.MultiplePromisedImageDataRequests
+    
+    * UIProcess/Cocoa/WebViewImpl.h:
+    * UIProcess/Cocoa/WebViewImpl.mm:
+    (WebKit::WebViewImpl::clearPromisedDragImage):
+    (WebKit::WebViewImpl::pasteboardChangedOwner):
+    (WebKit::WebViewImpl::provideDataForPasteboard):
+    
+    Fix the bug by not immediately clearing out the promised drag image.
+    
+    * UIProcess/mac/PageClientImplMac.mm:
+    (WebKit::PageClientImpl::didCommitLoadForMainFrame):
+    
+    Tools:
+    
+    Add a test to verify that promised image data can be delivered to multiple pasteboards when performing a drop.
+    
+    * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248166 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-08-02  Wenson Hsieh  <[email protected]>
+
+            [macOS 10.15] Image dragged from Safari does not appear in Notes
+            https://bugs.webkit.org/show_bug.cgi?id=188490
+            <rdar://problem/39462717>
+
+            Reviewed by Andy Estes.
+
+            Add a test to verify that promised image data can be delivered to multiple pasteboards when performing a drop.
+
+            * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
+
+2019-08-13  Alan Coon  <[email protected]>
+
         Cherry-pick r248541. rdar://problem/54237768
 
     [iPadOS] Web pages sometimes load at half width in Safari

Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm (248623 => 248624)


--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm	2019-08-13 20:01:24 UTC (rev 248623)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm	2019-08-13 20:01:27 UTC (rev 248624)
@@ -135,4 +135,27 @@
     EXPECT_EQ(1, [webView stringByEvaluatingJavaScript:@"filecount.textContent"].integerValue);
 }
 
+TEST(DragAndDropTests, ProvideImageDataForMultiplePasteboards)
+{
+    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400)]);
+    TestWKWebView *webView = [simulator webView];
+    [webView synchronouslyLoadTestPageNamed:@"image-and-contenteditable"];
+    [simulator runFrom:NSMakePoint(100, 100) to:NSMakePoint(100, 300)];
+
+ALLOW_DEPRECATED_DECLARATIONS_BEGIN
+    NSPasteboard *dragPasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
+    NSPasteboard *uniquePasteboard = [NSPasteboard pasteboardWithUniqueName];
+    [webView pasteboard:dragPasteboard provideDataForType:NSTIFFPboardType];
+    [webView pasteboard:uniquePasteboard provideDataForType:NSTIFFPboardType];
+ALLOW_DEPRECATED_DECLARATIONS_END
+
+    NSArray *allowedClasses = @[ NSImage.class ];
+    NSImage *imageFromDragPasteboard = [dragPasteboard readObjectsForClasses:allowedClasses options:nil].firstObject;
+    NSImage *imageFromUniquePasteboard = [uniquePasteboard readObjectsForClasses:allowedClasses options:nil].firstObject;
+
+    EXPECT_EQ(imageFromUniquePasteboard.TIFFRepresentation.length, imageFromDragPasteboard.TIFFRepresentation.length);
+    EXPECT_TRUE(NSEqualSizes(imageFromDragPasteboard.size, imageFromUniquePasteboard.size));
+    EXPECT_FALSE(NSEqualSizes(NSZeroSize, imageFromUniquePasteboard.size));
+}
+
 #endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to