-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UIAsyncTextInput] Keyboard sometimes autocapitalizes incorrectly while typing an inline completion #21244
Merged
Conversation
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
EWS run on current version of this PR (hash 46f5cf0) |
rr-codes
approved these changes
Dec 4, 2023
Thanks for the review! |
…le typing an inline completion https://bugs.webkit.org/show_bug.cgi?id=265764 rdar://119084774 Reviewed by Richard Robinson. After adopting `-invalidateTextEntryContext` in place of `-[UIKeyboardImpl layoutHasChanged]` when the async text input codepath is enabled, the keyboard sometimes unexpectedly autocapitalizes when typing while showing inline predictions in Mail compose. This is because the replacement API (`-invalidateTextEntryContext`) now additionally updates text context in addition to updating the layout and positioning of input method UI (i.e. when using Chinese or Japanese input). This is meant to only be done only once, when initially starting IME composition, in order to give certain web apps (e.g. Google Docs) a chance to reposition any offscreen, hidden editable containers such that the input method UI and candidates bar shows up in the right place — to achieve this, we set a `_candidateViewNeedsUpdate` flag upon setting any marked text where the marked text range is previously empty, and clear out the flag after the next selection change. In iOS 17+, inline predictions also exercise this same marked text codepath; however, instead of maintaining a persistent marked text string, inline predictions continuously clear out and reinsert marked text as the prediction is regenerated while typing, which causes the `_candidateViewNeedsUpdate` flag to be continuously set (and therefore, causes us to continuously invoke `-invalidateTextEntryContext` while typing). The combination of the above causes the keyboard to occasionally lose context while typing, which results in the keyboard becoming erroneously autoshifted after typing a space. To fix this, we make this logic more nuanced, such that we only `-invalidateTextEntryContext` if there's an active IME session (excluding marked text, set by inline predictions). Test: editing/input/ios/typing-with-inline-predictions.html * LayoutTests/editing/input/ios/typing-with-inline-predictions-expected.txt: Added. * LayoutTests/editing/input/ios/typing-with-inline-predictions.html: Added. Add a layout test to exercise the change. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.h: Introduce a new flag, `_isDeferringKeyEventsToInputMethod`, to track whether or not we have an active IME session. * Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView cleanUpInteraction]): (-[WKContentView canPerformActionForWebView:withSender:]): Drive-by fix: replace some internal calls to `-hasContent` with an internal version instead, `-_hasContent`, to avoid self-induced release assertions after 271417@main. (-[WKContentView _setMarkedText:underlines:highlights:selectedRange:]): (-[WKContentView unmarkText]): Unset the new flag when committing marked text. (-[WKContentView _internalHandleKeyWebEvent:withCompletionHandler:]): Set the new flag, `_isDeferringKeyEventsToInputMethod`, if we've actually deferred key event handling to system IME. (-[WKContentView hasContent]): (-[WKContentView _hasContent]): See drive-by fix above. Canonical link: https://commits.webkit.org/271482@main
46f5cf0
to
01a600b
Compare
Committed 271482@main (01a600b): https://commits.webkit.org/271482@main Reviewed commits have been landed. Closing PR #21244 and removing active labels. |
megangardner
reviewed
Dec 4, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r+
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
01a600b
46f5cf0
🧪 wpe-wk2