[webkit-changes] [WebKit/WebKit] 55b051: [UnifiedPDF] Fix context menu page navigation for ...
Sammy Gill
noreply at github.com
Fri Feb 16 11:15:58 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 55b05170db3b61e4d6266a0a9580f4665adcbb39
https://github.com/WebKit/WebKit/commit/55b05170db3b61e4d6266a0a9580f4665adcbb39
Author: Sammy Gill <sammy.gill at apple.com>
Date: 2024-02-16 (Fri, 16 Feb 2024)
Changed paths:
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
Log Message:
-----------
[UnifiedPDF] Fix context menu page navigation for 2up.
https://bugs.webkit.org/show_bug.cgi?id=269501
rdar://problem/123032781
Reviewed by Simon Fraser.
274737 at main provided the initial implementation for navigating between
pages using context menu options. It worked fine for pages in single
page display modes but not all the time in two up display modes. This
patch tries to address that by making sure we navigate between pairs
of pages in two up mode.
When determining which page to scroll to in two up mode we need to
consider whether the "current page," is the first page in the row or the
second page in the row. If we are navigating forwards and the "current
page," is the first page in the row, then we need to navigate two pages
forward to go to the next row. Similarly, if we are navigating backwards
and the "current page," is the second page in the row, we need to
go two pages backwards.
I also changed indexForCurrentPageInView to use a new method,
nearestPageIndexForDocumentPoint, instead of pageIndexForDocumentPoint
since it was not guaranteed the later would alawys return a page index.
Fow single page mode, this new method iterates over the pages in order
and compares the point with the bottom of each page. Once we find a page
point's Y location that is lower than the document points' then we have
found the page the point is contained in. Two up modes works in the
same way except we also need to compare the X location for the points.
I also renamed the DisplayModes enums to explicitly state whether they
are discrete or continuous to help introduce some new helpers without
them having confusing names (isSinglePageDisplayMode and
isTwoUpDisplayMode).
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
(WebKit::PDFDocumentLayout::isSinglePageDisplayMode const):
(WebKit::PDFDocumentLayout::isTwoUpDisplayMode const):
(WebKit::PDFDocumentLayout::pagesPerRow const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::isLeftPageIndex const):
(WebKit::PDFDocumentLayout::isRightPageIndex const):
(WebKit::PDFDocumentLayout::isLastPageIndex const):
(WebKit::PDFDocumentLayout::nearestPageIndexForDocumentPoint const):
(WebKit::PDFDocumentLayout::updateLayout):
(WebKit::PDFDocumentLayout::layoutPages):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::shouldUseScrollSnapping const):
(WebKit::UnifiedPDFPlugin::shouldDisplayPage):
(WebKit::UnifiedPDFPlugin::indexForCurrentPageInView const):
(WebKit::UnifiedPDFPlugin::contextMenuItemTagFromDisplayMode const):
(WebKit::UnifiedPDFPlugin::displayModeFromContextMenuItemTag const):
(WebKit::UnifiedPDFPlugin::navigationContextMenuItems const):
(WebKit::UnifiedPDFPlugin::performContextMenuAction):
Canonical link: https://commits.webkit.org/274858@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