[webkit-changes] [WebKit/WebKit] 70f074: [UnifiedPDF] [iOS] Support tap-and-drag and tap-an...
Wenson Hsieh
noreply at github.com
Fri Dec 13 14:24:02 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 70f0749b52792ef31ff7de092be021912fce330e
https://github.com/WebKit/WebKit/commit/70f0749b52792ef31ff7de092be021912fce330e
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2024-12-13 (Fri, 13 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
Log Message:
-----------
[UnifiedPDF] [iOS] Support tap-and-drag and tap-and-half for text selections
https://bugs.webkit.org/show_bug.cgi?id=284641
rdar://141324790
Reviewed by Abrar Rahman Protyasha.
Add support for additional text interaction gestures when selecting text on iOS with unified PDF
enabled: tap-and-a-half, and tap-and-drag. See below for more details.
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.h:
* Source/WebKit/WebProcess/Plugins/PDF/PDFPluginBase.mm:
(WebKit::PDFPluginBase::extendInitialSelection):
Add more plumbing through `PluginView` → `PDFPluginBase` → `UnifiedPDFPlugin` to handle this new
selection extent update.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::areVisuallyDistinct):
(WebKit::UnifiedPDFPlugin::clearSelection):
(WebKit::UnifiedPDFPlugin::setSelectionRange):
Teach `UnifiedPDFPlugin` to keep track of the initial selection when using `setSelectionRange` to
select text, so that we can use it in `extendInitialSelection` for these new text interactions.
(WebKit::isEmpty):
(WebKit::UnifiedPDFPlugin::moveSelectionEndpoint):
Adopt the new `selectionBetweenPoints` helper below.
(WebKit::UnifiedPDFPlugin::resetInitialSelection):
Reset the initial selection, along with the initial selection start info.
(WebKit::UnifiedPDFPlugin::selectionBetweenPoints const):
Add a new helper method to obtain a selection at the given point relative to the given page's
coordinate space, with the given granularity.
(WebKit::UnifiedPDFPlugin::selectionAtPoint const):
Add a new helper method to obtain a selection between two points in the document (at character
granularity).
(WebKit::UnifiedPDFPlugin::extendInitialSelection):
Add support for extending the selection to the given point here. This method works by:
1. Mapping the given point in root view coordinates to a point in a PDF page.
2. Getting the PDF selection (with the given granularity) at that point.
3. Expanding and canonicalizing the selection from (2) to include the initial selection range as
well (note that this does not include any text in between).
4. Setting the current selection to a new selection that encompasses all selectable text in between
the extent point, and the initial selection.
5. Returning the selection endpoint that moved as a result of running the above steps (by checking
whether or not the start position has changed).
(WebKit::UnifiedPDFPlugin::selectionCaretPointInPage):
(WebKit::UnifiedPDFPlugin::selectionCaretPointInPage const):
Drive-by refactoring: adjust these helpers to just return a `PageAndPoint` rather than
`optional<PageAndPoint>`. In the case where the result is invalid, the page is `nil` anyways, and
all call sites check for this; as such, the optional wrapping is unnecessary, and makes the code
slightly more difficult to read because the call site can't directly use destructuring assignment.
* Source/WebKit/WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::moveSelectionEndpoint):
(WebKit::PluginView::extendInitialSelection):
Plumb over to the PDF plugin.
* Source/WebKit/WebProcess/Plugins/PluginView.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::updateSelectionWithExtentPointAndBoundary):
Defer to the PDF plugin if needed (see above).
Canonical link: https://commits.webkit.org/287816@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