[webkit-changes] [WebKit/WebKit] 6669d1: [iOS 17] Software keyboard overlaps position: fixe...

Wenson Hsieh noreply at github.com
Mon Jul 3 17:42:31 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6669d12b7b43d2d36a549d9fcad0a1577b66a1f4
      https://github.com/WebKit/WebKit/commit/6669d12b7b43d2d36a549d9fcad0a1577b66a1f4
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-07-03 (Mon, 03 Jul 2023)

  Changed paths:
    A LayoutTests/fast/forms/ios/scroll-to-reveal-fixed-input-expected.txt
    A LayoutTests/fast/forms/ios/scroll-to-reveal-fixed-input.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  [iOS 17] Software keyboard overlaps position: fixed; text fields near the bottom of the viewport
https://bugs.webkit.org/show_bug.cgi?id=258828
rdar://109127515

Reviewed by Aditya Keerthi.

On iOS 17, in the case where out-of-process keyboard is enabled and the software keyboard is shown,
we end up getting two sets of `"KeyboardWillShow"` -> `"KeyboardDidShow"` notifications when the
keyboard animates up, after reloading input views. When the first set of notifications is dispatched
underneath the  call to `-reloadInputViews`, the keyboard hasn't yet become full height, and so our
attempts to zoom to reveal the focused element using the current input view bounds will fail.

I filed <rdar://111704216> for UIKit to investigate restoring pre-iOS-17 behavior, with respect to
dispatching these intermediate keyboard notifications; in the meantime, this patch works around this
behavior change by deferring the call to `-_zoomToRevealFocusedElement` until the first
`"KeyboardWillShow"` notification arrives *after* `-reloadInputViews` has already been invoked, in
the case where OOP keyboard is enabled and the keyboard is full height.

We limit this to the case of OOP keyboard because when that feature is disabled, we receive a
"KeyboardWillShow" notification underneath the call to `-reloadInputViews` that already contains the
final keyboard height; furthermore, we limit this to the case where the keyboard is full height,
because when OOP keyboard is enabled and the keyboard is minimized (e.g. the hardware keyboard is
attached), we only get a single set of keyboard appearance notifications.

* LayoutTests/fast/forms/ios/scroll-to-reveal-fixed-input-expected.txt: Added.
* LayoutTests/fast/forms/ios/scroll-to-reveal-fixed-input.html: Added.

Add a new layout test to exercise keyboard scrolling, in the case where:

1. We're showing the software keyboard.
2. The focused element that would be overlapped by the keyboard is in a fixed position container.
3. The page itself is scrollable.

...and verify that we successfully scroll such that the bottom of the caret rect is above the top of
the keyboard (input view bounds).

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.getUICaretViewRectInGlobalCoordinates.return.new.Promise.):
(window.UIHelper.getUICaretViewRectInGlobalCoordinates.return.new.Promise):
(window.UIHelper.getUICaretViewRectInGlobalCoordinates):

Add support for a new `UIHelper` method to grab the selection caret rect in web view coordinates.
The "global" here is consistent terminology used elsewhere in `UIScriptController`.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):

See comments above for more details.

* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::selectionCaretViewRectInGlobalCoordinates const):
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::selectionCaretViewRect const):
(WTR::UIScriptControllerIOS::selectionCaretViewRectInGlobalCoordinates const):

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




More information about the webkit-changes mailing list