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

  Changed paths:
    A 
LayoutTests/pdf/mac/selection-context-menu-items-with-copying-disabled-expected.txt
    A 
LayoutTests/pdf/mac/selection-context-menu-items-with-copying-disabled.html
    A LayoutTests/pdf/resources/copying-disabled.pdf
    M LayoutTests/platform/ios/TestExpectations
    M LayoutTests/platform/visionos/TestExpectations
    M Source/WebCore/plugins/PluginViewBase.h
    M Source/WebCore/testing/Internals.cpp
    M Source/WebCore/testing/Internals.h
    M Source/WebCore/testing/Internals.idl
    M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Source/WebKit/WebProcess/Plugins/PluginView.cpp
    M Source/WebKit/WebProcess/Plugins/PluginView.h

  Log Message:
  -----------
  [macOS] Text selection options missing from context menu in PDFs with copying 
disabled
https://bugs.webkit.org/show_bug.cgi?id=323297
rdar://186527750

Reviewed by Wenson Hsieh.

When we build up the context menu items in UnifiedPDFPlugin, we too
eagerly skipped the text selection items if a document did not allow
copying. However, the copying permission really only affected the "Copy"
and "Copy Link" items, and not the other menu items such as "Look Up ..."
and "Search with ...".

As such, this patch relaxes that restriction and only consults
-[PDFDocument allowsCopying] before producing the context menu items
which involve copying.

To facilitate testing, we refactor UnifiedPDFPlugin::createContextMenu()
to accept a root view point and an input source, rather than a full
fledged context menu event. This allows both the event handling path and
the test hook to obtain a context menu, using which the latter generates
a set of titles observed in the PDF's context menu.

Test: pdf/mac/selection-context-menu-items-with-copying-disabled.html

* 
LayoutTests/pdf/mac/selection-context-menu-items-with-copying-disabled-expected.txt:
 Added.
* LayoutTests/pdf/mac/selection-context-menu-items-with-copying-disabled.html: 
Added.
* LayoutTests/pdf/resources/copying-disabled.pdf: Added.
* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/visionos/TestExpectations:
* Source/WebCore/plugins/PluginViewBase.h:
(WebCore::PluginViewBase::pdfContextMenuItemTitlesForTesting const):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::pdfContextMenuItemTitlesForTesting const):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::PDFPluginBase::contextMenuItemTitlesForTesting const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::handleContextMenuEvent):
(WebKit::UnifiedPDFPlugin::createContextMenu const):
(WebKit::UnifiedPDFPlugin::contextMenuItemTitlesForTesting const):
(WebKit::UnifiedPDFPlugin::selectionContextMenuItems const):
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::pdfContextMenuItemTitlesForTesting const):
* Source/WebKit/WebProcess/Plugins/PluginView.h:

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



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

Reply via email to