OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.graphics.Rect; | 9 import android.graphics.Rect; |
10 import android.os.Build; | 10 import android.os.Build; |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 case android.R.id.paste: | 613 case android.R.id.paste: |
614 mWebContents.paste(); | 614 mWebContents.paste(); |
615 return true; | 615 return true; |
616 default: | 616 default: |
617 return false; | 617 return false; |
618 } | 618 } |
619 } | 619 } |
620 | 620 |
621 boolean performEditorAction(int actionCode) { | 621 boolean performEditorAction(int actionCode) { |
622 if (!isValid()) return false; | 622 if (!isValid()) return false; |
623 if (actionCode == EditorInfo.IME_ACTION_NEXT) { | 623 switch (actionCode) { |
624 sendSyntheticKeyPress(KeyEvent.KEYCODE_TAB, | 624 case EditorInfo.IME_ACTION_NEXT: |
625 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE | 625 advanceFocusInForm(true); |
626 | KeyEvent.FLAG_EDITOR_ACTION); | 626 break; |
627 } else { | 627 case EditorInfo.IME_ACTION_PREVIOUS: |
628 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, | 628 advanceFocusInForm(false); |
629 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE | 629 break; |
630 | KeyEvent.FLAG_EDITOR_ACTION); | 630 default: |
| 631 sendSyntheticKeyPress(KeyEvent.KEYCODE_ENTER, |
| 632 KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_M
ODE |
| 633 | KeyEvent.FLAG_EDITOR_ACTION); |
| 634 break; |
631 } | 635 } |
632 return true; | 636 return true; |
633 } | 637 } |
634 | 638 |
| 639 /** |
| 640 * Advances the focus to next input field in the current form. |
| 641 * |
| 642 * @param forward indicates whether to advance forward or backward direction
. |
| 643 */ |
| 644 private void advanceFocusInForm(boolean forward) { |
| 645 if (mNativeImeAdapterAndroid == 0) return; |
| 646 nativeAdvanceFocusInForm(mNativeImeAdapterAndroid, forward); |
| 647 } |
| 648 |
635 void notifyUserAction() { | 649 void notifyUserAction() { |
636 mInputMethodManagerWrapper.notifyUserAction(); | 650 mInputMethodManagerWrapper.notifyUserAction(); |
637 } | 651 } |
638 | 652 |
639 @VisibleForTesting | 653 @VisibleForTesting |
640 protected void sendSyntheticKeyPress(int keyCode, int flags) { | 654 protected void sendSyntheticKeyPress(int keyCode, int flags) { |
641 long eventTime = SystemClock.uptimeMillis(); | 655 long eventTime = SystemClock.uptimeMillis(); |
642 sendKeyEvent(new KeyEvent(eventTime, eventTime, | 656 sendKeyEvent(new KeyEvent(eventTime, eventTime, |
643 KeyEvent.ACTION_DOWN, keyCode, 0, 0, | 657 KeyEvent.ACTION_DOWN, keyCode, 0, 0, |
644 KeyCharacterMap.VIRTUAL_KEYBOARD, 0, | 658 KeyCharacterMap.VIRTUAL_KEYBOARD, 0, |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA
ndroid, | 914 private native void nativeSetEditableSelectionOffsets(long nativeImeAdapterA
ndroid, |
901 int start, int end); | 915 int start, int end); |
902 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i
nt start, int end); | 916 private native void nativeSetComposingRegion(long nativeImeAdapterAndroid, i
nt start, int end); |
903 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid
, | 917 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid
, |
904 int before, int after); | 918 int before, int after); |
905 private native void nativeDeleteSurroundingTextInCodePoints( | 919 private native void nativeDeleteSurroundingTextInCodePoints( |
906 long nativeImeAdapterAndroid, int before, int after); | 920 long nativeImeAdapterAndroid, int before, int after); |
907 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt
erAndroid); | 921 private native boolean nativeRequestTextInputStateUpdate(long nativeImeAdapt
erAndroid); |
908 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, | 922 private native void nativeRequestCursorUpdate(long nativeImeAdapterAndroid, |
909 boolean immediateRequest, boolean monitorRequest); | 923 boolean immediateRequest, boolean monitorRequest); |
| 924 private native void nativeAdvanceFocusInForm(long nativeImeAdapterAndroid, b
oolean forward); |
910 } | 925 } |
OLD | NEW |