Support writing link titles to the pasteboard when beginning data interaction on...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Apr 2017 06:18:53 +0000 (06:18 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Apr 2017 06:18:53 +0000 (06:18 +0000)
commitf417d9975ee228d3d0e55e94ea399b8d4fdbcbc4
tree84e73cdf248aafe9aeb7fb6bbcc260db23740160
parent455bf770f014ad81d5fdbc7a8c6d597a29d61d9e
Support writing link titles to the pasteboard when beginning data interaction on a link
https://bugs.webkit.org/show_bug.cgi?id=171154
<rdar://problem/31356937>

Reviewed by Andy Estes.

Source/WebCore:

Currently, when writing NSURLs to the pasteboard, we only write a String to the pasteboard corresponding to
kUTTypeURL. This means richer data associated with the link (in this case, the title) are not captured when
writing to the pasteboard. To address this, we introduce a new codepath for writing links to the pasteboard that
mirrors the way PasteboardImage and PasteboardWebContent are written to the pasteboard.

Test: Augmented DataInteractionTests.LinkToInput.

* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:

Add plumbing support for writing PasteboardURLs.

* platform/ios/PasteboardIOS.mm:
(WebCore::Pasteboard::write):
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::writeObjectRepresentations):

Teach PlatformPasteboard to also set the _title attribute of the NSURL when creating an NSURL representation
for registering with the shared WebItemProviderPasteboard.

(WebCore::PlatformPasteboard::write):
* platform/ios/WebItemProviderPasteboard.mm:

Remove deprecation guards and replace deprecated method calls with the latest undeprecated versions.

(-[WebItemProviderPasteboard setItemsFromObjectRepresentations:]):

Source/WebKit/mac:

Adjust for some changes in WebCore to introduce a separate codepath for writing PasteboardURLs. See WebCore
and WebKit2 ChangeLogs for more details.

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::writeToPasteboard):

Source/WebKit2:

Adds support for setting the _title attribute of NSURLs written to the pasteboard. See WebCore ChangeLog for more details.

* Scripts/webkit/messages.py:
(headers_for_type):
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<PasteboardURL>::encode):
(IPC::ArgumentCoder<PasteboardURL>::decode):
* Shared/WebCoreArgumentCoders.h:

Teach PasteboardURL to be serialized in IPC. For now, we just send across the absolute string of the link and
its title.

* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::writeURLToPasteboard):
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.messages.in:

Add IPC plumbing for writing PasteboarURLs to the pasteboard.

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::writeToPasteboard):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

Tools:

Augments an existing unit test, DataInteractionTests.LinkToInput, to also check that the fetching the NSURL from
the source UIItemProvider generated by performing data interaction results in an NSURL with the _title attribute
matching the title of the link.

* TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/PasteboardStrategy.h
Source/WebCore/platform/PlatformPasteboard.h
Source/WebCore/platform/ios/PasteboardIOS.mm
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Source/WebCore/platform/ios/WebItemProviderPasteboard.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.h
Source/WebKit/mac/WebCoreSupport/WebPlatformStrategies.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Scripts/webkit/messages.py
Source/WebKit2/Shared/WebCoreArgumentCoders.cpp
Source/WebKit2/Shared/WebCoreArgumentCoders.h
Source/WebKit2/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
Source/WebKit2/UIProcess/WebPasteboardProxy.h
Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm