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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Jul 11 06:33:22 PDT 2021


--- Comment #18 from 荒野無燈 <ttys3.rust at gmail.com> ---
Created attachment 433288

  --> https://bugs.webkit.org/attachment.cgi?id=433288&action=review

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

 WebCorePasteboardFileReader reader(context);
 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.

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/20210711/865ff393/attachment-0001.htm>

More information about the webkit-unassigned mailing list