[webkit-changes] [WebKit/WebKit] 2c9d24: [UnifiedPDF] PDF is opening in Safari zoomed in an...

Simon Fraser noreply at github.com
Thu Mar 28 21:56:27 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2c9d242f87f88dd7f4d777ea9f8bc0381345bf03
      https://github.com/WebKit/WebKit/commit/2c9d242f87f88dd7f4d777ea9f8bc0381345bf03
  Author: Simon Fraser <simon.fraser at apple.com>
  Date:   2024-03-28 (Thu, 28 Mar 2024)

  Changed paths:
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFDocumentLayout.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.h
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm

  Log Message:
  -----------
  [UnifiedPDF] PDF is opening in Safari zoomed in and off-center
https://bugs.webkit.org/show_bug.cgi?id=271870
rdar://125382902

Reviewed by Abrar Rahman Protyasha and Sammy Gill.

Safari does per-site saving of page zoom, which means that when you re-open a PDF, it calls `UnifiedPDFPlugin::setPageScaleFactor()`
before we've received the PDFDocument. This causes `UnifiedPDFPlugin::setPageScaleFactor()` to set `m_shouldUpdateAutoSizeScale` to `ShouldUpdateAutoSizeScale::No`.

When then run `PDFDocumentLayout::updateLayout()` with a null document, and compute a small maxRowWidth which is just the margins,
thus computing a huge scale. And because `m_shouldUpdateAutoSizeScale` is forever after `ShouldUpdateAutoSizeScale::No`, we get stuck
with this huge scale.

Fix by ensuring that the first layout with a non-null PDFDocument runs with `ShouldUpdateAutoSizeScale::Yes`.

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

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