Changeset 248166 in webkit


Ignore:
Timestamp:
Aug 2, 2019 11:49:58 AM (5 years ago)
Author:
Wenson Hsieh
Message:

[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:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r248164 r248166  
     12019-08-02  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS 10.15] Image dragged from Safari does not appear in Notes
     4        https://bugs.webkit.org/show_bug.cgi?id=188490
     5        <rdar://problem/39462717>
     6
     7        Reviewed by Andy Estes.
     8
     9        Removes some logic that clears out the cached promised drag image in the UI process when WebKit is asked to
     10        provide TIFF image data. This prevents the drop destination from asking for promised image data, if anything
     11        else (e.g. the system) also asks the web view to provide the same data. Additionally, this logic didn't
     12        previously guarantee that the promised image would be cleared anyways, since it is dependent on the drop target
     13        actually requesting the promised image in order to perform the cleanup.
     14
     15        In lieu of clearing the promised drag image when it's requested, we instead clear it out upon mainframe
     16        navigation, in PageClientImpl::didCommitLoadForMainFrame.
     17
     18        Test: DragAndDropTests.MultiplePromisedImageDataRequests
     19
     20        * UIProcess/Cocoa/WebViewImpl.h:
     21        * UIProcess/Cocoa/WebViewImpl.mm:
     22        (WebKit::WebViewImpl::clearPromisedDragImage):
     23        (WebKit::WebViewImpl::pasteboardChangedOwner):
     24        (WebKit::WebViewImpl::provideDataForPasteboard):
     25
     26        Fix the bug by not immediately clearing out the promised drag image.
     27
     28        * UIProcess/mac/PageClientImplMac.mm:
     29        (WebKit::PageClientImpl::didCommitLoadForMainFrame):
     30
    1312019-08-02  Keith Rollin  <krollin@apple.com>
    232
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h

    r246938 r248166  
    603603
    604604    void takeFocus(WebCore::FocusDirection);
     605    void clearPromisedDragImage();
    605606
    606607private:
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r247460 r248166  
    42064206}
    42074207
     4208void WebViewImpl::clearPromisedDragImage()
     4209{
     4210    m_promisedImage = nullptr;
     4211}
     4212
    42084213void WebViewImpl::pasteboardChangedOwner(NSPasteboard *pasteboard)
    42094214{
    4210     m_promisedImage = nullptr;
     4215    clearPromisedDragImage();
    42114216    m_promisedFilename = emptyString();
    42124217    m_promisedURL = emptyString();
     
    42154220void WebViewImpl::provideDataForPasteboard(NSPasteboard *pasteboard, NSString *type)
    42164221{
    4217     // FIXME: need to support NSRTFDPboardType
    4218 
    4219     if ([type isEqual:WebCore::legacyTIFFPasteboardType()] && m_promisedImage) {
     4222    // FIXME: Need to support NSRTFDPboardType.
     4223    if ([type isEqual:WebCore::legacyTIFFPasteboardType()] && m_promisedImage)
    42204224        [pasteboard setData:(__bridge NSData *)m_promisedImage->tiffRepresentation() forType:WebCore::legacyTIFFPasteboardType()];
    4221         m_promisedImage = nullptr;
    4222     }
    42234225}
    42244226
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r246938 r248166  
    290290    m_impl->updateSupportsArbitraryLayoutModes();
    291291    m_impl->dismissContentRelativeChildWindowsWithAnimation(true);
     292    m_impl->clearPromisedDragImage();
    292293}
    293294
  • trunk/Tools/ChangeLog

    r248163 r248166  
     12019-08-02  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [macOS 10.15] Image dragged from Safari does not appear in Notes
     4        https://bugs.webkit.org/show_bug.cgi?id=188490
     5        <rdar://problem/39462717>
     6
     7        Reviewed by Andy Estes.
     8
     9        Add a test to verify that promised image data can be delivered to multiple pasteboards when performing a drop.
     10
     11        * TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm:
     12
    1132019-08-02  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Tools/TestWebKitAPI/Tests/mac/DragAndDropTestsMac.mm

    r242339 r248166  
    136136}
    137137
     138TEST(DragAndDropTests, ProvideImageDataForMultiplePasteboards)
     139{
     140    auto simulator = adoptNS([[DragAndDropSimulator alloc] initWithWebViewFrame:NSMakeRect(0, 0, 400, 400)]);
     141    TestWKWebView *webView = [simulator webView];
     142    [webView synchronouslyLoadTestPageNamed:@"image-and-contenteditable"];
     143    [simulator runFrom:NSMakePoint(100, 100) to:NSMakePoint(100, 300)];
     144
     145ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     146    NSPasteboard *dragPasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
     147    NSPasteboard *uniquePasteboard = [NSPasteboard pasteboardWithUniqueName];
     148    [webView pasteboard:dragPasteboard provideDataForType:NSTIFFPboardType];
     149    [webView pasteboard:uniquePasteboard provideDataForType:NSTIFFPboardType];
     150ALLOW_DEPRECATED_DECLARATIONS_END
     151
     152    NSArray *allowedClasses = @[ NSImage.class ];
     153    NSImage *imageFromDragPasteboard = [dragPasteboard readObjectsForClasses:allowedClasses options:nil].firstObject;
     154    NSImage *imageFromUniquePasteboard = [uniquePasteboard readObjectsForClasses:allowedClasses options:nil].firstObject;
     155
     156    EXPECT_EQ(imageFromUniquePasteboard.TIFFRepresentation.length, imageFromDragPasteboard.TIFFRepresentation.length);
     157    EXPECT_TRUE(NSEqualSizes(imageFromDragPasteboard.size, imageFromUniquePasteboard.size));
     158    EXPECT_FALSE(NSEqualSizes(NSZeroSize, imageFromUniquePasteboard.size));
     159}
     160
    138161#endif // ENABLE(DRAG_SUPPORT) && PLATFORM(MAC)
Note: See TracChangeset for help on using the changeset viewer.