Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 56edd4201d2fee53ba3f72c3d4618bd587c097ae
      
https://github.com/WebKit/WebKit/commit/56edd4201d2fee53ba3f72c3d4618bd587c097ae
  Author: Simon Fraser <simon.fra...@apple.com>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M LayoutTests/http/tests/pdf/linearized-pdf-in-iframe.html
    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] Maintain scroll position when zooming and resizing the window
https://bugs.webkit.org/show_bug.cgi?id=271938
rdar://119632576

Reviewed by Tim Horton.

Do a better job of preserving the page that is in the viewport ("restoring the 
scroll position")
under two circumstances:
1. We're in "Automatically Resize" mode and the user is resizing the window
2. Switching between Single Page and Two Page modes.

We do this by computing a point in the PDF page that is closest to the top of 
the viewport,
arbitrarily picking a point horizontally centered in that page.
`PDFDocumentLayout::pageIndexAndPagePointForDocumentYOffset()` has logic to 
pick the right page
if it is closer to the top (e.g. when page sizes are uneven).

After layout, we compute a new scroll position based on this page/point pair, 
and scroll to
it.

We avoid doing this when not in "Automatically Resize" mode because we don't 
want to clobber
the horizontal scroll position. We also need to ensure that we've laid out the 
PDF pages
at least once.

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.mm:
(WebKit::PDFDocumentLayout::pageIndexAndPagePointForDocumentYOffset const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h:
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::updateLayout):
(WebKit::UnifiedPDFPlugin::scrollAnchoringForCurrentScrollPosition const):
(WebKit::UnifiedPDFPlugin::restoreScrollPositionWithInfo):

Canonical link: https://commits.webkit.org/276946@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to