[Webkit-unassigned] [Bug 218519] [GTK] Can't paste image data (like image/png) from the clipboard in WebKit browsers

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 14 10:50:09 PST 2021


https://bugs.webkit.org/show_bug.cgi?id=218519

--- Comment #25 from Miikka <miikka.veijonen at gmail.com> ---
(In reply to 荒野無燈 from comment #23)
> (In reply to Miikka from comment #22)
> > (In reply to 荒野無燈 from comment #18)
> > > Created attachment 433288 [details]
> > > fix: fallback to readBufferFromClipboard if readFilePathsFromClipboard get
> > > no files, this fix makes ctrl + v paste image under GTK  works
> > > 
> > > in Source/WebCore/dom/DataTransfer.cpp 
> > > DataTransfer::filesFromPasteboardAndItemList
> > > 
> > > ```cpp
> > >  WebCorePasteboardFileReader reader(context);
> > >  m_pasteboard->read(reader);
> > >  files = WTFMove(reader.files);
> > > ```
> > > 
> > > it only calls `void Pasteboard::read(PasteboardFileReader& reader,
> > > std::optional<size_t>)`, 
> > > 
> > > and `Pasteboard::read(PasteboardWebContentReader& reader,
> > > WebContentReadingPolicy policy, std::optional<size_t>)` got no chances, so
> > > the image data dit not got read.
> > > 
> > > this patch is a workaround to fixup the problem (tested under webkitgtk
> > > 2.32.0 and 2.32.1).
> > > 
> > > by patching `void Pasteboard::read(PasteboardFileReader& reader,
> > > std::optional<size_t>)`,  and call
> > > `WebCorePasteboardFileReader::readBuffer`, we can make
> > > `DataTransferItem::getAsFile()` get the image file data.
> > 
> > Thanks. I applied the patch you linked
> > (https://bugs.webkit.org/attachment.cgi?id=433288&action=diff) against
> > webkitgtk 2.32.2 and the compiled it and then compiled Epiphany 40.2 against
> > that webkitgtk build but pasting image data from the clipboard still does
> > not work for me.
> > 
> > Is this https://bugs.webkit.org/attachment.cgi?id=433288&action=diff enough
> > or should I apply something else too? Waht do you mean with this: "by
> > patching `void Pasteboard::read(PasteboardFileReader& reader,
> > std::optional<size_t>)`,  and call
> > `WebCorePasteboardFileReader::readBuffer`, we can make
> > `DataTransferItem::getAsFile()` get the image file data."?
> 
> just use this patch will works fine.
> 
> please note that this patch does not related to GNOME Web browser Epiphany.
> 
> I compared from webkitgtk-2.32.0 to webkitgtk-2.32.2, the
> `Source/WebCore/platform/gtk/PasteboardGtk.cpp` file are all the same, 
> I tested the patch under webkitgtk 2.32.0 and 2.32.1, so I do think it
> should works for 2.32.2
> 
> by the way, I use this page (thanks Sonny Piers) to test:
> https://codepen.io/tmrDevelops/pen/YxGQaW
> 
> and I also tested it under Epiphany 40.1 on Ubuntu 21.04
> (https://i.ibb.co/FXhhSYZ/Epiphany-40-1-on-Ubuntu-21-042021-07-12-21-07.png),
> and Epiphany Technology Preview 41.alpha-4-g70730e4dd+ does not work. but I
> recommend you not to verify the patch via Epiphany browser, this will
> introduce more variable.
> 
> Using a simple code (in your favorite lang) to create a webview, then
> loading the page: https://codepen.io/tmrDevelops/pen/YxGQaW and then see if
> it works.
> 
> In my situation, I use the WebKitGtk lib via
> https://github.com/gtk-rs/webkit2gtk-rs
> 
> hope this will help you.

Yes, I tested this by using the WebKit4GTK MiniBrowser now (/usr/lib/x86_64-linux-gnu/webkit2gtk-4.0/MiniBrowser) and the image data pasting works there (both in normal and in editor mode: --editor-mode). But in other WebKit based browsers, like Epiphany it still does not work :(

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211214/6a03db06/attachment.htm>


More information about the webkit-unassigned mailing list