DO NOT MERGE. CHERRY-PICKED GERRIT CHANGE 60365.
Support complex characters in plugins. Complex characters like chinese are sent via the onKeyMultiple() callback. The WebView passes these characters to Webkit so that non-text inputs (e.g. plugins) can process them. Change-Id: I49575bb8a583f9f3580f5734ad87cc7c00b2bda9 http://b/2900114
This commit is contained in:
@@ -3911,6 +3911,19 @@ public class WebView extends AbsoluteLayout
|
||||
// affect long press with the trackball/touch.
|
||||
private boolean mGotCenterDown = false;
|
||||
|
||||
@Override
|
||||
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
|
||||
// send complex characters to webkit for use by JS and plugins
|
||||
if (keyCode == KeyEvent.KEYCODE_UNKNOWN && event.getCharacters() != null) {
|
||||
// pass the key to DOM
|
||||
mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
|
||||
mWebViewCore.sendMessage(EventHub.KEY_UP, event);
|
||||
// return true as DOM handles the key
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (DebugFlags.WEB_VIEW) {
|
||||
|
||||
@@ -1568,9 +1568,16 @@ final class WebViewCore {
|
||||
+ evt);
|
||||
}
|
||||
int keyCode = evt.getKeyCode();
|
||||
if (!nativeKey(keyCode, evt.getUnicodeChar(),
|
||||
evt.getRepeatCount(), evt.isShiftPressed(), evt.isAltPressed(),
|
||||
evt.isSymPressed(),
|
||||
int unicodeChar = evt.getUnicodeChar();
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_UNKNOWN && evt.getCharacters() != null
|
||||
&& evt.getCharacters().length() > 0) {
|
||||
// we should only receive individual complex characters
|
||||
unicodeChar = evt.getCharacters().codePointAt(0);
|
||||
}
|
||||
|
||||
if (!nativeKey(keyCode, unicodeChar, evt.getRepeatCount(), evt.isShiftPressed(),
|
||||
evt.isAltPressed(), evt.isSymPressed(),
|
||||
isDown) && keyCode != KeyEvent.KEYCODE_ENTER) {
|
||||
if (keyCode >= KeyEvent.KEYCODE_DPAD_UP
|
||||
&& keyCode <= KeyEvent.KEYCODE_DPAD_RIGHT) {
|
||||
|
||||
Reference in New Issue
Block a user