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

Changeset 245993 in webkit


Ignore:
Timestamp:
May 31, 2019, 4:13:39 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

[iOS] Reveal the focused element when it's immediately above software keyboard
https://bugs.webkit.org/show_bug.cgi?id=198412

Reviewed by Wenson Hsieh.

Source/WebKit:

When _zoomToRevealFocusedElement is called with forceScroll set to NO (happens when input type is none or drawing
or when the platform is iPad), we don't force scrolling to reveal the focused element when it's entirely visible.

This can be misleading in cases where there is more content right beneath it relevant for editing operations.
Zoom & scroll to reveal the focused element when the said element is within 50px of the software keyboard.

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

(-[WKWebView _zoomToFocusRect:selectionRect:insideFixed:fontSize:minimumScale:maximumScale:allowScaling:forceScroll:]):

LayoutTests:

Added a regression test. Note that this test always passes on non-iPad platforms either
before or after this patch as _zoomToRevealFocusedElement forces scrolling in that case.

  • fast/scrolling/ios/reveal-focused-element-right-above-keyboard-on-ipad-expected.txt: Added.
  • fast/scrolling/ios/reveal-focused-element-right-above-keyboard-on-ipad.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245991 r245993  
     12019-05-31  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        [iOS] Reveal the focused element when it's immediately above software keyboard
     4        https://bugs.webkit.org/show_bug.cgi?id=198412
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Added a regression test. Note that this test always passes on non-iPad platforms either
     9        before or after this patch as _zoomToRevealFocusedElement forces scrolling in that case.
     10
     11        * fast/scrolling/ios/reveal-focused-element-right-above-keyboard-on-ipad-expected.txt: Added.
     12        * fast/scrolling/ios/reveal-focused-element-right-above-keyboard-on-ipad.html: Added.
     13
    1142019-05-31  Nikita Vasilyev  <nvasilyev@apple.com>
    215
  • trunk/Source/WebKit/ChangeLog

    r245992 r245993  
     12019-05-31  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        [iOS] Reveal the focused element when it's immediately above software keyboard
     4        https://bugs.webkit.org/show_bug.cgi?id=198412
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        When _zoomToRevealFocusedElement is called with forceScroll set to NO (happens when input type is none or drawing
     9        or when the platform is iPad), we don't force scrolling to reveal the focused element when it's entirely visible.
     10
     11        This can be misleading in cases where there is more content right beneath it relevant for editing operations.
     12        Zoom & scroll to reveal the focused element when the said element is within 50px of the software keyboard.
     13
     14        * Platform/spi/ios/UIKitSPI.h:
     15        * UIProcess/API/Cocoa/WKWebView.mm:
     16        (-[WKWebView _zoomToFocusRect:selectionRect:insideFixed:fontSize:minimumScale:maximumScale:allowScaling:forceScroll:]):
     17
    1182019-05-31  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r245989 r245993  
    23282328
    23292329    CGFloat visibleOffsetFromTop = 0;
     2330    CGFloat minimumDistanceFromKeyboardToTriggerScroll = 0;
    23302331    if (!CGRectIsEmpty(intersectionBetweenScrollViewAndFormAssistant)) {
    23312332        CGFloat heightVisibleAboveFormAssistant = CGRectGetMinY(intersectionBetweenScrollViewAndFormAssistant) - CGRectGetMinY(visibleScrollViewBoundsInWebViewCoordinates);
    23322333        CGFloat heightVisibleBelowFormAssistant = CGRectGetMaxY(visibleScrollViewBoundsInWebViewCoordinates) - CGRectGetMaxY(intersectionBetweenScrollViewAndFormAssistant);
    23332334
    2334         if (heightVisibleAboveFormAssistant >= minimumHeightToShowContentAboveKeyboard || heightVisibleBelowFormAssistant < heightVisibleAboveFormAssistant)
     2335        if (heightVisibleAboveFormAssistant >= minimumHeightToShowContentAboveKeyboard || heightVisibleBelowFormAssistant < heightVisibleAboveFormAssistant) {
    23352336            visibleSize.height = heightVisibleAboveFormAssistant;
    2336         else {
     2337            minimumDistanceFromKeyboardToTriggerScroll = 50;
     2338        } else {
    23372339            visibleSize.height = heightVisibleBelowFormAssistant;
    23382340            visibleOffsetFromTop = CGRectGetMaxY(intersectionBetweenScrollViewAndFormAssistant) - CGRectGetMinY(visibleScrollViewBoundsInWebViewCoordinates);
     
    23732375        currentlyVisibleRegionInWebViewCoordinates.origin.y += visibleOffsetFromTop;
    23742376        currentlyVisibleRegionInWebViewCoordinates.size = visibleSize;
     2377        currentlyVisibleRegionInWebViewCoordinates.size.height -= minimumDistanceFromKeyboardToTriggerScroll;
    23752378
    23762379        // Don't bother scrolling if the entire node is already visible, whether or not we got a selectionRect.
Note: See TracChangeset for help on using the changeset viewer.