Changeset 225714 in webkit


Ignore:
Timestamp:
Dec 8, 2017 4:00:09 PM (6 years ago)
Author:
Simon Fraser
Message:

When the iPhone keyboard is up, sometimes we never commit a stable update and re-show the caret
https://bugs.webkit.org/show_bug.cgi?id=180498

Reviewed by Tim Horton.

Source/WebKit:

When the keyboard is showing, we would think that the page was in a rubber-banding state
because contentOffsetBoundedInValidRange() would always clamp the content offset to a different
value.

This happened because scrollView.contentInset don't change when the keyboard is showing,
but UIKit actually consults scrollView.adjustedContentInset, which does. If we use
scrollView.adjustedContentInset in this computation, we'll get a correct answer.

Also rewrote the clamping logic to be more similar to what UIKit does internally when computing
min/max content offset.

  • UIProcess/API/Cocoa/WKWebView.mm:

(contentOffsetBoundedInValidRange):

LayoutTests:

Test that completes once a stable update is received after showing the keyboard.

  • fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt: Added.
  • fast/visual-viewport/ios/stable-update-with-keyboard.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r225707 r225714  
     12017-12-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        When the iPhone keyboard is up, sometimes we never commit a stable update and re-show the caret
     4        https://bugs.webkit.org/show_bug.cgi?id=180498
     5
     6        Reviewed by Tim Horton.
     7
     8        Test that completes once a stable update is received after showing the keyboard.
     9
     10        * fast/visual-viewport/ios/stable-update-with-keyboard-expected.txt: Added.
     11        * fast/visual-viewport/ios/stable-update-with-keyboard.html: Added.
     12
    1132017-12-08  Daniel Bates  <dabates@apple.com>
    214
  • trunk/Source/WebKit/ChangeLog

    r225711 r225714  
     12017-12-06  Simon Fraser  <simon.fraser@apple.com>
     2
     3        When the iPhone keyboard is up, sometimes we never commit a stable update and re-show the caret
     4        https://bugs.webkit.org/show_bug.cgi?id=180498
     5
     6        Reviewed by Tim Horton.
     7
     8        When the keyboard is showing, we would think that the page was in a rubber-banding state
     9        because contentOffsetBoundedInValidRange() would always clamp the content offset to a different
     10        value.
     11
     12        This happened because scrollView.contentInset don't change when the keyboard is showing,
     13        but UIKit actually consults scrollView.adjustedContentInset, which does. If we use
     14        scrollView.adjustedContentInset in this computation, we'll get a correct answer.
     15
     16        Also rewrote the clamping logic to be more similar to what UIKit does internally when computing
     17        min/max content offset.
     18
     19        * UIProcess/API/Cocoa/WKWebView.mm:
     20        (contentOffsetBoundedInValidRange):
     21
    1222017-12-08  Chris Dumez  <cdumez@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r225615 r225714  
    16301630static CGPoint contentOffsetBoundedInValidRange(UIScrollView *scrollView, CGPoint contentOffset)
    16311631{
     1632#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     1633    UIEdgeInsets contentInsets = scrollView.adjustedContentInset;
     1634#else
    16321635    UIEdgeInsets contentInsets = scrollView.contentInset;
     1636#endif
     1637
    16331638    CGSize contentSize = scrollView.contentSize;
    16341639    CGSize scrollViewSize = scrollView.bounds.size;
    16351640
    1636     CGFloat maxHorizontalOffset = contentSize.width + contentInsets.right - scrollViewSize.width;
    1637     contentOffset.x = std::min(maxHorizontalOffset, contentOffset.x);
    1638     contentOffset.x = std::max(-contentInsets.left, contentOffset.x);
    1639 
    1640     CGFloat maxVerticalOffset = contentSize.height + contentInsets.bottom - scrollViewSize.height;
    1641     contentOffset.y = std::min(maxVerticalOffset, contentOffset.y);
    1642     contentOffset.y = std::max(-contentInsets.top, contentOffset.y);
    1643     return contentOffset;
     1641    CGPoint minimumContentOffset = CGPointMake(-contentInsets.left, -contentInsets.top);
     1642    CGPoint maximumContentOffset = CGPointMake(std::max(minimumContentOffset.x, contentSize.width + contentInsets.right - scrollViewSize.width), std::max(minimumContentOffset.y, contentSize.height + contentInsets.bottom - scrollViewSize.height));
     1643
     1644    return CGPointMake(std::max(std::min(contentOffset.x, maximumContentOffset.x), minimumContentOffset.x), std::max(std::min(contentOffset.y, maximumContentOffset.y), minimumContentOffset.y));
    16441645}
    16451646
Note: See TracChangeset for help on using the changeset viewer.