Skip to content

Commit

Permalink
Cherry-pick e5bf2b8. rdar://118147164
Browse files Browse the repository at this point in the history
    [iOS] Non-fullscreen content peeks into top safe area in element fullscreen mode
    https://bugs.webkit.org/show_bug.cgi?id=264455
    rdar://118147164

    Reviewed by Simon Fraser.

    When entering fullscreen, certain properties of the WKWebView and scrollView are reset to
    default values, as clients like Safari may have overridden them. One of these properties,
    contentInset, is reset to zero by that machinery. However, this causes overflow content to
    be visible above the safe area; instead, it should be reset to a correct initial value that
    accounts for the page's adoption of safe areas, via -_initialContentOffsetForScrollView.

    * Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h:
    * Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
    (-[WKWebView _resetContentOffset]):
    * Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
    (-[WKFullScreenWindowController enterFullScreen:]):

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

Identifier: 267815.555@safari-7617-branch
  • Loading branch information
Dan Robson committed Nov 9, 2023
1 parent f834d52 commit dc15bd8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/API/ios/WKWebViewIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class VisibleContentRectUpdateInfo;
@property (nonatomic, readonly) std::optional<CGSize> _viewLayoutSizeOverride;
@property (nonatomic, readonly) std::optional<CGSize> _minimumUnobscuredSizeOverride;
@property (nonatomic, readonly) std::optional<CGSize> _maximumUnobscuredSizeOverride;
- (void)_resetContentOffset;
- (void)_resetUnobscuredSafeAreaInsets;
- (void)_resetObscuredInsets;

Expand Down
5 changes: 5 additions & 0 deletions Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3449,6 +3449,11 @@ - (BOOL)_haveSetUnobscuredSafeAreaInsets
return _haveSetUnobscuredSafeAreaInsets;
}

- (void)_resetContentOffset
{
[_scrollView setContentOffset:[self _initialContentOffsetForScrollView]];
}

- (void)_resetUnobscuredSafeAreaInsets
{
_haveSetUnobscuredSafeAreaInsets = NO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,7 @@ - (void)enterFullScreen:(CGSize)videoDimensions
[webView _setMinimumEffectiveDeviceWidth:0];
[webView _setViewScale:1.f];
WebKit::WKWebViewState().applyTo(webView.get());
[webView _resetContentOffset];
[_window insertSubview:webView.get() atIndex:0];
[webView setNeedsLayout];
[webView layoutIfNeeded];
Expand Down

0 comments on commit dc15bd8

Please sign in to comment.