Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: f778680e9ba45d5bbcd17b16dd4e32886370e73e https://github.com/WebKit/WebKit/commit/f778680e9ba45d5bbcd17b16dd4e32886370e73e Author: Wenson Hsieh <wenson_hs...@apple.com> Date: 2024-12-23 (Mon, 23 Dec 2024)
Changed paths: M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h M Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm 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 M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm M Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm M Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm M Tools/TestWebKitAPI/cocoa/TestWKWebView.h M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm Log Message: ----------- "Look Up" and "Search Web" should appear in the edit menu for selected text https://bugs.webkit.org/show_bug.cgi?id=285086 rdar://141917634 Reviewed by Abrar Rahman Protyasha. Add support for a few more text services: "Look Up" and "Search Web", through the edit menu for selected text in PDFs when Unified PDF is enabled. See below for more details. * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h: (WebKit::PDFPluginBase::stringsBeforeAndAfterSelection const): * Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm: (WebKit::PDFPluginBase::documentEditingContext const): * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h: * Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm: (WebKit::UnifiedPDFPlugin::stringsBeforeAndAfterSelection const): Add a new helper method to surface text (i.e. a given number of characters) around the current selection, as a `std::pair` representing text before and after (respectively). (WebKit::UnifiedPDFPlugin::documentEditingContext const): Add a helper method to return a document editing context for the given request. This only surfaces selected text at the moment, but can be fleshed out in the future if needed. * Source/WebKit/WebProcess/Plugins/PluginView.cpp: (WebKit::PluginView::stringsBeforeAndAfterSelection const): (WebKit::PluginView::documentEditingContext const): * Source/WebKit/WebProcess/Plugins/PluginView.h: * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::getSelectionContext): Implement this for the unified PDF plugin in terms of the new `stringsBeforeAndAfterSelection` helper method. Look Up uses this to obtain text context around the selection string. (WebKit::WebPage::requestDocumentEditingContext): Add very basic support for document editing contexts in PDFs — DataDetectorsUI uses a Reveal item derived from the document editing context to determine whether or not they should populate the edit menu with "Look Up" and "Search Web". We currently return an empty document editing context, which causes this to fail. * Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm: (-[TestWKWebView synchronouslyRequestDocumentContext:]): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm: (TestWebKitAPI::UNIFIED_PDF_TEST): Add a new API test to exercise this change by simulating the "Look Up" action from API. * Tools/TestWebKitAPI/cocoa/TestWKWebView.h: * Tools/TestWebKitAPI/cocoa/TestWKWebView.mm: (-[WKWebView synchronouslyRequestDocumentContext:]): Move this testing helper out of the test file and into `TestWKWebView`, for use in Unified PDF tests as well. Canonical link: https://commits.webkit.org/288247@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes