| 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 ade6398bbb375e7330f2b6b55340e0d7d0b206f2..e40bdd0b50bf6cf74f35ba0c33804d178a619683 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
|
| @@ -56,7 +56,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.
|
| @@ -543,7 +543,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));
|
| @@ -562,8 +562,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());
|
| @@ -572,8 +572,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;
|
| }
|
|
|
| @@ -588,21 +588,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());
|
| }
|
| @@ -618,11 +618,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;
|
| }
|
|
|
| @@ -760,10 +760,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,
|
|
|