Bug 211511 - [GTK] Rework clipboard handling in preparation for GTK4
Summary: [GTK] Rework clipboard handling in preparation for GTK4
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: GTK4 211561 211723
  Show dependency treegraph
 
Reported: 2020-05-06 06:54 PDT by Carlos Garcia Campos
Modified: 2020-05-12 08:20 PDT (History)
4 users (show)

See Also:


Attachments
Patch (66.74 KB, patch)
2020-05-06 07:05 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (67.24 KB, patch)
2020-05-07 05:21 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Patch (68.36 KB, patch)
2020-05-11 05:50 PDT, Carlos Garcia Campos
aperez: review+
Details | Formatted Diff | Diff
Patch for landing (69.54 KB, patch)
2020-05-12 07:16 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2020-05-06 06:54:44 PDT
Use async APIs to avoid blocking the UI process during the communication with the clipboard. In GTK4 only async APIs are available.
Comment 1 Carlos Garcia Campos 2020-05-06 07:05:08 PDT
Created attachment 398610 [details]
Patch
Comment 2 Carlos Garcia Campos 2020-05-07 05:21:54 PDT
Created attachment 398723 [details]
Patch
Comment 3 Carlos Garcia Campos 2020-05-11 05:50:48 PDT
Created attachment 399013 [details]
Patch
Comment 4 Adrian Perez 2020-05-12 06:50:52 PDT
Comment on attachment 399013 [details]
Patch

Looks good overall, with a few nits you may want to take a look at before landing.


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

> Source/WebCore/editing/gtk/WebContentReaderGtk.cpp:53
> +bool WebContentReader::readFilePaths(const Vector<String>& paths)

This is exactly the same implementation as for Cocoa, and it seems like a reasonable
default implementation for any port. I would move this into “WebContentReader.cpp” and
share the code.

> Source/WebCore/editing/gtk/WebContentReaderGtk.cpp:93
> +bool WebContentReader::readURL(const URL&, const String&)

The Cocoa port creates an anchor element when reading an URL, resulting in a
fragment with something like “<a href="url">title-or-url</a>” being added.

I think it makes sense to mimic that behavior. Feel free to leave a TODO note
here to do that later on as a follow-up patch.

> Source/WebCore/editing/gtk/WebContentReaderGtk.cpp:98
> +bool WebContentMarkupReader::readHTML(const String&)

This could also be implemented, seems easy enough to call “sanitizeMarkup()” on the
input string and use the result from that.

Feel free to leave it as a TODO for a follow-up patch as well.

> Source/WebCore/platform/gtk/PasteboardGtk.cpp:106
> +    ASSERT(m_selectionData);

Shouldn't this be also a “RELEASE_ASSERT()” as above? It looks like to me
that both assertions should be of the same kind.
Comment 5 Carlos Garcia Campos 2020-05-12 07:05:11 PDT
Comment on attachment 399013 [details]
Patch

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

>> Source/WebCore/editing/gtk/WebContentReaderGtk.cpp:93
>> +bool WebContentReader::readURL(const URL&, const String&)
> 
> The Cocoa port creates an anchor element when reading an URL, resulting in a
> fragment with something like “<a href="url">title-or-url</a>” being added.
> 
> I think it makes sense to mimic that behavior. Feel free to leave a TODO note
> here to do that later on as a follow-up patch.

We don't really support URLs, we use _NETSCAPE_URL for drag an drop and the html markup is already generated so it's always handled as text/html. This is never called for GTK port.

>> Source/WebCore/editing/gtk/WebContentReaderGtk.cpp:98
>> +bool WebContentMarkupReader::readHTML(const String&)
> 
> This could also be implemented, seems easy enough to call “sanitizeMarkup()” on the
> input string and use the result from that.
> 
> Feel free to leave it as a TODO for a follow-up patch as well.

I'm not sure this is called for the GTK port either, I'll check.

>> Source/WebCore/platform/gtk/PasteboardGtk.cpp:106
>> +    ASSERT(m_selectionData);
> 
> Shouldn't this be also a “RELEASE_ASSERT()” as above? It looks like to me
> that both assertions should be of the same kind.

No, the other should be ASSERT instead, since I don't usually build with debug I use release assert during development and then convert them to asserts, but I guess I forgot one.

> Source/WebCore/platform/gtk/PasteboardGtk.cpp:249
> +void Pasteboard::read(PasteboardWebContentReader& reader, WebContentReadingPolicy policy, Optional<size_t>)

This is where the WebContentReader is used and we don't call reader.readURL(), that's why it's unimplemented.
Comment 6 Carlos Garcia Campos 2020-05-12 07:16:47 PDT
Created attachment 399126 [details]
Patch for landing
Comment 7 Carlos Garcia Campos 2020-05-12 08:20:38 PDT
Committed r261554: <https://trac.webkit.org/changeset/261554>