Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS 15] Unable to type in Google Docs with a hardware keyboard witho…
…ut refocusing editor https://bugs.webkit.org/show_bug.cgi?id=241308 rdar://90755619 Reviewed by Tim Horton. After the changes in r277265, we no longer call into `-reloadInputViews` when starting an input session after programmatically focusing an editable container with `inputmode="none"`, with a hardware keyboard attached. This is because `-_shouldShowKeyboardForElement:` returns `NO` (due to inputmode none), so we bail early at this check: ``` if (!shouldShowInputView || information.elementType == WebKit::InputType::None) { _page->setIsShowingInputViewForFocusedElement(false); return; } ``` As a result, UIKit never resets UIKeyboardImpl's input delegate, which should now be the `WKContentView`, and thus never consults whether we require key events (`-requiresKeyEvents`), which in turn means that `-handleKeyWebEvent:withCompletionHandler:` is never invoked on the content view, so we never dispatch key events to the page. In the normal, non-editable key event case, we lazily call `-reloadInputViews` in `-_handleKeyUIEvent:` (which is called just before keyboard WebEvents start getting dispatched by UIKit). However, since we're still focusing an editable element in this case, we don't end up going down this codepath. When the hardware keyboard is not connected, avoiding the call to `-reloadInputViews` is expected, since we aren't showing a keyboard anyways due to the fact that the element was programmatically focused (so the user has no way of typing or dispatching key events, in the first place). And finally, when the `inputmode` is not none, `_isFocusingElementWithKeyboard` is set to `YES`, so we begin the input session and call `-reloadInputViews` as normal. It's only in this `inputmode=none` case with both the hardware keyboard attached and the editable container being programmatically focused, where we end up in a state where the user can type with a hardware keyboard, but we haven't informed UIKit that we should receive key events. We can fix this by consulting a separate `-_shouldShowKeyboardForElementIgnoringInputMode:` instead which allows us to follow the normal routine for focusing an editable element with `inputmode="none"` which includes zooming to reveal the focused element if it's on-screen and not hidden, as well as calling the related delegate methods; the only difference is that we avoid showing the UCB or software keyboard, by returning `YES` from `-_disableAutomaticKeyboardUI` in this case. * LayoutTests/fast/forms/ios/keydown-in-hidden-contenteditable-with-inputmode-none-expected.txt: Added. * LayoutTests/fast/forms/ios/keydown-in-hidden-contenteditable-with-inputmode-none.html: Added. Add a new layout test to simulate typing in Google Docs with a hardware keyboard (i.e., focus a hidden contenteditable container with `inputmode="none"`), and verify that we dispatch key events to the focused editable element. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _elementTypeRequiresAccessoryView:]): (-[WKContentView _shouldShowKeyboardForElement:]): (-[WKContentView _shouldShowKeyboardForElementIgnoringInputMode:]): Split this helper method into two versions (one of which ignores `inputmode=none`). See above for more details. (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): Canonical link: https://commits.webkit.org/251335@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information