Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 8f8836b26a36d8d6a0e2a508c3c2422437fb0ad1
https://github.com/WebKit/WebKit/commit/8f8836b26a36d8d6a0e2a508c3c2422437fb0ad1
Author: Devin Rousso <[email protected]>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
M LayoutTests/platform/win/TestExpectations
M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
M Source/WebCore/Modules/async-clipboard/Clipboard.cpp
M Source/WebCore/Modules/async-clipboard/ClipboardItem.cpp
M Source/WebCore/Modules/async-clipboard/ClipboardItem.h
M Source/WebCore/Modules/async-clipboard/ClipboardItem.idl
M Source/WebCore/PlatformWin.cmake
M Source/WebCore/platform/Pasteboard.cpp
M Source/WebCore/platform/Pasteboard.h
M Source/WebCore/platform/PasteboardStrategy.h
M Source/WebCore/platform/PlatformPasteboard.h
M Source/WebCore/platform/StaticPasteboard.h
M
Source/WebCore/platform/cocoa/PasteboardCocoa.mm
M Source/WebCore/platform/glib/PasteboardGLib.cpp
M Source/WebCore/platform/libwpe/PasteboardLibWPE.cpp
M Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
M Source/WebCore/platform/win/ClipboardUtilitiesWin.h
M Source/WebCore/platform/win/PasteboardWin.cpp
A Source/WebCore/platform/win/PlatformPasteboardWin.cpp
M Source/WebKit/PlatformWin.cmake
M Source/WebKit/UIProcess/WebPasteboardProxy.cpp
M Source/WebKit/UIProcess/WebPasteboardProxy.h
M Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
M Source/WebKit/UIProcess/win/PageClientImpl.cpp
A Source/WebKit/UIProcess/win/WebPasteboardProxyWin.cpp
M Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
M Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h
M Tools/TestWebKitAPI/Tests/WebCore/TestPlatformStrategies.cpp
Log Message:
-----------
[Win]
`navigator.clipboard.readText()` always rejects
https://bugs.webkit.org/show_bug.cgi?id=320659
Reviewed by Ian Grunert.
Give Windows a `PlatformPasteboard` and a `WebPasteboardProxy` so that plain
text reaches the clipboard the same way it does on the ports that already
support the async clipboard API.
`Clipboard::readText()` rejects as soon as
`Pasteboard::allPasteboardItemInfo()` returns `std::nullopt`, and that is all
it can ever return on Windows because the function is only implemented for
`PLATFORM(COCOA)`, `PLATFORM(GTK)`, and `PLATFORM(WPE)`.
It cannot be implemented for Windows while the clipboard is reached straight
from `Win32` in the WebProcess rather than through a pasteboard strategy.
* Source/WebCore/Modules/async-clipboard/Clipboard.cpp:
(WebCore::Clipboard::writeText):
(WebCore::Clipboard::ItemWriter::didSetAllData):
* Source/WebCore/Modules/async-clipboard/ClipboardItem.cpp:
(WebCore::ClipboardItem::supports):
*
Source/WebCore/Modules/async-clipboard/ClipboardItem.h:
* Source/WebCore/Modules/async-clipboard/ClipboardItem.idl:
Pass the current `ScriptExecutionContext` to `ClipboardItem.supports()` and
consult `AsyncClipboardRichContentEnabled` instead of branching on the platform
in async clipboard code.
Use the same runtime capability to reject multiple items, non-plain types, and
buffer-backed data before the clipboard is touched.
Mark async writes explicitly with `PasteboardWriteType::AsyncClipboard`.
* Source/WebCore/platform/win/PasteboardWin.cpp:
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::changeCount const): Added.
(WebCore::Pasteboard::read):
(WebCore::Pasteboard::writeCustomData):
* Source/WebCore/platform/Pasteboard.cpp:
(WebCore::Pasteboard::allPasteboardItemInfo const):
(WebCore::Pasteboard::pasteboardItemInfo const):
* Source/WebCore/platform/Pasteboard.h:
Ask the strategy for the item info, change count, types, and text of the copy
and paste
clipboard, so that a single place owns it.
Route only writes marked `PasteboardWriteType::AsyncClipboard` through the
strategy.
Leave drag, `DataTransfer`, and legacy copy and paste behavior unchanged.
* Source/WebCore/platform/win/PlatformPasteboardWin.cpp: Added.
(WebCore::clipboardOwner): Added.
(WebCore::readClipboardString): Added.
(WebCore::setClipboardData): Added.
(WebCore::PlatformPasteboard::PlatformPasteboard): Added.
(WebCore::PlatformPasteboard::performAsDataOwner): Added.
(WebCore::PlatformPasteboard::changeCount const): Added.
(WebCore::PlatformPasteboard::getTypes const): Added.
(WebCore::PlatformPasteboard::readCustomData const): Added.
(WebCore::PlatformPasteboard::readString const): Added.
(WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const): Added.
(WebCore::PlatformPasteboard::informationForItemAtIndex): Added.
(WebCore::PlatformPasteboard::allPasteboardItemInfo): Added.
(WebCore::PlatformPasteboard::count const):
Added.
(WebCore::PlatformPasteboard::write): Added.
* Source/WebCore/platform/PlatformPasteboard.h:
* Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::customDataClipboardFormat): Added.
* Source/WebCore/platform/win/ClipboardUtilitiesWin.h:
Implement the plain text and same-origin metadata operations that the async
clipboard API needs on top of the `Win32` clipboard.
Reads and writes go through a message only owner window, because
`EmptyClipboard()` makes the owner of an unowned clipboard null and
`SetClipboardData()` then fails.
Read serialized custom data by length rather than as a null terminated string.
Ignore unsupported data without changing the clipboard.
* Source/WebKit/UIProcess/win/WebPasteboardProxyWin.cpp: Added.
(WebKit::WebPasteboardProxy::getPasteboardChangeCount): Added.
(WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite): Added.
(WebKit::WebPasteboardProxy::writeCustomData):
Added.
(WebKit::WebPasteboardProxy::allPasteboardItemInfo): Added.
(WebKit::WebPasteboardProxy::informationForItemAtIndex): Added.
(WebKit::WebPasteboardProxy::getPasteboardItemsCount): Added.
(WebKit::WebPasteboardProxy::readStringFromPasteboard): Added.
(WebKit::WebPasteboardProxy::readURLFromPasteboard): Added.
(WebKit::WebPasteboardProxy::readBufferFromPasteboard): Added.
* Source/WebKit/UIProcess/WebPasteboardProxy.cpp:
Answer the pasteboard messages for Windows in the UIProcess.
* Source/WebKit/UIProcess/win/PageClientImpl.cpp:
(WebKit::PageClientImpl::requestDOMPasteAccess):
Grant paste access when the origin asking for it is the one that wrote the
clipboard, matching WPE.
* Source/WebCore/platform/cocoa/PasteboardCocoa.mm:
(WebCore::Pasteboard::writeCustomData):
* Source/WebCore/platform/glib/PasteboardGLib.cpp:
(WebCore::Pasteboard::writeCustomData):
* Source/WebCore/platform/libwpe/PasteboardLibWPE.cpp:
(WebCore::Pasteboard::writeCustomData):
*
Source/WebCore/platform/StaticPasteboard.h:
(WebCore::StaticPasteboard::writeCustomData):
Accept `PasteboardWriteType` without changing the existing behavior on other
platforms.
* Source/WebCore/platform/PasteboardStrategy.h:
* Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::changeCount):
* Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* Source/WebKit/UIProcess/WebPasteboardProxy.h:
* Source/WebKit/UIProcess/WebPasteboardProxy.messages.in:
* Tools/TestWebKitAPI/Tests/WebCore/TestPlatformStrategies.cpp:
(TestWebKitAPI::TestPasteboardStrategy::changeCount): Added.
Make `GetPasteboardChangeCount` available to Windows alongside GTK and WPE.
Keep the test pasteboard strategy concrete on Windows.
* LayoutTests/platform/win/TestExpectations:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/PlatformWin.cmake:
* Source/WebKit/PlatformWin.cmake:
Canonical link:
https://flagged.apple.com:443/proxy?t2=Dk2s3f7uW1&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE4NTg3QG1haW4=&emid=05e41208-cee6-4c93-a832-00b13aedcc98&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications