Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: da8844b2ef52ac3e78029b400f8305dbcf1f39b5
      
https://github.com/WebKit/WebKit/commit/da8844b2ef52ac3e78029b400f8305dbcf1f39b5
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2026-09-28 (Mon, 28 Sep 2026)

  Changed paths:
    M Source/WebCore/platform/LocalizedStrings.h
    M Source/WebKit/UIProcess/mac/WebPageProxyMac.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Tools/Scripts/webkitpy/api_tests/allowlist.txt
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEditActions.mm

  Log Message:
  -----------
  [macOS] PDF context menu does not present "Translate ..." option
https://bugs.webkit.org/show_bug.cgi?id=325440
rdar://186553741

Reviewed by Wenson Hsieh.

The context menu presented over PDF content differs from that presented
over regular web content because they are created in different places.
We ought to bring more parity between the two -- one notable case is the
"Translate" option, which is only missing over PDF content on macOS.

In this patch, we introduce the plumbing required to present said option
in the PDF context menu.

Test: Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEditActions.mm

* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebKit/UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::showPDFContextMenu):

  Filter out the Translate menu item if the runtime configuration cannot
  handle this context menu translation flow.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::contextMenuActionFromTag const):
(WebKit::UnifiedPDFPlugin::toContextMenuItemTag):
(WebKit::UnifiedPDFPlugin::titleForContextMenuItemTag const):
(WebKit::UnifiedPDFPlugin::selectionContextMenuItems const):

  Remove the separator between Look Up and Search since the regular
  context menu does not have a separator there.

(WebKit::UnifiedPDFPlugin::performContextMenuAction):
(WebKit::UnifiedPDFPlugin::selectionString const):
(WebKit::UnifiedPDFPlugin::showTranslationUIForSelection):
* Tools/Scripts/webkitpy/api_tests/allowlist.txt:
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/WKWebViewEditActions.mm:
(TestWebKitAPI::makeTranslationAvailabilityScope):
(TestWebKitAPI::runCanInvokeTranslateWithTextSelectionTest):
(TestWebKitAPI::TEST(WebKit, CanInvokeTranslateWithTextSelection)):
(TestWebKitAPI::TEST(WebKit, CanInvokeTranslateWithTextSelectionInPDF)):
(TestWebKitAPI::menuItemWithIdentifier):
(TestWebKitAPI::menuItemWithTitlePrefix):
(TestWebKitAPI::proposedContextMenuAfterRightClick):
(TestWebKitAPI::pdfContextMenuAfterRightClick):
(TestWebKitAPI::TEST(WKWebViewEditActions, 
CanInvokeTranslateContextMenuItemWithSelection)):
(TestWebKitAPI::TEST(WKWebViewEditActions, 
CanInvokeTranslateContextMenuItemWithSelectionInPDF)):

  Drive-by: Add iOS test coverage in CanInvokeTranslateWithTextSelectionInPDF

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



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

Reply via email to