Changeset 213643 in webkit


Ignore:
Timestamp:
Mar 9, 2017 8:26:41 AM (7 years ago)
Author:
timothy_horton@apple.com
Message:

WKWebView should automatically respect insets from the view controller hierarchy
https://bugs.webkit.org/show_bug.cgi?id=169398
<rdar://problem/30617593>

Reviewed by Dean Jackson.

  • Platform/spi/ios/UIKitSPI.h:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _initializeWithConfiguration:]):
(-[WKWebView _computedContentInset]):
(activeMinimumLayoutSize):
(-[WKWebView _frameOrBoundsChanged]):
Factor insets from above us in the view controller hierarchy into our
content insets (and layout size) automatically.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r213638 r213643  
     12017-03-09  Tim Horton  <timothy_horton@apple.com>
     2
     3        WKWebView should automatically respect insets from the view controller hierarchy
     4        https://bugs.webkit.org/show_bug.cgi?id=169398
     5        <rdar://problem/30617593>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * Platform/spi/ios/UIKitSPI.h:
     10        * UIProcess/API/Cocoa/WKWebView.mm:
     11        (-[WKWebView _initializeWithConfiguration:]):
     12        (-[WKWebView _computedContentInset]):
     13        (activeMinimumLayoutSize):
     14        (-[WKWebView _frameOrBoundsChanged]):
     15        Factor insets from above us in the view controller hierarchy into our
     16        content insets (and layout size) automatically.
     17
    1182017-03-09  Tomas Popela  <tpopela@redhat.com>
    219
  • trunk/Source/WebKit2/Platform/spi/ios/UIKitSPI.h

    r213584 r213643  
    874874@end
    875875
     876@interface UIView ()
     877- (void)safeAreaInsetsDidChange;
     878@end
     879
     880@interface UIScrollView ()
     881@property (nonatomic, setter=_setEdgesScrollingContentIntoSafeArea:) UIRectEdge _edgesScrollingContentIntoSafeArea;
     882@property (nonatomic, readonly) UIEdgeInsets _systemContentInset;
     883@end
     884
    876885WTF_EXTERN_C_BEGIN
    877886
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r213590 r213643  
    507507    [_scrollView setBouncesZoom:YES];
    508508
     509    if ([_scrollView respondsToSelector:@selector(_setEdgesScrollingContentIntoSafeArea:)])
     510        [_scrollView _setEdgesScrollingContentIntoSafeArea:UIRectEdgeAll];
     511
    509512    [self addSubview:_scrollView.get()];
    510513
     
    13421345        return _obscuredInsets;
    13431346
    1344     return [_scrollView contentInset];
     1347    UIEdgeInsets insets = [_scrollView contentInset];
     1348
     1349    if ([_scrollView respondsToSelector:@selector(_systemContentInset)]) {
     1350        UIEdgeInsets systemInsets = [_scrollView _systemContentInset];
     1351        insets.top += systemInsets.top;
     1352        insets.bottom += systemInsets.bottom;
     1353        insets.left += systemInsets.left;
     1354        insets.right += systemInsets.right;
     1355    }
     1356
     1357    return insets;
    13451358}
    13461359
     
    21922205}
    21932206
     2207static WebCore::FloatSize activeMinimumLayoutSize(WKWebView *webView, const CGRect& bounds)
     2208{
     2209    if (webView->_overridesMinimumLayoutSize)
     2210        return WebCore::FloatSize(webView->_minimumLayoutSizeOverride);
     2211
     2212    if ([webView->_scrollView respondsToSelector:@selector(_systemContentInset)]) {
     2213        UIEdgeInsets systemContentInset = [webView->_scrollView _systemContentInset];
     2214        return WebCore::FloatSize(UIEdgeInsetsInsetRect(CGRectMake(0, 0, bounds.size.width, bounds.size.height), systemContentInset).size);
     2215    }
     2216
     2217    return WebCore::FloatSize(bounds.size);
     2218}
     2219
    21942220- (void)_frameOrBoundsChanged
    21952221{
     
    21992225    if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) {
    22002226        if (!_overridesMinimumLayoutSize)
    2201             _page->setViewportConfigurationMinimumLayoutSize(WebCore::FloatSize(bounds.size));
     2227            _page->setViewportConfigurationMinimumLayoutSize(activeMinimumLayoutSize(self, self.bounds));
    22022228        if (!_overridesMaximumUnobscuredSize)
    22032229            _page->setMaximumUnobscuredSize(WebCore::FloatSize(bounds.size));
     
    22332259    CGPoint boundedOffset = contentOffsetBoundedInValidRange(_scrollView.get(), contentOffset);
    22342260    return !pointsEqualInDevicePixels(contentOffset, boundedOffset, deviceScaleFactor);
     2261}
     2262
     2263- (void)safeAreaInsetsDidChange
     2264{
     2265    if ([super respondsToSelector:@selector(safeAreaInsetsDidChange)])
     2266        [super safeAreaInsetsDidChange];
     2267
     2268    [self _scheduleVisibleContentRectUpdate];
    22352269}
    22362270
     
    36553689
    36563690#if PLATFORM(IOS)
    3657 static WebCore::FloatSize activeMinimumLayoutSize(WKWebView *webView, const CGRect& bounds)
    3658 {
    3659     return WebCore::FloatSize(webView->_overridesMinimumLayoutSize ? webView->_minimumLayoutSizeOverride : bounds.size);
    3660 }
    3661 
    36623691static WebCore::FloatSize activeMaximumUnobscuredSize(WKWebView *webView, const CGRect& bounds)
    36633692{
Note: See TracChangeset for help on using the changeset viewer.