Deal with backspace keycodes getting sent by IME during compositions.
As of KitKat, the standard Google IME always calls deleteSurroundingText(1, 0) when the soft backspace button is pressed. But Jellybean and below instead mixed in a backspace key event into the IME stream, and the current Samsung keyboard still has this behavior. If we only forward such key events to Blink during an ongoing composition, then Blink will delete its string but the BaseInputConnection won't update its state, leading to a desync and strange bugs later. Our sendKeyEvent method already had a workaround to call deleteSurroundingText directly in such cases. sendKeyEvent is called when Samsung keyboard is used with Chrome, but WebView instead goes through the alternate Chrome.dispatchKeyEvent path. For that reason we currently have a Samsung+WebView specific desync bug. This patch changes dispatchKeyEvent to call sendKeyEvent, like https://codereview.chromium.org/759033002 did before it was reverted, to extend the workaround to WebView. This would have the unfortunate side effect of causing a bug with backspace key-repeats on physical keyboards, as the code there only applies backspace on keyup. So this patch changes it to keydown (which is better UX even aside from key repeat) and also forwards the system-supplied key events directly instead of throwing them out and generating artificial ones. BUG=483514 Review URL: https://codereview.chromium.org/1137673005 Cr-Commit-Position: refs/heads/master@{#329954}
Showing
Please register or sign in to comment