[webkit-changes] [WebKit/WebKit] eb5517: [iOS 17] [OOP Keyboard] Scrolling to reveal the se...

Wenson Hsieh noreply at github.com
Tue Jun 27 10:52:11 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: eb551731bdda4d96b22724af1703ba169df61f0b
      https://github.com/WebKit/WebKit/commit/eb551731bdda4d96b22724af1703ba169df61f0b
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-06-27 (Tue, 27 Jun 2023)

  Changed paths:
    A LayoutTests/editing/selection/ios/scroll-to-reveal-selection-in-mail-compose-expected.txt
    A LayoutTests/editing/selection/ios/scroll-to-reveal-selection-in-mail-compose.html
    R LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled-expected.txt
    R LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled.html
    M LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll-expected.txt
    M LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll.html
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/WebKitTestRunner/TestOptions.cpp
    M Tools/WebKitTestRunner/TestOptions.h
    M Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h
    M Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm
    M Tools/WebKitTestRunner/ios/TestControllerIOS.mm

  Log Message:
  -----------
  [iOS 17] [OOP Keyboard] Scrolling to reveal the selection is broken in Mail compose
https://bugs.webkit.org/show_bug.cgi?id=258573
rdar://110139313

Reviewed by Aditya Keerthi and Abrar Rahman Protyasha.

We currently call `-[WKContentView reloadInputViews]` twice whenever we focus an editable element on
iOS. While this *should* be benign, it causes UIKit to dispatch redundant sets of `KeyboardWillShow`
and `KeyboardDidShow` notifications before the keyboard animation has even started, when out-of-
process keyboard is enabled.

Importantly, this redundant set of notifications causes us to not scroll to reveal the selection
when tapping into Mail compose to bring up the keyboard, since the keyboard height is still 0 (i.e.
the keyboard is not covering anything) when the earliest set of keyboard notifications arrives.

While the redundant notification dispatching likely still needs to be fixed in UIKit, it seems
wasteful to unnecessarily trigger `-reloadInputViews` in WebKit, so we can address the issue for now
by fixing this.

* LayoutTests/editing/selection/ios/scroll-to-reveal-selection-in-mail-compose-expected.txt: Added.
* LayoutTests/editing/selection/ios/scroll-to-reveal-selection-in-mail-compose.html: Added.

Augment an existing layout test that was originally intended to simulate Mail compose, such that it
more closely follows Mail compose with the software keyboard — i.e.:

- The web view is editable.
- First responder keyboard avoidance scrolling is disabled.
- The input accessory view is suppressed.

* LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled-expected.txt: Removed.
* LayoutTests/editing/selection/ios/scroll-to-reveal-selection-with-keyboard-avoidance-disabled.html: Removed.
* LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll-expected.txt:
* LayoutTests/editing/selection/ios/update-selection-after-iframe-scroll.html:

Drive-by-fix a flaky layout test, which fails if run after some other layout tests (discovered while
debugging nearby test failures), by (1) ensuring that the test begins after the `iframe` finishes
loading, and (2) the selection in editable content is always set properly, by setting it after
starting the input session — the initial tap sometimes causes the selection to collapse right after
the click handler selects a range.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showKeyboard]):

Also remove an unnecessary check for `PLATFORM(WATCHOS)`, now that this method is only invoked from
non-watchOS codepaths.

(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):

See comments above.

* Tools/WebKitTestRunner/TestOptions.cpp:
(WTR::TestOptions::defaults):
(WTR::TestOptions::keyTypeMapping):
* Tools/WebKitTestRunner/TestOptions.h:

Add a new test option to suppress the input accessory view when starting an input session; necessary
to satisfy the conditions required to trigger this bug.

(WTR::TestOptions::suppressInputAccessoryView const):
* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView _webView:willStartInputSession:]):
* Tools/WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformResetStateToConsistentValues):

Canonical link: https://commits.webkit.org/265556@main




More information about the webkit-changes mailing list