[Attachment Support] Add plumbing for starting a drag with promised blob data
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 05:58:03 +0000 (05:58 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Jan 2018 05:58:03 +0000 (05:58 +0000)
commitbb07117dbf417b349915f2c94051fb83fcdd45f3
tree0a3ba9fc4328f3794e827613d09692905d9a8794
parentcf820e2fea55d540850c1ac0f2489dae1720caf4
[Attachment Support] Add plumbing for starting a drag with promised blob data
https://bugs.webkit.org/show_bug.cgi?id=181201

Reviewed by Tim Horton.

Source/WebCore:

Adds logic to allow dragging an attachment element as a file by sending promised blob information to the UI
process. See comments below for more detail.

The only change in behavior is that dragging an attachment element will no longer write web content and injected
bundle data to the pasteboard if the attachment element's file attribute is nonnull. This will cause one
existing WK1 layout test to fail, but will otherwise not affect any attachment editing clients. On iOS,
attachment elements in the Mail viewer can be dragged, but each attachment's file is null, so we fall back to
current behavior; on macOS, Mail currently overrides the drag completely, beginning at -mouseDown:, so this
doesn't make a difference to macOS Mail either.

* editing/Editor.h:
* editing/cocoa/EditorCocoa.mm:
(WebCore::Editor::getPasteboardTypesAndDataForAttachment):

Add a helper method to retrieve an attachment element as web archive data, for moving attachments within the
same document. Also gives the injected editor bundle a chance to supply custom pasteboard types.

* loader/EmptyClients.cpp:
* page/DragClient.h:
(WebCore::DragClient::prepareToDragPromisedBlob):

Add new DragClient methods to send information about a promised blob to the UI process.

* page/DragController.cpp:
(WebCore::DragController::startDrag):

Call dragAttachmentElement when starting a drag on an attachment element.

(WebCore::DragController::dragAttachmentElement):

Try to begin dragging a given attachment element, propagating promised blob information to the client layers.
Returns true iff the attachment is backed by blob data (i.e. the file is nonnull).

* platform/PromisedBlobInfo.h:

Add a list of additional types and data to PromisedBlobInfo. In addition to the promised blob info, this would
allow injected bundle data and other private types alongside the main attachment data on the pasteboard.

Source/WebKit:

Add boilerplate plumbing for PrepareToDragPromisedBlob, which delivers blob promises to the UI process when
dragging, respectively.

* Scripts/webkit/messages.py:
(headers_for_type):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::encodeTypesAndData):
(IPC::decodeTypesAndData):
(IPC::ArgumentCoder<PasteboardWebContent>::encode):
(IPC::ArgumentCoder<PasteboardWebContent>::decode):
(IPC::ArgumentCoder<PasteboardImage>::encode):
(IPC::ArgumentCoder<PasteboardImage>::decode):
(IPC::ArgumentCoder<PromisedBlobInfo>::encode):
(IPC::ArgumentCoder<PromisedBlobInfo>::decode):

Add IPC support PromisedBlobInfo's additionalTypes and additionalData.

(IPC::encodeClientTypesAndData): Deleted.
(IPC::decodeClientTypesAndData): Deleted.

Rename these helper functions and move them to the top of the file.

* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::prepareToDragPromisedBlob):
* UIProcess/PageClient.h:
(WebKit::PageClient::prepareToDragPromisedBlob):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::prepareToDragPromisedBlob):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::prepareToDragPromisedBlob):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _prepareToDragPromisedBlob:]):
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::prepareToDragPromisedBlob):
* WebProcess/WebCoreSupport/WebDragClient.cpp:
(WebKit::WebDragClient::prepareToDragPromisedBlob):
* WebProcess/WebCoreSupport/WebDragClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::prepareToDragPromisedBlob):
* WebProcess/WebPage/WebPage.h:

Source/WebKitLegacy/mac:

Minor adjustment to account for a DragClient interface change. See WebCore ChangeLog for more details.

* WebCoreSupport/WebDragClient.h:

LayoutTests:

Remove a WK1 LayoutTest testing drag and drop of an attachment element into a contenteditable. This test no
longer passes because the implementation of attachment dragging on macOS is not yet implemented. Subsequent
patches will test this scenario once again, but as a WK2 macOS drag and drop API test.

* editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt: Removed.
* editing/pasteboard/drag-and-drop-attachment-contenteditable.html: Removed.
* platform/gtk/TestExpectations:
* platform/ios/TestExpectations:
* platform/mac-wk2/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226393 268f45cc-cd09-0410-ab3c-d52691b4dbfc
36 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable-expected.txt [deleted file]
LayoutTests/editing/pasteboard/drag-and-drop-attachment-contenteditable.html [deleted file]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios/TestExpectations
LayoutTests/platform/mac-wk2/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.h
Source/WebCore/editing/cocoa/EditorCocoa.mm
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/page/DragClient.h
Source/WebCore/page/DragController.cpp
Source/WebCore/page/DragController.h
Source/WebCore/platform/PromisedBlobInfo.h
Source/WebKit/ChangeLog
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/UIProcess/Cocoa/WebViewImpl.h
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKit/UIProcess/PageClient.h
Source/WebKit/UIProcess/WebPageProxy.cpp
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/ios/PageClientImplIOS.h
Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/UIProcess/mac/PageClientImplMac.h
Source/WebKit/UIProcess/mac/PageClientImplMac.mm
Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebDragClient.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebDragClient.h