summarylogtreecommitdiffstats
path: root/PasteBoardGLib.patch
blob: fc31e02f8a24f3e029d532cdd68ec14a86970476 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff -Naur webkitgtk-2.50.0/Source/WebCore/platform/glib/PasteboardGLib.cpp webkitgtk-2.50.0-patched/Source/WebCore/platform/glib/PasteboardGLib.cpp
--- webkitgtk-2.50.0/Source/WebCore/platform/glib/PasteboardGLib.cpp	2025-08-08 17:17:55.336475000 +0800
+++ webkitgtk-2.50.0-patched/Source/WebCore/platform/glib/PasteboardGLib.cpp	2025-09-23 01:43:19.241817869 +0800
@@ -336,6 +336,25 @@
         auto filePaths = platformStrategies()->pasteboardStrategy()->readFilePathsFromClipboard(m_name);
         for (const auto& filePath : filePaths)
             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 };
+            static const ASCIILiteral imageNames[] = { "image.png"_s, "image.jpeg"_s, "image.gif"_s, "image.bmp"_s, "image.ico"_s, "image.ico"_s };
+            for (int i = 0;i < 6;i++) {
+                if (types.contains(imageTypes[i])) {
+                    // WTFLogAlways("xxoo Pasteboard::read readBufferFromClipboard types contains imageType");
+                    auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, imageTypes[i]);
+                    // readBuffer(const String&, const String& type, Ref<SharedBuffer>&&)
+                    // readImage(Ref<SharedBuffer>&&, const String&, PresentationSize = { }) 
+                    if (!buffer->isEmpty()) {
+                        reader.readBuffer(imageNames[i], imageTypes[i], buffer.releaseNonNull());
+                        // WTFLogAlways("xxoo Pasteboard::read reader.readBuffer success");
+                        return;
+                    }
+                }
+            }
+        }
         return;
     }