Changeset 185576 in webkit


Ignore:
Timestamp:
Jun 15, 2015 7:10:58 PM (9 years ago)
Author:
Simon Fraser
Message:

[iOS WK2] position:fixed elements sometimes truncated on scroll view bouncing
https://bugs.webkit.org/show_bug.cgi?id=146000
rdar://problem/19448439

Reviewed by Benjamin Poulain.

When in the middle of a rubber-band (UIScrollView bounce), we could send a bad
fixed position rect down to WebCore, causing 100% height elements to get laid out
at the wrong height, possible too short. This occurred when -_updateVisibleContentRects
said we were in a stable state, but the rubber-band offset caused WebPageProxy::computeCustomFixedPositionRect()
to compute a bad rect via constrainedUnobscuredRect.intersect(documentRect).

Fix by not claiming to be in a stable state during rubber-banding. Added _scrollViewIsRubberBanding
to compute that, taking care with floating point comparisons for 3x devices.

  • UIProcess/API/Cocoa/WKWebView.mm:

(isGreaterInDevicePixels):
(-[WKWebView _scrollViewIsRubberBanding]):
(-[WKWebView _updateVisibleContentRects]):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r185568 r185576  
     12015-06-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        [iOS WK2] position:fixed elements sometimes truncated on scroll view bouncing
     4        https://bugs.webkit.org/show_bug.cgi?id=146000
     5        rdar://problem/19448439
     6
     7        Reviewed by Benjamin Poulain.
     8       
     9        When in the middle of a rubber-band (UIScrollView bounce), we could send a bad
     10        fixed position rect down to WebCore, causing 100% height elements to get laid out
     11        at the wrong height, possible too short. This occurred when -_updateVisibleContentRects
     12        said we were in a stable state, but the rubber-band offset caused WebPageProxy::computeCustomFixedPositionRect()
     13        to compute a bad rect via constrainedUnobscuredRect.intersect(documentRect).
     14       
     15        Fix by not claiming to be in a stable state during rubber-banding. Added _scrollViewIsRubberBanding
     16        to compute that, taking care with floating point comparisons for 3x devices.
     17
     18        * UIProcess/API/Cocoa/WKWebView.mm:
     19        (isGreaterInDevicePixels):
     20        (-[WKWebView _scrollViewIsRubberBanding]):
     21        (-[WKWebView _updateVisibleContentRects]):
     22
    1232015-06-15  Ryuan Choi  <ryuan.choi@navercorp.com>
    224
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r185556 r185576  
    690690}
    691691
     692static inline bool pointsEqualInDevicePixels(CGPoint a, CGPoint b, float deviceScaleFactor)
     693{
     694    return fabs(a.x * deviceScaleFactor - b.x * deviceScaleFactor) < std::numeric_limits<float>::epsilon()
     695        && fabs(a.y * deviceScaleFactor - b.y * deviceScaleFactor) < std::numeric_limits<float>::epsilon();
     696}
     697
    692698static CGSize roundScrollViewContentSize(const WebKit::WebPageProxy& page, CGSize contentSize)
    693699{
     
    15141520}
    15151521
     1522// Ideally UIScrollView would expose this for us: <rdar://problem/21394567>.
     1523- (BOOL)_scrollViewIsRubberBanding
     1524{
     1525    float deviceScaleFactor = _page->deviceScaleFactor();
     1526
     1527    CGPoint contentOffset = [_scrollView contentOffset];
     1528    CGPoint boundedOffset = contentOffsetBoundedInValidRange(_scrollView.get(), contentOffset);
     1529    return !pointsEqualInDevicePixels(contentOffset, boundedOffset, deviceScaleFactor);
     1530}
     1531
    15161532- (void)_updateVisibleContentRects
    15171533{
     
    15401556    CGFloat scaleFactor = contentZoomScale(self);
    15411557
    1542     BOOL isStableState = !(_isChangingObscuredInsetsInteractively || [_scrollView isDragging] || [_scrollView isDecelerating] || [_scrollView isZooming] || [_scrollView isZoomBouncing] || [_scrollView _isAnimatingZoom] || [_scrollView _isScrollingToTop]);
     1558    BOOL isStableState = !(_isChangingObscuredInsetsInteractively || [_scrollView isDragging] || [_scrollView isDecelerating] || [_scrollView isZooming] || [_scrollView isZoomBouncing] || [_scrollView _isAnimatingZoom] || [_scrollView _isScrollingToTop] || [self _scrollViewIsRubberBanding]);
    15431559
    15441560    // FIXME: this can be made static after we stop supporting iOS 8.x.
Note: See TracChangeset for help on using the changeset viewer.