DescriptionSupport parsing BackgroundSpans and UnderlineSpans in Android IME's commitText()
Android InputConnection has two related methods
- setComposingText() replaces the current compose region with a given piece of
text and sets a composing span around the new text
- commitText() replaces the text the same way but then closes out the compose
region instead of putting it around the new text.
Support was added for parsing BackgroundSpan and UnderlineSpan annotations in
setComposingText() to support the Google Japanese Input IME (newly entered text
in the compose region is underlined and highlighted in a blue background).
The Android Voice IME instead uses commitText() because it wants the highlighted
regions to persist after the compose region is closed out. Closing out the
compose region after calling setComposingText() would clear the highlight
regions. So to support this, we need to parse the spans for commitText() in
ImeAdapterAndroid just as we do for setComposingText(), and also thread this
information all the way back to InputMethodController as we do for
setComposingText().
I tested this by forwarding calls of setComposingText() to commitText() and
verifying that highlighting works for the Google Japanese IME. It's highlighting
the character immediately ahead of the insertion point instead of the newly
typed character when I do this; I suspect this may be because the IME is
expecting something about the setComposingText() behavior (e.g. the compose
range) that's different in commitText(), but it's also possible I have a bug in
the new logic.
Once I write some code to start parsing out SuggestionSpans from the Voice IME,
I'll be able to test this better (I might be able to get this done tomorrow).
BUG=673491
Review-Url: https://codereview.chromium.org/2568093003
Cr-Commit-Position: refs/heads/master@{#442738}
Committed: https://chromium.googlesource.com/chromium/src/+/7efe230106176ba759388532a0993f0f0bef67d8
Patch Set 1 #Patch Set 2 : Fix some stuff breaking Linux builds #
Total comments: 1
Patch Set 3 : Don't try to add default underline for commitText(), attempt to fix Mac builds #
Total comments: 1
Patch Set 4 : Fix commitText() logic (I think) #
Total comments: 4
Patch Set 5 : Use rootEditableElement(), add test case #Patch Set 6 : fix test case #Patch Set 7 : Attempt to fix dependency error with target #
Total comments: 2
Patch Set 8 : Fix header include #
Total comments: 1
Patch Set 9 : Fix bug I introduced trying to use rootEditableElement for all underline code #Patch Set 10 : Remove a logging statement accidentally left in #Patch Set 11 : Rebase #
Total comments: 7
Patch Set 12 : Use addCompositionUnderlines() where I said I couldn't #Messages
Total messages: 82 (54 generated)
|