⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 220286 in webkit


Ignore:
Timestamp:
Aug 4, 2017, 12:50:23 PM (9 years ago)
Author:
timothy_horton@apple.com
Message:

viewport-fit changes during animated resize can cause layout size to get stuck
​https://bugs.webkit.org/show_bug.cgi?id=175169
<rdar://problem/33684697>

Reviewed by Simon Fraser.

If we get a commit that changes viewport-fit state while an animated
resize is underway, and that change causes the client to push a new
minimumLayoutSizeOverride, the new size will be lost forever, and we
will get stuck laying out at the wrong size.

This is because we unconditionally apply avoidsUnsafeArea for every commit,
while most other changes that come in from a commit are ignored if we're
inside animated resize. To fix, also ignore avoidsUnsafeArea changes during
animated resize, by moving the code that keeps track of it into WKWebView
like all of the rest, and read it out of the commit in didCommitLayerTree
*after* the animated-resize early-return.

Also, fix the associated layout tests by adding a missing assignment
in _computedContentInset, which was broken in r220138.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
(-[WKWebView _processDidExit]):
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _setAvoidsUnsafeArea:]):
(-[WKWebView _safeAreaShouldAffectObscuredInsets]):
(-[WKWebView _didChangeAvoidsUnsafeArea:]): Deleted.

  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::resetState):
(WebKit::WebPageProxy::setAvoidsUnsafeArea): Deleted.

  • UIProcess/WebPageProxy.h:

(WebKit::WebPageProxy::avoidsUnsafeArea const): Deleted.

  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::didChangeAvoidsUnsafeArea): Deleted.

  • UIProcess/ios/WebPageProxyIOS.mm:

(WebKit::WebPageProxy::didCommitLayerTree):

Location:
trunk/Source/WebKit
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r220279 r220286  
     12017-08-04  Tim Horton  <timothy_horton@apple.com>
     2
     3        viewport-fit changes during animated resize can cause layout size to get stuck
     4        https://bugs.webkit.org/show_bug.cgi?id=175169
     5        <rdar://problem/33684697>
     6
     7        Reviewed by Simon Fraser.
     8
     9        If we get a commit that changes viewport-fit state while an animated
     10        resize is underway, and that change causes the client to push a new
     11        minimumLayoutSizeOverride, the new size will be lost forever, and we
     12        will get stuck laying out at the wrong size.
     13
     14        This is because we unconditionally apply avoidsUnsafeArea for every commit,
     15        while most other changes that come in from a commit are ignored if we're
     16        inside animated resize. To fix, also ignore avoidsUnsafeArea changes during
     17        animated resize, by moving the code that keeps track of it into WKWebView
     18        like all of the rest, and read it out of the commit in didCommitLayerTree
     19        *after* the animated-resize early-return.
     20
     21        Also, fix the associated layout tests by adding a missing assignment
     22        in _computedContentInset, which was broken in r220138.
     23
     24        * UIProcess/API/Cocoa/WKWebView.mm:
     25        (-[WKWebView _initializeWithConfiguration:]):
     26        (-[WKWebView _setHasCustomContentView:loadedMIMEType:]):
     27        (-[WKWebView _processDidExit]):
     28        (-[WKWebView _didCommitLayerTree:]):
     29        (-[WKWebView _setAvoidsUnsafeArea:]):
     30        (-[WKWebView _safeAreaShouldAffectObscuredInsets]):
     31        (-[WKWebView _didChangeAvoidsUnsafeArea:]): Deleted.
     32        * UIProcess/API/Cocoa/WKWebViewInternal.h:
     33        * UIProcess/PageClient.h:
     34        * UIProcess/WebPageProxy.cpp:
     35        (WebKit::WebPageProxy::resetState):
     36        (WebKit::WebPageProxy::setAvoidsUnsafeArea): Deleted.
     37        * UIProcess/WebPageProxy.h:
     38        (WebKit::WebPageProxy::avoidsUnsafeArea const): Deleted.
     39        * UIProcess/ios/PageClientImplIOS.h:
     40        * UIProcess/ios/PageClientImplIOS.mm:
     41        (WebKit::PageClientImpl::didChangeAvoidsUnsafeArea): Deleted.
     42        * UIProcess/ios/WebPageProxyIOS.mm:
     43        (WebKit::WebPageProxy::didCommitLayerTree):
     44
    1452017-08-04  Matt Lewis  <jlewis3@apple.com>
    246
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r220138 r220286  
    247247    UIEdgeInsets _unobscuredSafeAreaInsets;
    248248    BOOL _haveSetUnobscuredSafeAreaInsets;
     249    BOOL _avoidsUnsafeArea;
    249250    UIRectEdge _obscuredInsetEdgesAffectedBySafeArea;
    250251
    … …  
    524525    [_scrollView setBouncesZoom:YES];
    525526
     527    _avoidsUnsafeArea = YES;
    526528    [self _updateScrollViewInsetAdjustmentBehavior];
    527529
    … …  
    12691271        [_scrollView setContentOffset:[self _adjustedContentOffset:CGPointZero]];
    12701272
    1271         [self _didChangeAvoidsUnsafeArea:NO];
     1273        [self _setAvoidsUnsafeArea:NO];
    12721274    } else if (_customContentView) {
    12731275        [_customContentView removeFromSuperview];
    … …  
    12831285        [_customContentFixedOverlayView setFrame:self.bounds];
    12841286        [self addSubview:_customContentFixedOverlayView.get()];
    1285 
    1286         [self _didChangeAvoidsUnsafeArea:_page->avoidsUnsafeArea()];
    12871287    }
    12881288
    … …  
    14081408#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
    14091409    if (self._safeAreaShouldAffectObscuredInsets)
    1410         UIEdgeInsetsAdd(insets, [_scrollView _systemContentInset], self._effectiveObscuredInsetEdgesAffectedBySafeArea);
     1410        insets = UIEdgeInsetsAdd(insets, [_scrollView _systemContentInset], self._effectiveObscuredInsetEdgesAffectedBySafeArea);
    14111411#endif
    14121412
    … …  
    14621462    _firstTransactionIDAfterPageRestore = 0;
    14631463    _resizeAnimationTransformTransactionID = std::nullopt;
     1464
     1465    _avoidsUnsafeArea = YES;
    14641466}
    14651467
    … …  
    15601562
    15611563    [self _updateScrollViewBackground];
     1564    [self _setAvoidsUnsafeArea:layerTreeTransaction.avoidsUnsafeArea()];
    15621565
    15631566    if (_gestureController)
    … …  
    27182721}
    27192722
    2720 - (void)_didChangeAvoidsUnsafeArea:(BOOL)avoidsUnsafeArea
    2721 {
     2723- (void)_setAvoidsUnsafeArea:(BOOL)avoidsUnsafeArea
     2724{
     2725    if (_avoidsUnsafeArea == avoidsUnsafeArea)
     2726        return;
     2727
     2728    _avoidsUnsafeArea = avoidsUnsafeArea;
     2729
    27222730    [self _updateScrollViewInsetAdjustmentBehavior];
    27232731    [self _scheduleVisibleContentRectUpdate];
    … …  
    46734681    if (![self usesStandardContentView])
    46744682        return NO;
    4675     if (!_page)
    4676         return YES;
    4677     return _page->avoidsUnsafeArea();
     4683    return _avoidsUnsafeArea;
    46784684}
    46794685
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h

    r220138 r220286  
    120120- (void)_hidePasswordView;
    121121
    122 - (void)_didChangeAvoidsUnsafeArea:(BOOL)avoidsUnsafeArea;
    123 
    124122- (void)_addShortcut:(id)sender;
    125123- (void)_arrowKey:(id)sender;
  • trunk/Source/WebKit/UIProcess/API/gtk/PageClientImpl.h

    r218740 r220286  
    147147    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override { return WebCore::UserInterfaceLayoutDirection::LTR; }
    148148
    149     void didChangeAvoidsUnsafeArea(bool) override { }
    150 
    151149    JSGlobalContextRef javascriptGlobalContext() override;
    152150
  • trunk/Source/WebKit/UIProcess/API/wpe/PageClientImpl.h

    r218740 r220286  
    118118    WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() override;
    119119
    120     void didChangeAvoidsUnsafeArea(bool) override { }
    121 
    122120    JSGlobalContextRef javascriptGlobalContext() override;
    123121
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r219340 r220286  
    385385#endif
    386386
    387     virtual void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) = 0;
    388 
    389387#if PLATFORM(GTK) || PLATFORM(WPE)
    390388    virtual JSGlobalContextRef javascriptGlobalContext() { return nullptr; }
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r220115 r220286  
    55155515    requestPointerUnlock();
    55165516#endif
    5517 
    5518     m_avoidsUnsafeArea = true;
    55195517}
    55205518
    … …  
    69516949}
    69526950
    6953 void WebPageProxy::setAvoidsUnsafeArea(bool avoidsUnsafeArea)
    6954 {
    6955     if (m_avoidsUnsafeArea == avoidsUnsafeArea)
    6956         return;
    6957 
    6958     m_avoidsUnsafeArea = avoidsUnsafeArea;
    6959 
    6960     m_pageClient.didChangeAvoidsUnsafeArea(avoidsUnsafeArea);
    6961 }
    6962 
    69636951} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r220011 r220286  
    12021202#endif
    12031203
    1204     void setAvoidsUnsafeArea(bool);
    1205     bool avoidsUnsafeArea() const { return m_avoidsUnsafeArea; }
    1206 
    12071204private:
    12081205    WebPageProxy(PageClient&, WebProcessProxy&, uint64_t pageID, Ref<API::PageConfiguration>&&);
    … …  
    20011998    bool m_isUsingHighPerformanceWebGL { false };
    20021999
    2003     bool m_avoidsUnsafeArea { true };
    2004 
    20052000    WeakPtrFactory<WebPageProxy> m_weakPtrFactory;
    20062001
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h

    r219340 r220286  
    200200    void handleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, const String& title, double duration, double elapsedTime) override;
    201201
    202     void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) override;
    203 
    204202#if USE(QUICK_LOOK)
    205203    void requestPasswordForQuickLookDocument(const String& fileName, WTF::Function<void(const String&)>&&) override;
  • trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm

    r219340 r220286  
    827827#endif
    828828
    829 void PageClientImpl::didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea)
    830 {
    831     [m_webView _didChangeAvoidsUnsafeArea:avoidsUnsafeArea];
    832 }
    833 
    834829} // namespace WebKit
    835830
  • trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm

    r219996 r220286  
    373373{
    374374    m_pageExtendedBackgroundColor = layerTreeTransaction.pageExtendedBackgroundColor();
    375     setAvoidsUnsafeArea(layerTreeTransaction.avoidsUnsafeArea());
    376375
    377376    if (!m_hasReceivedLayerTreeTransactionAfterDidCommitLoad) {
  • trunk/Source/WebKit/UIProcess/mac/PageClientImpl.h

    r217566 r220286  
    254254    void didRestoreScrollPosition() override;
    255255    bool windowIsFrontWindowUnderMouse(const NativeWebMouseEvent&) override;
    256 
    257     void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) override { }
    258256};
    259257
Note: See TracChangeset for help on using the changeset viewer.