Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f1111014c1d28387fcb7dbdd673e69e6ffcc2004
      
https://github.com/WebKit/WebKit/commit/f1111014c1d28387fcb7dbdd673e69e6ffcc2004
  Author: Abrar Rahman Protyasha <[email protected]>
  Date:   2026-08-07 (Fri, 07 Aug 2026)

  Changed paths:
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/UnifiedPDFTests.mm

  Log Message:
  -----------
  Embedded PDFs do not re-fit when the plugin frame is resized
https://bugs.webkit.org/show_bug.cgi?id=321241
rdar://160319744

Reviewed by Richard Robinson and Megan Gardner.

The PDF plugin computes (and pins to) a scale from the frame's width
after the first layout, so a main frame PDF maintains user zoom across
window resizes. However, since subframe PDFs follow this same logic,
they are never re-fit when the _plugin frame_ itself is resized.

This is most notable with Site Isolation enabled since a cross origin
<iframe src=pdf> will often do its first layout pass with a provisional
frame (that is window sized) and then proceed to keep that bad scale
when the real size does eventually arrive (asynchronously). However, we
see the same issue when we modify the width attribute of any embedded
PDF div.

To fix this issue, we make subframe PDFs recompute its document layout
scale (and initialScale()) whenever its frame is resized, until of
course user zoom is applied and auto-resizing is disabled
unconditionally anyway.

Test: TestWebKitAPI.UnifiedPDF.EmbeddedPDFFitsToFrame

* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::geometryDidChange):
(WebKit::UnifiedPDFPlugin::updateLayout):
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/UnifiedPDFTests.mm:
(TestWebKitAPI::EmbeddedPDFFitsToFrame::embedElement const):
(TestWebKitAPI::EmbeddedPDFFitsToFrame::crossOrigin const):
(TestWebKitAPI::EmbeddedPDFFitsToFrame::siteIsolationEnabled const):
(TestWebKitAPI::EmbeddedPDFFitsToFrame::siteIsolationSharedProcessEnabled 
const):
(TestWebKitAPI::EmbeddedPDFFitsToFrame::testNameGenerator):
(TestWebKitAPI::TEST_P):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to