Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7242348f028d45f8a1415f3cfe0b7d40c90de1da
      
https://github.com/WebKit/WebKit/commit/7242348f028d45f8a1415f3cfe0b7d40c90de1da
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2025-01-21 (Tue, 21 Jan 2025)

  Changed paths:
    M LayoutTests/pdf/two-pages-continuous-to-discrete-expected.html
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.h
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.mm
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.h
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.h
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm
    A Tools/TestWebKitAPI/Tests/WebKitCocoa/multiple-pages-colored.pdf

  Log Message:
  -----------
  [UnifiedPDF] [macOS] Switching from continuous to discrete mode will display 
the page(s) that are at the top of the window, even if barely visible
https://bugs.webkit.org/show_bug.cgi?id=286193
rdar://137608841

Reviewed by Tim Horton.

When switching between display modes, we need to decide an anchor point
to maintain the PDF document's view position post factum. We have been
using the top left (plugin space) as said anchor point, but when
switching out from a continuous display mode, the anchor point often
happens to be in the sliver of the previous page showing in the plugin
space, so after the transition, we end up landing on a previous page.

This patch addresses this logic error by instead adopting Preview's (and
PDFLayerController's) behavior of anchoring around the origin (top left)
of the page visible in the center of the plugin.

To facilitate these changes, we introduce a couple of helper methods,
namely `anchorPointForDocument()` and `pageIndexForCurrentView()`. These
helpers allow both the presentation controller instances to use shared
logic for `pdfPositionForCurrentView()`, so we devirtualize it. Note
that we don't use this new anchoring behavior for layout updates with
autoscaling behavior activated, since we still want to unconditionally
anchor around the plugin's top-left in that use case.

* LayoutTests/pdf/two-pages-continuous-to-discrete-expected.html:

Address some flakiness.

* 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.h:
* 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDiscretePresentationController.mm:
(WebKit::PDFDiscretePresentationController::pageIndexForCurrentView const):
(WebKit::PDFDiscretePresentationController::pdfPositionForCurrentView const): 
Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm:
(WebKit::PDFPresentationController::pdfPositionForCurrentView const):
(WebKit::PDFPresentationController::anchorPointForDocument const):
* 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.h:
* 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFScrollingPresentationController.mm:
(WebKit::PDFScrollingPresentationController::pageIndexForCurrentView const):
(WebKit::PDFScrollingPresentationController::pdfPositionForCurrentView const): 
Deleted.
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updateLayout):
(WebKit::UnifiedPDFPlugin::setDisplayModeAndUpdateLayout):
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/UnifiedPDFTests.mm:
(TestWebKitAPI::UnifiedPDFWithKeyboardScrolling::synchronouslyLoadPDFDocument):
(TestWebKitAPI::UnifiedPDFWithKeyboardScrolling::scrollDown):
(TestWebKitAPI::UnifiedPDFWithKeyboardScrolling::scrollRight):
(TestWebKitAPI::UnifiedPDFWithKeyboardScrolling::pressKey):
(TestWebKitAPI::TEST_F(UnifiedPDFWithKeyboardScrolling, 
KeyboardScrollingInSinglePageMode)):
(TestWebKitAPI::TEST_F(UnifiedPDFWithKeyboardScrolling, 
DisplayModeTransitionLandingPage)):

Introduce a UnifiedPDFWithKeyboardScrolling text fixture class, which
takes the keyboard scrolling technique from the existing API test -
KeyboardScrollingInSinglePageMode - and exposes it as convenient
`scroll[Down|Right]()` utilities. This fixture class is used to
introduce a new API test `DisplayModeTransitionLandingPage`.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/multiple-pages-colored.pdf: Added.

Canonical link: https://commits.webkit.org/289212@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

Reply via email to