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 d7f70154e5fef20d7d0675f27394d7e41102cd08..d0014580bc8fb9641e9e4a23bee7e31ca6c23301 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 |
@@ -30,6 +30,7 @@ import org.chromium.base.TraceEvent; |
import org.chromium.base.VisibleForTesting; |
import org.chromium.base.annotations.CalledByNative; |
import org.chromium.base.annotations.JNINamespace; |
+import org.chromium.blink_public.web.WebFocusType; |
import org.chromium.blink_public.web.WebInputEventModifier; |
import org.chromium.blink_public.web.WebInputEventType; |
import org.chromium.blink_public.web.WebTextInputMode; |
@@ -620,18 +621,32 @@ public class ImeAdapter { |
boolean performEditorAction(int actionCode) { |
if (!isValid()) return false; |
- if (actionCode == EditorInfo.IME_ACTION_NEXT) { |
- sendSyntheticKeyPress(KeyEvent.KEYCODE_TAB, |
- KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE |
- | KeyEvent.FLAG_EDITOR_ACTION); |
- } else { |
- sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, |
- KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE |
- | KeyEvent.FLAG_EDITOR_ACTION); |
+ switch (actionCode) { |
+ case EditorInfo.IME_ACTION_NEXT: |
+ advanceFocusInForm(WebFocusType.FORWARD); |
+ break; |
+ case EditorInfo.IME_ACTION_PREVIOUS: |
+ advanceFocusInForm(WebFocusType.BACKWARD); |
+ break; |
+ default: |
+ sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, |
+ KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE |
+ | KeyEvent.FLAG_EDITOR_ACTION); |
+ break; |
} |
return true; |
} |
+ /** |
+ * Advances the focus to next input field in the current form. |
+ * |
+ * @param focusType indicates whether to advance forward or backward direction. |
+ */ |
+ private void advanceFocusInForm(int focusType) { |
+ if (mNativeImeAdapterAndroid == 0) return; |
+ nativeAdvanceFocusInForm(mNativeImeAdapterAndroid, focusType); |
+ } |
+ |
void notifyUserAction() { |
mInputMethodManagerWrapper.notifyUserAction(); |
} |
@@ -907,4 +922,5 @@ public class ImeAdapter { |
private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapterAndroid); |
private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, |
boolean immediateRequest, boolean monitorRequest); |
+ private native void nativeAdvanceFocusInForm(long nativeImeAdapterAndroid, int focusType); |
} |