Title: [286870] trunk/Source
Revision
286870
Author
drou...@apple.com
Date
2021-12-10 13:15:46 -0800 (Fri, 10 Dec 2021)

Log Message

Allow `Pasteboard::readBuffer` to read from the pasteboard as a whole instead of a specific item
https://bugs.webkit.org/show_bug.cgi?id=233940

Reviewed by Wenson Hsieh.

In order to match the WK1 implementation of `-pasteFont:` <https://webkit.org/b/191379>, we
need to read from the font pasteboard as a whole, not a specific item. Make the `index` into
an `std::optional` so that we can have this behavior without needing to have a new method.

No change in behavior.

Source/WebCore:

* platform/Pasteboard.h:
* platform/Pasteboard.cpp:
(WebCore::Pasteboard::readBuffer):
* platform/PasteboardStrategy.h:
* platform/PlatformPasteboard.h:
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::PlatformPasteboard::getTypes const):
(WebCore::PlatformPasteboard::bufferForType const):
(WebCore::PlatformPasteboard::readBuffer const):
(WebCore::PlatformPasteboard::getTypes): Deleted.
(WebCore::PlatformPasteboard::bufferForType): Deleted.
* platform/libwpe/PlatformPasteboardLibWPE.cpp:
(WebCore::PlatformPasteboard::getTypes const):
(WebCore::PlatformPasteboard::getTypes): Deleted.
* platform/mac/PlatformPasteboardMac.mm:
(WebCore::PlatformPasteboard::getTypes const):
(WebCore::PlatformPasteboard::bufferForType const):
(WebCore::PlatformPasteboard::readBuffer const):
(WebCore::PlatformPasteboard::getTypes): Deleted.
(WebCore::PlatformPasteboard::bufferForType): Deleted.

Source/WebKit:

* UIProcess/WebPasteboardProxy.messages.in:
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.cpp:
(WebKit::WebPasteboardProxy::readBufferFromPasteboard):
* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::readBufferFromPasteboard):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::readBufferFromPasteboard):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebPlatformStrategies.h:
* WebCoreSupport/WebPlatformStrategies.mm:
(WebPlatformStrategies::readBufferFromPasteboard):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286869 => 286870)


--- trunk/Source/WebCore/ChangeLog	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/ChangeLog	2021-12-10 21:15:46 UTC (rev 286870)
@@ -1,3 +1,37 @@
+2021-12-10  Devin Rousso  <drou...@apple.com>
+
+        Allow `Pasteboard::readBuffer` to read from the pasteboard as a whole instead of a specific item
+        https://bugs.webkit.org/show_bug.cgi?id=233940
+
+        Reviewed by Wenson Hsieh.
+
+        In order to match the WK1 implementation of `-pasteFont:` <https://webkit.org/b/191379>, we
+        need to read from the font pasteboard as a whole, not a specific item. Make the `index` into
+        an `std::optional` so that we can have this behavior without needing to have a new method.
+
+        No change in behavior.
+
+        * platform/Pasteboard.h:
+        * platform/Pasteboard.cpp:
+        (WebCore::Pasteboard::readBuffer):
+        * platform/PasteboardStrategy.h:
+        * platform/PlatformPasteboard.h:
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::PlatformPasteboard::getTypes const):
+        (WebCore::PlatformPasteboard::bufferForType const):
+        (WebCore::PlatformPasteboard::readBuffer const):
+        (WebCore::PlatformPasteboard::getTypes): Deleted.
+        (WebCore::PlatformPasteboard::bufferForType): Deleted.
+        * platform/libwpe/PlatformPasteboardLibWPE.cpp:
+        (WebCore::PlatformPasteboard::getTypes const):
+        (WebCore::PlatformPasteboard::getTypes): Deleted.
+        * platform/mac/PlatformPasteboardMac.mm:
+        (WebCore::PlatformPasteboard::getTypes const):
+        (WebCore::PlatformPasteboard::bufferForType const):
+        (WebCore::PlatformPasteboard::readBuffer const):
+        (WebCore::PlatformPasteboard::getTypes): Deleted.
+        (WebCore::PlatformPasteboard::bufferForType): Deleted.
+
 2021-12-10  Chris Dumez  <cdu...@apple.com>
 
         Improve <type="datetime-local"> value parsing and sanitization

