[webkit-changes] [WebKit/WebKit] 95e57b: UnifiedPDF: Discrete scrolling mode
Tim Horton
noreply at github.com
Wed Feb 14 16:07:32 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 95e57b0ff9882e5ebd1c28680930eb94ad52532c
https://github.com/WebKit/WebKit/commit/95e57b0ff9882e5ebd1c28680930eb94ad52532c
Author: Tim Horton <thorton at apple.com>
Date: 2024-02-14 (Wed, 14 Feb 2024)
Changed paths:
M Source/WebCore/platform/ScrollableArea.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
Log Message:
-----------
UnifiedPDF: Discrete scrolling mode
https://bugs.webkit.org/show_bug.cgi?id=269399
rdar://121940957
Reviewed by Simon Fraser.
* Source/WebCore/platform/ScrollableArea.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updatePageBackgroundLayers):
(WebKit::UnifiedPDFPlugin::paintPDFContent):
Don't paint pages that we don't want displayed.
(WebKit::UnifiedPDFPlugin::updateLayerHierarchy):
(WebKit::UnifiedPDFPlugin::setPageScaleFactor):
(WebKit::UnifiedPDFPlugin::didChangeScrollOffset):
Determine if the currently-snapped page changed after each scroll.
(WebKit::UnifiedPDFPlugin::populateScrollSnapIdentifiers):
Make fake ElementIdentifiers for each PDF page to appease
insufficiently-DOM-agnostic scroll snapping code.
(WebKit::UnifiedPDFPlugin::pageForScrollSnapIdentifier const):
Find the page index for the given fake ElementIdentifier.
(WebKit::UnifiedPDFPlugin::shouldUseScrollSnapping const):
(WebKit::UnifiedPDFPlugin::updateSnapOffsets):
Build up a synthetic scroll snapping offset table for the PDF pages, with
required stop points at the beginning and end of each page.
(WebKit::UnifiedPDFPlugin::updateSnappedPage):
Look up which page is currently snapped, by scroll position.
This is a bit rough; ideally it would use the current snap point but you
often don't have one, so instead we just assume it's the last page that's not
too far past the current scroll position.
This could be improved.
(WebKit::UnifiedPDFPlugin::shouldDisplayPage):
Determine if the given page should be painted (based on the snapping location).
We show both the snapped page and the one next to it if we're in 2-up.
(WebKit::UnifiedPDFPlugin::performContextMenuAction):
Resnap when the mode is changed, if needed.
Canonical link: https://commits.webkit.org/274671@main
More information about the webkit-changes
mailing list