Bug 202622 - [Clipboard API] Introduce bindings for the async Clipboard API
Summary: [Clipboard API] Introduce bindings for the async Clipboard API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-10-06 20:28 PDT by Wenson Hsieh
Modified: 2019-10-08 07:50 PDT (History)
29 users (show)

See Also:


Attachments
IDL files and API stubs. (62.13 KB, patch)
2019-10-07 09:39 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Fix CMake builds (62.49 KB, patch)
2019-10-07 09:45 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Adjust WK1 test expectations. (62.75 KB, patch)
2019-10-07 11:22 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Incorporate review feedback + rebase on trunk (66.40 KB, patch)
2019-10-07 17:09 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Fix WPE build (66.42 KB, patch)
2019-10-07 17:31 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Try to fix GTK/WPE build again (66.42 KB, patch)
2019-10-07 17:52 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Try to fix GTK/WPE build (3) (66.44 KB, patch)
2019-10-07 20:08 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Rebase on trunk again (66.39 KB, patch)
2019-10-07 21:59 PDT, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2019-10-06 20:28:18 PDT
Work in progress towards implementing the async Clipboard API.
Comment 1 Radar WebKit Bug Importer 2019-10-07 09:04:18 PDT
<rdar://problem/56038126>
Comment 2 Wenson Hsieh 2019-10-07 09:39:05 PDT Comment hidden (obsolete)
Comment 3 Wenson Hsieh 2019-10-07 09:40:11 PDT
I’m working on upstreaming the existing web platform tests as well.
Comment 4 Wenson Hsieh 2019-10-07 09:45:36 PDT Comment hidden (obsolete)
Comment 5 Wenson Hsieh 2019-10-07 11:22:25 PDT
Created attachment 380339 [details]
Adjust WK1 test expectations.
Comment 6 Ryosuke Niwa 2019-10-07 13:46:07 PDT
Comment on attachment 380339 [details]
Adjust WK1 test expectations.

View in context: https://bugs.webkit.org/attachment.cgi?id=380339&action=review

You can fix the GC issue in a separate patch but please be sure to file a bug before landing this so that we won't forget to fix it.

> Source/WebCore/ChangeLog:9
> +        Adds IDL support for the async clipboard API (with the exception of delayed item generation interfaces, which

Nit: Adds IDL. It's not like IDL is a feature to support.x

> Source/WebCore/ChangeLog:11
> +

Please add a link to the spec.

> Source/WebCore/ChangeLog:18
> +        * Modules/clipboard/Clipboard.cpp:

Can we use Modules/async-clipboard/ instead?
It's a bit confusing as is since we already have the support for sync clipboard API support.

> Source/WebCore/Modules/clipboard/Clipboard.h:58
> +    void refEventTarget() final { ref(); }
> +    void derefEventTarget() final { deref(); }

Why do we need these??

> Source/WebCore/Modules/clipboard/Clipboard.idl:32
> +    EnabledBySetting=AsyncClipboardAPI,
> +] interface Clipboard : EventTarget {

Probably need GenerateIsReachable=ReachableFromDOMWindow or something.
Otherwise, the wrapper of this object can be collected.

> Source/WebCore/Modules/clipboard/ClipboardItem.idl:40
> +    ImplementationLacksVTable
> +] interface ClipboardItem {

We need to start thinking about GC model of this object.
You'd probably need to make this item's Clipboard an opaque root if it's associated with one.
Alternatively, add GenerateIsReachable=ReachableFromDOMWindow
and make it return DOMWindow* when it's associated with Clipboard.

> Source/WebCore/Modules/clipboard/NavigatorClipboard.h:43
> +    static Clipboard* clipboard(Navigator&);
> +    Clipboard* clipboard();

Return RefPtr instead?

> LayoutTests/platform/ios-wk1/TestExpectations:19
> +# Async Clipboard API is not supported in WebKit1.
> +editing/clipboard [ Skip ]
> +

Can we add the support in a subsequent patch? It's not great to have discrepancy between WK1 and WK2 if we can avoid it.
Comment 7 Wenson Hsieh 2019-10-07 15:10:15 PDT
Comment on attachment 380339 [details]
Adjust WK1 test expectations.

View in context: https://bugs.webkit.org/attachment.cgi?id=380339&action=review

>> Source/WebCore/ChangeLog:9
>> +        Adds IDL support for the async clipboard API (with the exception of delayed item generation interfaces, which
> 
> Nit: Adds IDL. It's not like IDL is a feature to support.x

Fixed.

>> Source/WebCore/ChangeLog:11
>> +
> 
> Please add a link to the spec.

Added.

>> Source/WebCore/ChangeLog:18
>> +        * Modules/clipboard/Clipboard.cpp:
> 
> Can we use Modules/async-clipboard/ instead?
> It's a bit confusing as is since we already have the support for sync clipboard API support.

Sure! Renamed to async-clipboard. I also renamed the tests in the editing directory from clipboard to async-clipboard to match.

>> Source/WebCore/Modules/clipboard/Clipboard.h:58
>> +    void derefEventTarget() final { deref(); }
> 
> Why do we need these??

Clipboard is an EventTarget, and these are pure virtual methods on EventTarget. It looks like all other event target subclasses override refEventTarget() and derefEventTarget(), as well.

>> Source/WebCore/Modules/clipboard/Clipboard.idl:32
>> +] interface Clipboard : EventTarget {
> 
> Probably need GenerateIsReachable=ReachableFromDOMWindow or something.
> Otherwise, the wrapper of this object can be collected.

Good catch! I added `GenerateIsReachable=ReachableFromNavigator` here to ensure that the wrapper object is kept alive by the Navigator, and then added a new layout test to verify that the wrapper is kept alive between GC passes.

>> Source/WebCore/Modules/clipboard/ClipboardItem.idl:40
>> +] interface ClipboardItem {
> 
> We need to start thinking about GC model of this object.
> You'd probably need to make this item's Clipboard an opaque root if it's associated with one.
> Alternatively, add GenerateIsReachable=ReachableFromDOMWindow
> and make it return DOMWindow* when it's associated with Clipboard.

Good call. As we chatted about in person, I’ll make this reachable from navigator, with the intention of returning the Clipboard’s navigator if the item is associated with a Clipboard (and otherwise, return null).

Since all APIs are stubs at the moment and there’s no way to get items associated with a Clipboard yet, this will just return null for now, until the subsequent patch that adds support for Clipboard.read().

>> Source/WebCore/Modules/clipboard/NavigatorClipboard.h:43
>> +    Clipboard* clipboard();
> 
> Return RefPtr instead?

Done!

>> LayoutTests/platform/ios-wk1/TestExpectations:19
>> +
> 
> Can we add the support in a subsequent patch? It's not great to have discrepancy between WK1 and WK2 if we can avoid it.

Okay — I filed https://bugs.webkit.org/show_bug.cgi?id=202654 to track this effort, and referenced the bug in the test expectations.
Comment 8 Wenson Hsieh 2019-10-07 17:09:07 PDT Comment hidden (obsolete)
Comment 9 Wenson Hsieh 2019-10-07 17:31:03 PDT Comment hidden (obsolete)
Comment 10 Wenson Hsieh 2019-10-07 17:52:38 PDT Comment hidden (obsolete)
Comment 11 Wenson Hsieh 2019-10-07 20:08:15 PDT Comment hidden (obsolete)
Comment 12 Wenson Hsieh 2019-10-07 21:59:01 PDT
Created attachment 380401 [details]
Rebase on trunk again
Comment 13 WebKit Commit Bot 2019-10-08 07:50:34 PDT
Comment on attachment 380401 [details]
Rebase on trunk again

Clearing flags on attachment: 380401

Committed r250824: <https://trac.webkit.org/changeset/250824>
Comment 14 WebKit Commit Bot 2019-10-08 07:50:37 PDT
All reviewed patches have been landed.  Closing bug.