Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: be2067342cce44336c3e59d9217d6e7af47cecb2
      
https://github.com/WebKit/WebKit/commit/be2067342cce44336c3e59d9217d6e7af47cecb2
  Author: Aditya Keerthi <[email protected]>
  Date:   2025-11-18 (Tue, 18 Nov 2025)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Tools/TestWebKitAPI/Tests/ios/WKScrollViewTests.mm
    M Tools/TestWebKitAPI/cocoa/TestCocoa.h
    M Tools/TestWebKitAPI/cocoa/TestCocoa.mm

  Log Message:
  -----------
  [iOS] `viewport-fit: auto` is not honored when navigating from a page with 
`viewport-fit: cover`
https://bugs.webkit.org/show_bug.cgi?id=302676
rdar://164923783

Reviewed by Abrar Rahman Protyasha.

`viewport-fit: cover` works by setting the content inset adjustment behavior on
`WKScrollView` to `UIScrollViewContentInsetAdjustmentNever`. When the value of
viewport-fit changes, the scroll view's content inset adjustment behavior must
also be changed. This is normally done in `-[WKWebView _setAvoidsUnsafeArea:]`.
However, that method has an early return if `_perProcessState.avoidsUnsafeArea`
is equal to the input parameter. Due to process-swap-on-navigation,
`_perProcessState` is reset (to true) when navigating from a page with
`viewport-fit: auto` to `viewport-fit: cover`. `-[WKWebView 
_setAvoidsUnsafeArea:]`
is only called on the next layer tree transaction. Consequently,
`-[WKWebView _setAvoidsUnsafeArea:]` is a no-op, as `viewport-fit: auto` wants
"avoids unsafe area" to be true, and the `_perProcessState` already has it as 
such.

Fix by moving `avoidsUnsafeArea` out of per-process-state, and making it an
instance variable on `WKWebView`. There is no need to reset this variable on
process-swap or exit. If it needs to be updated, it will be on the next layer
tree transaction.

* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _initializeWithConfiguration:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _setAvoidsUnsafeArea:]):
(-[WKWebView _safeAreaShouldAffectObscuredInsets]):
* Tools/TestWebKitAPI/Tests/ios/WKScrollViewTests.mm:
(TestWebKitAPI::TEST(WKScrollViewTests, 
ContentInsetAdjustmentBehaviorChangeAfterViewportFitChange)):
* Tools/TestWebKitAPI/cocoa/TestCocoa.h:
* Tools/TestWebKitAPI/cocoa/TestCocoa.mm:
(operator<<):
(operator==):

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



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

Reply via email to