Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 0a6c80bc21cba9b3b65f6d7eec39d711f970295d
https://github.com/WebKit/WebKit/commit/0a6c80bc21cba9b3b65f6d7eec39d711f970295d
Author: Wenson Hsieh <[email protected]>
Date: 2025-01-28 (Tue, 28 Jan 2025)
Changed paths:
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WebKit/test-rotated-cw-90.pdf
M Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm
Log Message:
-----------
[iOS] [UnifiedPDF] Support text interactions and selection in rotated PDF
pages
https://bugs.webkit.org/show_bug.cgi?id=286599
rdar://141946781
Reviewed by Abrar Rahman Protyasha.
Add support for proper text selection rendering and text interactons in rotated
pages of a PDF
document when unified PDF is enabled. See below for more details.
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::selectionCaretPointInPage const):
Rewrite this helper method to account for axis-aligned rotations (i.e. 90°,
180°, or 270°) when
finding the locations of the start and end character positions in the selected
range. Currently,
this method always assumes that the end of a selected piece of text is close to
the right edge of
the selection rect, while the start is close to the left edge; however, this
strategy only works
when the PDF is not rotated at all.
To make this more robust, we map selection rects for the given `PDFSelection`
into the root view,
and then choose the midpoint of the top, left, bottom or right edge of the root
view rect depending
on which way the PDF is rotated. We determine this by calculating the
`cumulativeTransform` when
mapping from PDF page to content coordinates, and then extracting just the
approximate rotation in
degrees (rounding to the nearest 90°) from this transform using the `a` and `b`
values of the affine
transformation.
Finally, once we've determined which edge is closest to the start or end
position of the selection,
we then remap this back to PDF page coordinates.
(WebKit::UnifiedPDFPlugin::platformPopulateEditorStateIfNeeded const):
Honor transforms on each of the selection rects' bounds when collecting
selection geometries for
`EditorState` in PDFs.
(WebKit::UnifiedPDFPlugin::selectionCaretPointInPage): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
Add a new test PDF that's rotated 90 degrees clockwise.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm:
(TestWebKitAPI::UNIFIED_PDF_TEST):
Add a new API test to exercise this change, by sanity checking the dimensions
of a piece of selected
text selection in a rotated PDF.
Canonical link: https://commits.webkit.org/289481@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes