[iOS DnD] Allow the injected bundle to add client data when writing an image to the...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jun 2017 20:05:07 +0000 (20:05 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 Jun 2017 20:05:07 +0000 (20:05 +0000)
commit0ece3c39f3f14dfaa9ff56bd2b59e02e34fef05f
tree2c89ce509b0488f8257d03c31478d8271acd7084
parent05395c641fca8970817f8c12a75481861a23a15f
[iOS DnD] Allow the injected bundle to add client data when writing an image to the pasteboard
https://bugs.webkit.org/show_bug.cgi?id=173238
<rdar://problem/31943370>

Reviewed by Ryosuke Niwa and Tim Horton.

Source/WebCore:

Add clientTypes and clientData to PasteboardImage, and call out to the injected bundle using
getClientPasteboardDataForRange when writing a PasteboardImage. When generating item providers for dragging in
the UI process in PlatformPasteboard, add any available client data as representations to the initialization
list used to set the WebItemProviderPasteboard.

Test: DataInteraction.InjectedBundleImageElementData

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

Source/WebKit2:

Send PasteboardImage.clientTypes and PasteboardImage.clientData over IPC.

* Shared/WebCoreArgumentCoders.cpp:
(IPC::encodeClientTypesAndData):
(IPC::decodeClientTypesAndData):

Factor out common logic used to encode and decode client types and data into static helpers.

(IPC::ArgumentCoder<PasteboardWebContent>::encode):
(IPC::ArgumentCoder<PasteboardWebContent>::decode):
(IPC::ArgumentCoder<PasteboardImage>::encode):
(IPC::ArgumentCoder<PasteboardImage>::decode):

Tools:

Add a new unit test to verify that data inserted by the injected bundle when beginning a drag on an image
element is plumbed across to the UI delegate. Also refactors injected bundle unit tests to use the new version
of adjustedDataInteractionItemProvidersForItemProvider: that takes representing objects and additional data.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/DataInteractionSimulator.h:
* TestWebKitAPI/ios/DataInteractionSimulator.mm:
(-[DataInteractionSimulator _webView:adjustedDataInteractionItemProvidersForItemProvider:representingObjects:additionalData:]):
(-[DataInteractionSimulator _webView:adjustedDataInteractionItemProviders:]): Deleted.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218128 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/editing/ios/EditorIOS.mm
Source/WebCore/platform/Pasteboard.h
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm
Tools/TestWebKitAPI/ios/DataInteractionSimulator.h
Tools/TestWebKitAPI/ios/DataInteractionSimulator.mm