| Index: content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
|
| index 8c1ae7a6652c3371c7a374969838f42c4d5f1805..53ea7530c081d133f23457418bbab05e59a4cda3 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/input/ImeAdapter.java
|
| @@ -55,7 +55,7 @@ public class ImeAdapter {
|
| private static final String TAG = "cr_Ime";
|
| private static final boolean DEBUG_LOGS = false;
|
|
|
| - private static final int COMPOSITION_KEY_CODE = 229;
|
| + public static final int COMPOSITION_KEY_CODE = 229;
|
|
|
| /**
|
| * Interface for the delegate that needs to be notified of IME changes.
|
| @@ -535,7 +535,7 @@ public class ImeAdapter {
|
| KeyEvent.ACTION_DOWN, keyCode, 0, 0,
|
| KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
|
| flags));
|
| - sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime,
|
| + sendKeyEvent(new KeyEvent(eventTime, eventTime,
|
| KeyEvent.ACTION_UP, keyCode, 0, 0,
|
| KeyCharacterMap.VIRTUAL_KEYBOARD, 0,
|
| flags));
|
| @@ -554,8 +554,8 @@ public class ImeAdapter {
|
|
|
| mViewEmbedder.onImeEvent();
|
| long timestampMs = SystemClock.uptimeMillis();
|
| - nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, WebInputEventType.RawKeyDown,
|
| - timestampMs, COMPOSITION_KEY_CODE, 0, unicodeFromKeyEvent);
|
| + nativeSendKeyEvent(mNativeImeAdapterAndroid, null, WebInputEventType.RawKeyDown, 0,
|
| + timestampMs, COMPOSITION_KEY_CODE, 0, false, unicodeFromKeyEvent);
|
|
|
| if (isCommit) {
|
| nativeCommitText(mNativeImeAdapterAndroid, text.toString());
|
| @@ -564,8 +564,8 @@ public class ImeAdapter {
|
| mNativeImeAdapterAndroid, text, text.toString(), newCursorPosition);
|
| }
|
|
|
| - nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, WebInputEventType.KeyUp, timestampMs,
|
| - COMPOSITION_KEY_CODE, 0, unicodeFromKeyEvent);
|
| + nativeSendKeyEvent(mNativeImeAdapterAndroid, null, WebInputEventType.KeyUp, 0, timestampMs,
|
| + COMPOSITION_KEY_CODE, 0, false, unicodeFromKeyEvent);
|
| return true;
|
| }
|
|
|
| @@ -580,21 +580,21 @@ public class ImeAdapter {
|
| if (mNativeImeAdapterAndroid == 0) return false;
|
|
|
| int action = event.getAction();
|
| - if (action != KeyEvent.ACTION_DOWN && action != KeyEvent.ACTION_UP) {
|
| - // action == KeyEvent.ACTION_MULTIPLE
|
| - // TODO(bulach): confirm the actual behavior. Apparently:
|
| - // If event.getKeyCode() == KEYCODE_UNKNOWN, we can send a
|
| - // composition key down (229) followed by a commit text with the
|
| - // string from event.getUnicodeChars().
|
| - // Otherwise, we'd need to send an event with a
|
| - // WebInputEvent::IsAutoRepeat modifier. We also need to verify when
|
| - // we receive ACTION_MULTIPLE: we may receive it after an ACTION_DOWN,
|
| - // and if that's the case, we'll need to review when to send the Char
|
| - // event.
|
| + int type;
|
| + if (action == KeyEvent.ACTION_DOWN) {
|
| + type = WebInputEventType.KeyDown;
|
| + } else if (action == KeyEvent.ACTION_UP) {
|
| + type = WebInputEventType.KeyUp;
|
| + } else {
|
| + // In theory, KeyEvent.ACTION_MULTIPLE is a valid value, but in practice
|
| + // this seems to have been quietly deprecated and we've never observed
|
| + // a case where it's sent (holding down physical keyboard key also
|
| + // sends ACTION_DOWN), so it's fine to silently drop it.
|
| return false;
|
| }
|
| mViewEmbedder.onImeEvent();
|
| - return nativeSendKeyEvent(mNativeImeAdapterAndroid, event, event.getAction(),
|
| +
|
| + return nativeSendKeyEvent(mNativeImeAdapterAndroid, event, type,
|
| getModifiers(event.getMetaState()), event.getEventTime(), event.getKeyCode(),
|
| event.getScanCode(), /*isSystemKey=*/false, event.getUnicodeChar());
|
| }
|
| @@ -610,11 +610,11 @@ public class ImeAdapter {
|
| boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
| mViewEmbedder.onImeEvent();
|
| if (mNativeImeAdapterAndroid == 0) return false;
|
| - nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid, WebInputEventType.RawKeyDown,
|
| - SystemClock.uptimeMillis(), COMPOSITION_KEY_CODE, 0, 0);
|
| + nativeSendKeyEvent(mNativeImeAdapterAndroid, null, WebInputEventType.RawKeyDown, 0,
|
| + SystemClock.uptimeMillis(), COMPOSITION_KEY_CODE, 0, false, 0);
|
| nativeDeleteSurroundingText(mNativeImeAdapterAndroid, beforeLength, afterLength);
|
| - nativeSendSyntheticKeyEvent(mNativeImeAdapterAndroid,
|
| - WebInputEventType.KeyUp, SystemClock.uptimeMillis(), COMPOSITION_KEY_CODE, 0, 0);
|
| + nativeSendKeyEvent(mNativeImeAdapterAndroid, null, WebInputEventType.KeyUp, 0,
|
| + SystemClock.uptimeMillis(), COMPOSITION_KEY_CODE, 0, false, 0);
|
| return true;
|
| }
|
|
|
| @@ -743,10 +743,8 @@ public class ImeAdapter {
|
| }
|
| }
|
|
|
| - private native boolean nativeSendSyntheticKeyEvent(long nativeImeAdapterAndroid,
|
| - int eventType, long timestampMs, int keyCode, int modifiers, int unicodeChar);
|
| private native boolean nativeSendKeyEvent(long nativeImeAdapterAndroid, KeyEvent event,
|
| - int action, int modifiers, long timestampMs, int keyCode, int scanCode,
|
| + int type, int modifiers, long timestampMs, int keyCode, int scanCode,
|
| boolean isSystemKey, int unicodeChar);
|
| private static native void nativeAppendUnderlineSpan(long underlinePtr, int start, int end);
|
| private static native void nativeAppendBackgroundColorSpan(long underlinePtr, int start,
|
|
|