config/patches/base/webkitgtk/PasteboardGtk-fix-paste-images.patch
2022-02-05 20:47:50 +01:00

50 lines
2.6 KiB
Diff

diff --git b/Source/WebCore/platform/gtk/PasteboardGtk.cpp a/Source/WebCore/platform/gtk/PasteboardGtk.cpp
index fbe7198..6693af0 100644
--- b/Source/WebCore/platform/gtk/PasteboardGtk.cpp
+++ a/Source/WebCore/platform/gtk/PasteboardGtk.cpp
@@ -315,15 +315,43 @@ void Pasteboard::read(PasteboardWebContentReader& reader, WebContentReadingPolic
void Pasteboard::read(PasteboardFileReader& reader, Optional<size_t>)
{
+ WTFLogAlways("xxoo Pasteboard::read PasteboardFileReader");
if (m_selectionData) {
- for (const auto& filePath : m_selectionData->filenames())
+ WTFLogAlways("xxoo Pasteboard::read m_selectionData");
+ for (const auto& filePath : m_selectionData->filenames()) {
+ WTFLogAlways("xxoo Pasteboard::read m_selectionData reader.readFilename filePath=%s", filePath.utf8().data());
reader.readFilename(filePath);
+ }
return;
}
+
+ WTFLogAlways("xxoo Pasteboard::read readFilePathsFromClipboard pasteboardName=%s", m_name.utf8().data());
auto filePaths = platformStrategies()->pasteboardStrategy()->readFilePathsFromClipboard(m_name);
- for (const auto& filePath : filePaths)
+ for (const auto& filePath : filePaths) {
+ WTFLogAlways("xxoo Pasteboard::read readFilePathsFromClipboard reader.readFilename filePath=%s", filePath.utf8().data());
reader.readFilename(filePath);
+ }
+
+ if (filePaths.isEmpty()) {
+ WTFLogAlways("xxoo Pasteboard::read readFilePathsFromClipboard got no filePaths, try readBufferFromClipboard pasteboardName=%s", m_name.utf8().data());
+
+ auto types = platformStrategies()->pasteboardStrategy()->types(m_name);
+ static const ASCIILiteral imageTypes[] = { "image/png"_s, "image/jpeg"_s, "image/gif"_s, "image/bmp"_s, "image/vnd.microsoft.icon"_s, "image/x-icon"_s };
+ for (const auto& imageType : imageTypes) {
+ if (types.contains(imageType)) {
+ WTFLogAlways("xxoo Pasteboard::read readBufferFromClipboard types contains imageType");
+ auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, imageType);
+ // readBuffer(const String&, const String& type, Ref<SharedBuffer>&&)
+ // readImage(Ref<SharedBuffer>&&, const String&, PresentationSize = { })
+ if (!buffer->isEmpty()) {
+ reader.readBuffer(imageType, imageType, buffer.releaseNonNull());
+ WTFLogAlways("xxoo Pasteboard::read reader.readBuffer success");
+ return;
+ }
+ }
+ }
+ }
}
bool Pasteboard::hasData()