Modified: trunk/Source/WebCore/platform/Pasteboard.cpp (286869 => 286870)


--- trunk/Source/WebCore/platform/Pasteboard.cpp	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/Pasteboard.cpp	2021-12-10 21:15:46 UTC (rev 286870)
@@ -93,7 +93,7 @@
     return { };
 }
 
-RefPtr<WebCore::SharedBuffer> Pasteboard::readBuffer(size_t index, const String& type)
+RefPtr<WebCore::SharedBuffer> Pasteboard::readBuffer(std::optional<size_t> index, const String& type)
 {
     if (auto* strategy = platformStrategies()->pasteboardStrategy())
         return strategy->readBufferFromPasteboard(index, type, name(), context());

Modified: trunk/Source/WebCore/platform/Pasteboard.h (286869 => 286870)


--- trunk/Source/WebCore/platform/Pasteboard.h	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/Pasteboard.h	2021-12-10 21:15:46 UTC (rev 286870)
@@ -308,7 +308,7 @@
     std::optional<PasteboardItemInfo> pasteboardItemInfo(size_t index) const;
 
     String readString(size_t index, const String& type);
-    RefPtr<WebCore::SharedBuffer> readBuffer(size_t index, const String& type);
+    RefPtr<WebCore::SharedBuffer> readBuffer(std::optional<size_t> index, const String& type);
     URL readURL(size_t index, String& title);
 
     const PasteboardContext* context() const { return m_context.get(); }

Modified: trunk/Source/WebCore/platform/PasteboardStrategy.h (286869 => 286870)


--- trunk/Source/WebCore/platform/PasteboardStrategy.h	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/PasteboardStrategy.h	2021-12-10 21:15:46 UTC (rev 286870)
@@ -71,7 +71,7 @@
     virtual String urlStringSuitableForLoading(const String& pasteboardName, String& title, const PasteboardContext*) = 0;
 #endif
     virtual String readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext*) = 0;
-    virtual RefPtr<SharedBuffer> readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext*) = 0;
+    virtual RefPtr<SharedBuffer> readBufferFromPasteboard(std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext*) = 0;
     virtual URL readURLFromPasteboard(size_t index, const String& pasteboardName, String& title, const PasteboardContext*) = 0;
     virtual std::optional<PasteboardItemInfo> informationForItemAtIndex(size_t index, const String& pasteboardName, int64_t changeCount, const PasteboardContext*) = 0;
     virtual std::optional<Vector<PasteboardItemInfo>> allPasteboardItemInfo(const String& pasteboardName, int64_t changeCount, const PasteboardContext*) = 0;

Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (286869 => 286870)


--- trunk/Source/WebCore/platform/PlatformPasteboard.h	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h	2021-12-10 21:15:46 UTC (rev 286870)
@@ -70,8 +70,8 @@
     enum class IncludeImageTypes : bool { No, Yes };
     static String platformPasteboardTypeForSafeTypeForDOMToReadAndWrite(const String& domType, IncludeImageTypes = IncludeImageTypes::No);
 
-    WEBCORE_EXPORT void getTypes(Vector<String>& types);
-    WEBCORE_EXPORT RefPtr<SharedBuffer> bufferForType(const String& pasteboardType);
+    WEBCORE_EXPORT void getTypes(Vector<String>& types) const;
+    WEBCORE_EXPORT RefPtr<SharedBuffer> bufferForType(const String& pasteboardType) const;
     WEBCORE_EXPORT void getPathnamesForType(Vector<String>& pathnames, const String& pasteboardType) const;
     WEBCORE_EXPORT String stringForType(const String& pasteboardType) const;
     WEBCORE_EXPORT Vector<String> allStringsForType(const String& pasteboardType) const;
@@ -93,7 +93,7 @@
     WEBCORE_EXPORT void write(const PasteboardImage&);
     WEBCORE_EXPORT void write(const String& pasteboardType, const String&);
     WEBCORE_EXPORT void write(const PasteboardURL&);
