Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 01a600b1bfc9dba31c408eadc2900e28e1a63389
https://github.com/WebKit/WebKit/commit/01a600b1bfc9dba31c408eadc2900e28e1a63389
Author: Wenson Hsieh <[email protected]>
Date: 2023-12-04 (Mon, 04 Dec 2023)
Changed paths:
A LayoutTests/editing/input/ios/typing-with-inline-predictions-expected.txt
A LayoutTests/editing/input/ios/typing-with-inline-predictions.html
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Log Message:
-----------
[UIAsyncTextInput] Keyboard sometimes autocapitalizes incorrectly while
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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes