[webkit-changes] [WebKit/WebKit] a035a7: [iOS] "text/uri-list" can't be read upon paste if ...

Wenson Hsieh noreply at github.com
Tue Oct 18 16:43:33 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a035a72e61b9e468def2ac54f8ed8ff9be06bbb8
      https://github.com/WebKit/WebKit/commit/a035a72e61b9e468def2ac54f8ed8ff9be06bbb8
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2022-10-18 (Tue, 18 Oct 2022)

  Changed paths:
    M Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
    M Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/dump-datatransfer-types.html
    M Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm

  Log Message:
  -----------
  [iOS] "text/uri-list" can't be read upon paste if the pasteboard set NSData for "public.url"
https://bugs.webkit.org/show_bug.cgi?id=246699
rdar://96854364

Reviewed by Tim Horton.

Currently, when copying from apps that write serialized URLs as `NSData` for the "public.url" type
and pasting into WebKit views, "text/uri-list" doesn't appear in `DataTransfer.types` upon paste,
and requesting "text/uri-list" using `getData()` just returns the empty string.

This is because `PlatformPasteboard::readURL()` uses `-valuesForPasteboardType:inItemSet:` to
collect URLs and expects the resulting value to be an `NSURL`; however, in this case, it ends up
being an `NSData`.

Since inserting data-backed URLs from the pasteboard works in native text views on iOS, we should
ensure that it also works for web views by falling back to `NSData`, if the value on the pasteboard
is not already an `NSURL`.

* Source/WebCore/platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::readURL const):

Also modernize this code a bit by using `dynamic_objc_cast<>` when converting the read value.

* Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:

Link against UniformTypeIdentifiers.framework so that we can use UTTypeURL on iOS.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/dump-datatransfer-types.html:
* Tools/TestWebKitAPI/Tests/ios/UIPasteboardTests.mm:

Additionally add an API test to exercise the change.

(TestWebKitAPI::TEST):

Canonical link: https://commits.webkit.org/255704@main




More information about the webkit-changes mailing list