-    WEBCORE_EXPORT RefPtr<SharedBuffer> readBuffer(size_t index, const String& pasteboardType) const;
+    WEBCORE_EXPORT RefPtr<SharedBuffer> readBuffer(std::optional<size_t> index, const String& pasteboardType) const;
     WEBCORE_EXPORT String readString(size_t index, const String& pasteboardType) const;
     WEBCORE_EXPORT URL readURL(size_t index, String& title) const;
     WEBCORE_EXPORT int count() const;

Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (286869 => 286870)


--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm	2021-12-10 21:15:46 UTC (rev 286870)
@@ -74,12 +74,12 @@
 }
 #endif
 
-void PlatformPasteboard::getTypes(Vector<String>& types)
+void PlatformPasteboard::getTypes(Vector<String>& types) const
 {
     types = makeVector<String>([m_pasteboard pasteboardTypes]);
 }
 
-RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& type)
+RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& type) const
 {
     if (NSData *data = "" dataForPasteboardType:type])
         return SharedBuffer::create(data);
@@ -746,12 +746,16 @@
     return strings;
 }
 
-RefPtr<SharedBuffer> PlatformPasteboard::readBuffer(size_t index, const String& type) const
+RefPtr<SharedBuffer> PlatformPasteboard::readBuffer(std::optional<size_t> index, const String& type) const
 {
-    if ((NSInteger)index < 0 || (NSInteger)index >= [m_pasteboard numberOfItems])
+    if (!index)
+        return bufferForType(type);
+
+    NSInteger integerIndex = *index;
+    if (integerIndex < 0 || integerIndex >= [m_pasteboard numberOfItems])
         return nullptr;
 
-    NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:index];
+    NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:integerIndex];
 
     RetainPtr<NSArray> pasteboardItem = [m_pasteboard dataForPasteboardType:type inItemSet:indexSet];
 

Modified: trunk/Source/WebCore/platform/libwpe/PlatformPasteboardLibWPE.cpp (286869 => 286870)


--- trunk/Source/WebCore/platform/libwpe/PlatformPasteboardLibWPE.cpp	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/libwpe/PlatformPasteboardLibWPE.cpp	2021-12-10 21:15:46 UTC (rev 286870)
@@ -52,7 +52,7 @@
     actions();
 }
 
-void PlatformPasteboard::getTypes(Vector<String>& types)
+void PlatformPasteboard::getTypes(Vector<String>& types) const
 {
     struct wpe_pasteboard_string_vector pasteboardTypes = { nullptr, 0 };
     wpe_pasteboard_get_types(m_pasteboard, &pasteboardTypes);

Modified: trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm (286869 => 286870)


--- trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebCore/platform/mac/PlatformPasteboardMac.mm	2021-12-10 21:15:46 UTC (rev 286870)
@@ -63,12 +63,12 @@
     ASSERT(pasteboardName);
 }
 
-void PlatformPasteboard::getTypes(Vector<String>& types)
+void PlatformPasteboard::getTypes(Vector<String>& types) const
 {
     types = makeVector<String>([m_pasteboard types]);
 }
 
-RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardType)
+RefPtr<SharedBuffer> PlatformPasteboard::bufferForType(const String& pasteboardType) const
 {
     NSData *data = "" dataForType:pasteboardType];
     if (!data)
@@ -446,9 +446,12 @@
     return { };
 }
 
