Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] Adjust the bindings-exposed screen size in headless browser mode #13998

Merged
merged 1 commit into from
May 18, 2023

Commits on May 18, 2023

  1. [iOS] Adjust the bindings-exposed screen size in headless browser mode

    https://bugs.webkit.org/show_bug.cgi?id=256939
    
    Reviewed by Alan Baradlay.
    
    Add different, platform-specific strategies when returning an appropriate screen size for bindings
    in headless browsing. See below for more details.
    
    Changes covered by a new API test (and adjustments to some existing tests).
    
    * Source/WebCore/page/ChromeClient.h:
    (WebCore::ChromeClient::screenSizeForHeadlessMode const):
    
    Add a chrome client hook to return a screen size specifically for "headless mode", given the
    requesting frame and the actual screen size.
    
    * Source/WebCore/page/LocalFrame.cpp:
    (WebCore::LocalFrame::screenSize const):
    * Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
    (WebKit::WebChromeClient::screenSizeForHeadlessMode const):
    
    Add some plumbing out to `WebPage`.
    
    * Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
    * Source/WebKit/WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::screenSizeForHeadlessMode const):
    
    Move the logic currently in `LocalFrame::screenSize` over to this method; additionally, instead of
    trying to counterscale the innerWidth/innerHeight, simply return the unobscured content rect; this
    does not change with `pageScaleFactor` on macOS, eliminating the need for counterscaling.
    
    * Source/WebKit/WebProcess/WebPage/WebPage.h:
    * Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
    (WebKit::WebPage::screenSizeForHeadlessMode const):
    
    Implement an iOS-specific strategy for `screenSizeForHeadlessMode`, returning one of three canned
    values on iPhone (based on the current user idiom), and falling back to the initial containing block
    (ignoring the current scale factor, by using `ViewportConfiguration::minimumLayoutSize()`) on iPad.
    
    Canonical link: https://commits.webkit.org/264200@main
    whsieh committed May 18, 2023
    Configuration menu
    Copy the full SHA
    e82dfc6 View commit details
    Browse the repository at this point in the history