Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b4363b9b36946b63017de1b6d8b8e924dbf23e56
      
https://github.com/WebKit/WebKit/commit/b4363b9b36946b63017de1b6d8b8e924dbf23e56
  Author: Aditya Keerthi <[email protected]>
  Date:   2026-10-06 (Tue, 06 Oct 2026)

  Changed paths:
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WTF/wtf/PlatformHave.h
    M Source/WebKit/Shared/WebPageCreationParameters.h
    M Source/WebKit/Shared/WebPageCreationParameters.serialization.in
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxyInternals.h
    M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
    M 
Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm
    M Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm
    M Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/WebPage.messages.in
    M Source/WebKit/WebProcess/WebPage/WebPageInternals.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

  Log Message:
  -----------
  Display PDFs in two-up when the iPhone Duo is partially folded
https://bugs.webkit.org/show_bug.cgi?id=326418
rdar://187132500

Reviewed by Abrar Rahman Protyasha.

When the iPhone Duo is partially folded, with the fold dividing the web view
vertically in half, display PDFs in two-up continuous mode. When the fold no
longer divides the view, return to single page continuous mode.

UIKit exposes the fold as a division reserved region. Whenever `WKWebView` lays
out its subviews, it checks for a single division region that leaves content on
both sides and is centered within the unobscured bounds of the view. The display
mode is only changed when the result of this check changes, so that a user
choice to explicitly enter two-up (which is possible on iPad using a context
menu), is not overridden by subsequent layouts.

PDFs that are loaded while the device is already folded should open in two-up,
rather than opening in single page mode and then switching. To support this, the
UI process sends the initial PDF display mode to the web process, both directly
and in the page creation parameters, and `UnifiedPDFPlugin` uses it as the
initial display mode for full main frame plugins.

When the device is folded, left-align a trailing odd page in two-up mode, so
that it is in the same column as the first page, rather than centered over the
fold.

Finally, partially fix the scroll position after changing the display mode on
iOS. `pdfPositionForCurrentView` anchored to the origin of the plugin. When the
plugin is sized to fit its content, the main frame scrolls rather than the
plugin, so that origin is the top of the document, not the top of the visible
area. Anchor to the top-left of the unobscured content rect instead, using
`anchorPointInDocumentSpace`. In this case, also preserve the horizontal
position, rather than revealing the horizontal center of the page, which relied
on the resulting scroll position being clamped. Note that there are still some
remaining issues with position preservation, tracked in rdar://188627419.

* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:

Remove `TwoUpPDFTrailingPageLeftAlignmentEnabled`. This preference is not
needed anywhere else, and the determination is now done by detecting whether
the device is partially folded.

* Source/WTF/wtf/PlatformHave.h:

Use `__has_include` while SDKs are still in a transient state.

* Source/WebKit/Shared/WebPageCreationParameters.h:
* Source/WebKit/Shared/WebPageCreationParameters.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView layoutSubviews]):
(-[WKWebView _updatePDFDisplayModeIfNeeded]):

Choose the display mode based on the division reserved region, and only request
a new mode when the choice changes.

* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxyInternals.h:
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::setInitialPDFDisplayMode):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/PDFPresentationController.mm:
(WebKit::PDFPresentationController::pdfPositionForCurrentView const):
* Source/WebKit/WebProcess/Plugins/PDF/UnifiedPDF/UnifiedPDFPlugin.mm:
(WebKit::UnifiedPDFPlugin::UnifiedPDFPlugin):

Use the initial display mode from the page for full main frame plugins.

(WebKit::UnifiedPDFPlugin::updateLayout):

Left-align a trailing odd page in two-up mode when the device is folded.

* Source/WebKit/WebProcess/WebPage/Cocoa/WebPageCocoa.mm:
(WebKit::WebPage::platformInitialize):
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Source/WebKit/WebProcess/WebPage/WebPageInternals.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::initialPDFDisplayMode const):
(WebKit::WebPage::setInitialPDFDisplayMode):

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



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

Reply via email to