Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0b85f13185f5720036900ad6ae7ffe726c47a98c
      
https://github.com/WebKit/WebKit/commit/0b85f13185f5720036900ad6ae7ffe726c47a98c
  Author: Tim Nguyen <[email protected]>
  Date:   2026-07-06 (Mon, 06 Jul 2026)

  Changed paths:
    M LayoutTests/editing/execCommand/enabling-and-selection-2-expected.txt
    M LayoutTests/editing/execCommand/enabling-and-selection-2.html
    M LayoutTests/editing/execCommand/enabling-and-selection-expected.txt
    M LayoutTests/editing/execCommand/enabling-and-selection.html
    M 
LayoutTests/imported/w3c/web-platform-tests/editing/other/exec-command-without-editable-element.tentative-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/paste-clipboard-change.tentative_id=contenteditable-expected.txt
    M 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/paste-clipboard-change.tentative_id=text-expected.txt
    M 
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/editing/other/exec-command-without-editable-element.tentative-expected.txt
    M 
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/editing/other/paste-in-list-with-inline-style.tentative-expected.txt
    M 
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/editing/other/paste-text-after-collapsible-white-space-whose-container-remove-non-first-children-expected.txt
    M Source/WTF/wtf/MainThread.h
    M Source/WTF/wtf/ThreadAssertions.h
    M Source/WTF/wtf/cocoa/MainThreadCocoa.mm
    M Source/WebCore/dom/UserGestureIndicator.h
    M Source/WebCore/editing/Editor.cpp
    M Source/WebCore/editing/EditorCommand.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEditActions.mm

  Log Message:
  -----------
  REGRESSION (Safari 18.x): Copy main menu item is enabled with no selection in 
the web page
https://bugs.webkit.org/show_bug.cgi?id=313835
rdar://176061974

Reviewed by Megan Gardner and Wenson Hsieh.

288559@main changed Editor::canCopy to return true for carets in non-editable
positions so that document.execCommand("copy") would fire copy events even
without a range selection. This regressed the Copy menu item, which is now
enabled whenever the caret was anywhere on a non-editable page.

Fix by reverting canCopy to require a range selection (restoring the correct
menu item state), and instead preserving 288559@main's execCommand behavior
via allowExecutionWhenDisabledCopyCut: when the copy/cut command is disabled
from a DOM source, allow execution anyway if clipboard access is currently
permitted (i.e. there is a user gesture or JavaScriptCanAccessClipboard is
true). This lets oncopy handlers fire from user-gesture-driven execCommand
calls on pages without a selection, while keeping programmatic calls without
a user gesture fully blocked (including suppressing the copy event).

Also, return the actual copy/cut success from executeCopy/executeCut instead
of always returning true, and only beep on failed copy/cut when the call
originates from the menu or a key binding.

* LayoutTests/editing/execCommand/enabling-and-selection-2-expected.txt:
* LayoutTests/editing/execCommand/enabling-and-selection-2.html:
* LayoutTests/editing/execCommand/enabling-and-selection-expected.txt:
* LayoutTests/editing/execCommand/enabling-and-selection.html:
* 
LayoutTests/imported/w3c/web-platform-tests/editing/other/exec-command-without-editable-element.tentative-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/paste-clipboard-change.tentative_id=contenteditable-expected.txt:
* 
LayoutTests/platform/glib/imported/w3c/web-platform-tests/editing/other/paste-clipboard-change.tentative_id=text-expected.txt:
* 
LayoutTests/platform/gtk/imported/w3c/web-platform-tests/editing/other/exec-command-without-editable-element.tentative-expected.txt:
* 
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/editing/other/paste-in-list-with-inline-style.tentative-expected.txt:
* 
LayoutTests/platform/wpe/imported/w3c/web-platform-tests/editing/other/paste-text-after-collapsible-white-space-whose-container-remove-non-first-children-expected.txt:
* Source/WTF/wtf/MainThread.h:
* Source/WTF/wtf/ThreadAssertions.h:
* Source/WTF/wtf/cocoa/MainThreadCocoa.mm:
(WTF::isMainThread):
* Source/WebCore/dom/UserGestureIndicator.h:
* Source/WebCore/editing/Editor.cpp:
(WebCore::Editor::canCopy const):
(WebCore::Editor::cut):
(WebCore::Editor::copy):
* Source/WebCore/editing/EditorCommand.cpp:
(WebCore::executeCopy):
(WebCore::executeCut):
(WebCore::allowCopyCutFromDOM):
(WebCore::allowExecutionWhenDisabledCopyCut):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEditActions.mm:
(TestWebKitAPI::TEST(WKWebViewEditActions, 
CopyMenuItemDisabledWithNoSelection)):

Canonical link: https://commits.webkit.org/316571@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to