-RefPtr<SharedBuffer> PlatformPasteboard::readBuffer(size_t index, const String& type) const
+RefPtr<SharedBuffer> PlatformPasteboard::readBuffer(std::optional<size_t> index, const String& type) const
 {
-    NSPasteboardItem *item = itemAtIndex(index);
+    if (!index)
+        return bufferForType(type);
+
+    NSPasteboardItem *item = itemAtIndex(*index);
     if (!item)
         return { };
 

Modified: trunk/Source/WebKit/ChangeLog (286869 => 286870)


--- trunk/Source/WebKit/ChangeLog	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/ChangeLog	2021-12-10 21:15:46 UTC (rev 286870)
@@ -1,3 +1,26 @@
+2021-12-10  Devin Rousso  <drou...@apple.com>
+
+        Allow `Pasteboard::readBuffer` to read from the pasteboard as a whole instead of a specific item
+        https://bugs.webkit.org/show_bug.cgi?id=233940
+
+        Reviewed by Wenson Hsieh.
+
+        In order to match the WK1 implementation of `-pasteFont:` <https://webkit.org/b/191379>, we
+        need to read from the font pasteboard as a whole, not a specific item. Make the `index` into
+        an `std::optional` so that we can have this behavior without needing to have a new method.
+
+        No change in behavior.
+
+        * UIProcess/WebPasteboardProxy.messages.in:
+        * UIProcess/WebPasteboardProxy.h:
+        * UIProcess/WebPasteboardProxy.cpp:
+        (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+        * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+        (WebKit::WebPlatformStrategies::readBufferFromPasteboard):
+
 2021-12-10  Alex Christensen  <achristen...@webkit.org>
 
         Move if-domain and unless-domain conversion to WKContentRuleList parsing

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (286869 => 286870)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2021-12-10 21:15:46 UTC (rev 286870)
@@ -538,7 +538,7 @@
     });
 }
 
-void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
+void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, std::optional<PageIdentifier> pageID, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
 {
     MESSAGE_CHECK_COMPLETION(!pasteboardType.isEmpty(), completionHandler({ }));
 

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp (286869 => 286870)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp	2021-12-10 21:15:46 UTC (rev 286870)
@@ -111,7 +111,7 @@
     completionHandler({ }, { });
 }
 
-void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, size_t, const String&, const String&, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
+void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection&, std::optional<size_t>, const String&, const String&, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(SharedMemory::IPCHandle&&)>&& completionHandler)
 {
     completionHandler({ });
 }

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h (286869 => 286870)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h	2021-12-10 21:15:46 UTC (rev 286870)
@@ -109,7 +109,7 @@
 
     void readStringFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(String&&)>&&);
     void readURLFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardName, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(String&& url, String&& title)>&&);
-    void readBufferFromPasteboard(IPC::Connection&, size_t index, const String& pasteboardType, const String& pasteboardName, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(SharedMemory::IPCHandle&&)>&&);
+    void readBufferFromPasteboard(IPC::Connection&, std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(SharedMemory::IPCHandle&&)>&&);
     void getPasteboardItemsCount(IPC::Connection&, const String& pasteboardName, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(uint64_t)>&&);
     void informationForItemAtIndex(IPC::Connection&, size_t index, const String& pasteboardName, int64_t changeCount, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(std::optional<WebCore::PasteboardItemInfo>&&)>&&);
     void allPasteboardItemInfo(IPC::Connection&, const String& pasteboardName, int64_t changeCount, std::optional<WebCore::PageIdentifier>, CompletionHandler<void(std::optional<Vector<WebCore::PasteboardItemInfo>>&&)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in (286869 => 286870)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in	2021-12-10 21:15:46 UTC (rev 286870)
@@ -36,7 +36,7 @@
     GetPasteboardItemsCount(String pasteboardName, std::optional<WebCore::PageIdentifier> pageID) -> (uint64_t itemsCount) Synchronous WantsConnection
     ReadStringFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName, std::optional<WebCore::PageIdentifier> pageID) -> (String string) Synchronous WantsConnection
     ReadURLFromPasteboard(uint64_t index, String pasteboardName, std::optional<WebCore::PageIdentifier> pageID) -> (String url, String title) Synchronous WantsConnection
-    ReadBufferFromPasteboard(uint64_t index, String pasteboardType, String pasteboardName, std::optional<WebCore::PageIdentifier> pageID) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous WantsConnection
+    ReadBufferFromPasteboard(std::optional<uint64_t> index, String pasteboardType, String pasteboardName, std::optional<WebCore::PageIdentifier> pageID) -> (WebKit::SharedMemory::IPCHandle handle) Synchronous WantsConnection
     ContainsStringSafeForDOMToReadForType(String type, String pasteboardName, std::optional<WebCore::PageIdentifier> pageID) -> (bool result) Synchronous WantsConnection
 
 #if PLATFORM(COCOA)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (286869 => 286870)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp	2021-12-10 21:15:46 UTC (rev 286870)
@@ -406,7 +406,7 @@
     return info;
 }
 
-RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, const PasteboardContext* context)
 {
     SharedMemory::IPCHandle ipcHandle;
     WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadBufferFromPasteboard(index, pasteboardType, pasteboardName, pageIdentifier(context)), Messages::WebPasteboardProxy::ReadBufferFromPasteboard::Reply(ipcHandle), 0);

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h (286869 => 286870)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h	2021-12-10 21:15:46 UTC (rev 286870)
@@ -89,7 +89,7 @@
 #endif
 
     String readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const WebCore::PasteboardContext*) override;
-    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const WebCore::PasteboardContext*) override;
+    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, const WebCore::PasteboardContext*) override;
     URL readURLFromPasteboard(size_t index, const String& pasteboardName, String& title, const WebCore::PasteboardContext*) override;
     int getPasteboardItemsCount(const String& pasteboardName, const WebCore::PasteboardContext*) override;
     std::optional<WebCore::PasteboardItemInfo> informationForItemAtIndex(size_t index, const String& pasteboardName, int64_t changeCount, const WebCore::PasteboardContext*) override;

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (286869 => 286870)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-12-10 21:15:46 UTC (rev 286870)
@@ -1,3 +1,20 @@
+2021-12-10  Devin Rousso  <drou...@apple.com>
+
+        Allow `Pasteboard::readBuffer` to read from the pasteboard as a whole instead of a specific item
+        https://bugs.webkit.org/show_bug.cgi?id=233940
+
+        Reviewed by Wenson Hsieh.
+
+        In order to match the WK1 implementation of `-pasteFont:` <https://webkit.org/b/191379>, we
+        need to read from the font pasteboard as a whole, not a specific item. Make the `index` into
+        an `std::optional` so that we can have this behavior without needing to have a new method.
+
+        No change in behavior.
+
+        * WebCoreSupport/WebPlatformStrategies.h:
+        * WebCoreSupport/WebPlatformStrategies.mm:
+        (WebPlatformStrategies::readBufferFromPasteboard):
+
 2021-12-09  Devin Rousso  <drou...@apple.com>
 
         Add a `DOMPasteAccessCategory` to control which pasteboard the WebProcess is granted access to when pasting

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h (286869 => 286870)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.h	2021-12-10 21:15:46 UTC (rev 286870)
@@ -55,7 +55,7 @@
     void updateSupportedTypeIdentifiers(const Vector<String>& identifiers, const String& pasteboardName, const WebCore::PasteboardContext*) override;
 #endif
     String readStringFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const WebCore::PasteboardContext*) override;
-    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(size_t index, const String& pasteboardType, const String& pasteboardName, const WebCore::PasteboardContext*) override;
+    RefPtr<WebCore::SharedBuffer> readBufferFromPasteboard(std::optional<size_t> index, const String& pasteboardType, const String& pasteboardName, const WebCore::PasteboardContext*) override;
     URL readURLFromPasteboard(size_t index, const String& pasteboardName, String& title, const WebCore::PasteboardContext*) override;
     int getPasteboardItemsCount(const String& pasteboardName, const WebCore::PasteboardContext*) override;
     std::optional<WebCore::PasteboardItemInfo> informationForItemAtIndex(size_t index, const String& pasteboardName, int64_t changeCount, const WebCore::PasteboardContext*) override;

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm (286869 => 286870)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2021-12-10 20:37:40 UTC (rev 286869)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebPlatformStrategies.mm	2021-12-10 21:15:46 UTC (rev 286870)
@@ -209,7 +209,7 @@
     return PlatformPasteboard(pasteboardName).count();
 }
 
-RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(size_t index, const String& type, const String& pasteboardName, const PasteboardContext*)
+RefPtr<WebCore::SharedBuffer> WebPlatformStrategies::readBufferFromPasteboard(std::optional<size_t> index, const String& type, const String& pasteboardName, const PasteboardContext*)
 {
     return PlatformPasteboard(pasteboardName).readBuffer(index, type);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to