-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
8 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
LayoutTests/fast/forms/ios/scroll-to-reveal-fixed-input-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
This test verifies that we properly reveal focused elements in fixed position containers which would otherwise be obscured by the software keyboard. To reproduce, tap on the input field below. The software keyboard should not obscure the selection caret. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
PASS inputViewBounds.top is >= caretRect.top + caretRect.height | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
80 changes: 80 additions & 0 deletions
80
LayoutTests/fast/forms/ios/scroll-to-reveal-fixed-input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] --> | ||
<html> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<head> | ||
<script src="../../../resources/js-test.js"></script> | ||
<script src="../../../resources/ui-helper.js"></script> | ||
<style> | ||
html, body { | ||
width: 100%; | ||
height: 100%; | ||
color: lightgray; | ||
font-size: 20px; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
text-align: center; | ||
font-family: system-ui; | ||
background-color: #222; | ||
overflow: scroll; | ||
} | ||
|
||
.tall { | ||
width: 100%; | ||
height: 200vh; | ||
} | ||
|
||
.container { | ||
position: fixed; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
input { | ||
border: none; | ||
border-radius: 4px; | ||
outline: none; | ||
font-size: 20px; | ||
background-color: lightgray; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
padding: 8px; | ||
} | ||
</style> | ||
<script> | ||
jsTestIsAsync = true; | ||
|
||
addEventListener("load", async () => { | ||
description(`This test verifies that we properly reveal focused elements in fixed position | ||
containers which would otherwise be obscured by the software keyboard. To reproduce, tap on | ||
the input field below. The software keyboard should not obscure the selection caret.`); | ||
|
||
await UIHelper.setHardwareKeyboardAttached(false); | ||
|
||
const textField = document.querySelector("input"); | ||
await UIHelper.activateElementAndWaitForInputSession(textField); | ||
|
||
caretRect = await UIHelper.getUICaretViewRectInGlobalCoordinates(); | ||
inputViewBounds = await UIHelper.inputViewBounds(); | ||
|
||
shouldBeGreaterThanOrEqual("inputViewBounds.top", "caretRect.top + caretRect.height"); | ||
|
||
textField.blur(); | ||
await UIHelper.waitForKeyboardToHide(); | ||
finishJSTest(); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<input autofocus placeholder="Tap here"></input> | ||
</div> | ||
<div class="tall"></div> | ||
<div id="description"></div> | ||
<div id="console"></div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters