[Mac] Prioritize file promises over filenames during drag and drop
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2018 20:40:12 +0000 (20:40 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Apr 2018 20:40:12 +0000 (20:40 +0000)
commit44c61a6d6ef3343dbf8bb4b58c4fb109f0d3f307
treedc6e580becb16872b22626aef69a0e224ff91a32
parent2bfccf256c58de70db5a36a11b3dd21523303d08
[Mac] Prioritize file promises over filenames during drag and drop
https://bugs.webkit.org/show_bug.cgi?id=184237
<rdar://problem/38278076>

Reviewed by Wenson Hsieh.

Source/WebCore:

When performing a drag operation where the pasteboard contains both a file path and a file
promise, we have historically preferred to accept the file path. Some versions of Photos.app
will provide both a low-resolution thumbnail as a file path and its high-resolution
counterpart as a file promise when dragging a photo, and our current logic leads us to
choose the low-quality thumbnail.

This patch changes our logic to prefer file promises over file paths. This matches the
behavior of Finder and ensures we accept high-resolution assets from Photos.app.

Covered by existing file promise drag tests. beginDragWithFilePromises() was updated to
write a bogus file path to the pasteboard along with the legitimate file promise.

* platform/mac/DragDataMac.mm:
(WebCore::DragData::asFilenames const):
* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::read):
(WebCore::Pasteboard::readFilePaths):
* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::numberOfFiles const):

Source/WebKit:

* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::performDragOperation):

Source/WebKitLegacy/mac:

* WebView/WebView.mm:
(-[WebView performDragOperation:]):

Tools:

* DumpRenderTree/mac/EventSendingController.mm:
(-[EventSendingController beginDragWithFilePromises:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230221 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/mac/DragDataMac.mm
Source/WebCore/platform/mac/PasteboardMac.mm
Source/WebCore/platform/mac/PlatformPasteboardMac.mm
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebView.mm
Tools/ChangeLog
Tools/DumpRenderTree/mac/EventSendingController.mm