[webkit-changes] [WebKit/WebKit] 6390ac: [iOS] [Unified PDF] Make it possible to select wor...
Wenson Hsieh
noreply at github.com
Wed Dec 11 21:36:12 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 6390ac13796720a15123cbb56cbe0971d9843e27
https://github.com/WebKit/WebKit/commit/6390ac13796720a15123cbb56cbe0971d9843e27
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-12-11 (Wed, 11 Dec 2024)
Changed paths:
M Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h
M Source/WebKit/Shared/EditorState.cpp
M Source/WebKit/Shared/EditorState.h
M Source/WebKit/Shared/EditorState.serialization.in
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
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/WebPage.cpp
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
[iOS] [Unified PDF] Make it possible to select words by long pressing
https://bugs.webkit.org/show_bug.cgi?id=284477
Reviewed by Abrar Rahman Protyasha.
Work towards support for UIKit-based text interaction in PDFs when Unified PDF is enabled. This
patch only introduces the minimal support needed to allow long presses to select a single word in
a PDF document. See below for more details.
* Source/WebKit/Platform/spi/Cocoa/PDFKitSPI.h:
Remove some staging declarations that are no longer necessary, now that these enums are public API.
* Source/WebKit/Shared/EditorState.cpp:
(WebKit::operator<<):
* Source/WebKit/Shared/EditorState.h:
Move `isInPlugin` behind `PLATFORM(MAC)`. This flag is currently unused on iOS (no codepath sets it
to true).
* Source/WebKit/Shared/EditorState.serialization.in:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(WebKit::WKSelectionDrawingInfo::WKSelectionDrawingInfo):
(WebKit::operator<<):
Remove dead code on iOS, now that `isInPlugin` is only available on macOS.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
(WebKit::requires):
(WebKit::PDFPluginBase::convertFromRootViewToPlugin const):
(WebKit::PDFPluginBase::convertFromPluginToRootView const):
Turn these into templated coordinate space conversion helper methods, and use a `CanMakeFloatRect`
concept here to call `mapRect` for both `IntRect` and `FloatRect` at compile time; otherwise, call
`mapPoint` for both `IntPoint` and `FloatPoint`.
(WebKit::PDFPluginBase::setSelectionRange):
(WebKit::PDFPluginBase::platformPopulateEditorStateIfNeeded const):
Move logic to set the `isInPlugin` flag into `PDFPluginBase`, from `WebPage`. This, as far as I
could tell, was only used on iOS prior to PDFKit integration, when the legacy PDF plugin was still
utilized. It's now only required for macOS. On iOS, the unified PDF plugin instead populates the
relevant members of `EditorState` and its associated structs.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::populateEditorStateIfNeeded const):
(WebKit::PDFPluginBase::convertFromRootViewToPlugin const): Deleted.
(WebKit::PDFPluginBase::convertFromPluginToRootView const): Deleted.
See above.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::continueTrackingSelection):
Drive-by fix: remove some now-unneeded explicit casts to `PDFSelectionGranularity`.
(WebKit::UnifiedPDFPlugin::setCurrentSelection):
(WebKit::UnifiedPDFPlugin::setSelectionRange):
Add plumbing to set the current selection at the root view point, with the given granularity. This
is invoked when long pressing to set the selection. We map the root view point into plugin
coordinates, hit-test the `PDFDocument` for a selection under the point, and then update the current
selection.
(WebKit::UnifiedPDFPlugin::platformPopulateEditorStateIfNeeded const):
Add logic to assemble an `EditorState` representing the selected text range in the PDF plugin, based
on `PDFSelection`. For now, this just handles the case where the selection is a single piece of
left-to-right text on a single line; in future patches, we'll need the ability to coalesce adjacent
rects, handle bidirectional text, and a number of other use cases.
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::setSelectionRange):
(WebKit::PluginView::populateEditorStateIfNeeded const):
* Source/WebKit/WebProcess/Plugins/PluginView.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState const):
Refactor this to defer to the PDF plugin if needed.
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setFocusedFrameBeforeSelectingTextAtLocation):
Defer to the PDF plugin in the case where the focused or main frame is a PDF.
(WebKit::WebPage::setSelectionRange):
Canonical link: https://commits.webkit.org/287724@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list