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.os.Handler; | 7 import android.os.Handler; |
8 import android.os.ResultReceiver; | 8 import android.os.ResultReceiver; |
9 import android.os.SystemClock; | 9 import android.os.SystemClock; |
10 import android.text.Editable; | 10 import android.text.Editable; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 static KeyCharacterMap sKeyCharacterMap; | 120 static KeyCharacterMap sKeyCharacterMap; |
121 | 121 |
122 private long mNativeImeAdapterAndroid; | 122 private long mNativeImeAdapterAndroid; |
123 private InputMethodManagerWrapper mInputMethodManagerWrapper; | 123 private InputMethodManagerWrapper mInputMethodManagerWrapper; |
124 private AdapterInputConnection mInputConnection; | 124 private AdapterInputConnection mInputConnection; |
125 private final ImeAdapterDelegate mViewEmbedder; | 125 private final ImeAdapterDelegate mViewEmbedder; |
126 private final Handler mHandler; | 126 private final Handler mHandler; |
127 private DelayedDismissInput mDismissInput = null; | 127 private DelayedDismissInput mDismissInput = null; |
128 private int mTextInputType; | 128 private int mTextInputType; |
129 private String mLastComposeText; | 129 private String mLastComposeText; |
| 130 private int mInputElementMaxLength; |
130 | 131 |
131 @VisibleForTesting | 132 @VisibleForTesting |
132 int mLastSyntheticKeyCode; | 133 int mLastSyntheticKeyCode; |
133 | 134 |
134 @VisibleForTesting | 135 @VisibleForTesting |
135 boolean mIsShowWithoutHideOutstanding = false; | 136 boolean mIsShowWithoutHideOutstanding = false; |
136 | 137 |
137 /** | 138 /** |
138 * @param wrapper InputMethodManagerWrapper that should receive all the call
directed to | 139 * @param wrapper InputMethodManagerWrapper that should receive all the call
directed to |
139 * InputMethodManager. | 140 * InputMethodManager. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 /** | 556 /** |
556 * Send a request to the native counterpart of ImeAdapter to paste the text
from the clipboard. | 557 * Send a request to the native counterpart of ImeAdapter to paste the text
from the clipboard. |
557 * @return Whether the native counterpart of ImeAdapter received the call. | 558 * @return Whether the native counterpart of ImeAdapter received the call. |
558 */ | 559 */ |
559 public boolean paste() { | 560 public boolean paste() { |
560 if (mNativeImeAdapterAndroid == 0) return false; | 561 if (mNativeImeAdapterAndroid == 0) return false; |
561 nativePaste(mNativeImeAdapterAndroid); | 562 nativePaste(mNativeImeAdapterAndroid); |
562 return true; | 563 return true; |
563 } | 564 } |
564 | 565 |
| 566 public int getInputElementMaxLength() { |
| 567 return mInputElementMaxLength; |
| 568 } |
565 // Calls from C++ to Java | 569 // Calls from C++ to Java |
566 | 570 |
567 @CalledByNative | 571 @CalledByNative |
568 private static void initializeWebInputEvents(int eventTypeRawKeyDown, int ev
entTypeKeyUp, | 572 private static void initializeWebInputEvents(int eventTypeRawKeyDown, int ev
entTypeKeyUp, |
569 int eventTypeChar, int modifierShift, int modifierAlt, int modifierC
trl, | 573 int eventTypeChar, int modifierShift, int modifierAlt, int modifierC
trl, |
570 int modifierCapsLockOn, int modifierNumLockOn) { | 574 int modifierCapsLockOn, int modifierNumLockOn) { |
571 sEventTypeRawKeyDown = eventTypeRawKeyDown; | 575 sEventTypeRawKeyDown = eventTypeRawKeyDown; |
572 sEventTypeKeyUp = eventTypeKeyUp; | 576 sEventTypeKeyUp = eventTypeKeyUp; |
573 sEventTypeChar = eventTypeChar; | 577 sEventTypeChar = eventTypeChar; |
574 sModifierShift = modifierShift; | 578 sModifierShift = modifierShift; |
(...skipping 14 matching lines...) Expand all Loading... |
589 sTextInputTypePassword = textInputTypePassword; | 593 sTextInputTypePassword = textInputTypePassword; |
590 sTextInputTypeSearch = textInputTypeSearch; | 594 sTextInputTypeSearch = textInputTypeSearch; |
591 sTextInputTypeUrl = textInputTypeUrl; | 595 sTextInputTypeUrl = textInputTypeUrl; |
592 sTextInputTypeEmail = textInputTypeEmail; | 596 sTextInputTypeEmail = textInputTypeEmail; |
593 sTextInputTypeTel = textInputTypeTel; | 597 sTextInputTypeTel = textInputTypeTel; |
594 sTextInputTypeNumber = textInputTypeNumber; | 598 sTextInputTypeNumber = textInputTypeNumber; |
595 sTextInputTypeContentEditable = textInputTypeContentEditable; | 599 sTextInputTypeContentEditable = textInputTypeContentEditable; |
596 } | 600 } |
597 | 601 |
598 @CalledByNative | 602 @CalledByNative |
599 private void focusedNodeChanged(boolean isEditable) { | 603 private void focusedNodeChanged(boolean isEditable, int editableNodeMaxLengt
h) { |
| 604 mInputElementMaxLength = editableNodeMaxLength; |
600 if (mInputConnection != null && isEditable) mInputConnection.restartInpu
t(); | 605 if (mInputConnection != null && isEditable) mInputConnection.restartInpu
t(); |
601 } | 606 } |
602 | 607 |
603 @CalledByNative | 608 @CalledByNative |
604 private void populateUnderlinesFromSpans(CharSequence text, long underlines)
{ | 609 private void populateUnderlinesFromSpans(CharSequence text, long underlines)
{ |
605 if (!(text instanceof SpannableString)) return; | 610 if (!(text instanceof SpannableString)) return; |
606 | 611 |
607 SpannableString spannableString = ((SpannableString) text); | 612 SpannableString spannableString = ((SpannableString) text); |
608 CharacterStyle spans[] = | 613 CharacterStyle spans[] = |
609 spannableString.getSpans(0, text.length(), CharacterStyle.class)
; | 614 spannableString.getSpans(0, text.length(), CharacterStyle.class)
; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid
, | 666 private native void nativeDeleteSurroundingText(long nativeImeAdapterAndroid
, |
662 int before, int after); | 667 int before, int after); |
663 | 668 |
664 private native void nativeUnselect(long nativeImeAdapterAndroid); | 669 private native void nativeUnselect(long nativeImeAdapterAndroid); |
665 private native void nativeSelectAll(long nativeImeAdapterAndroid); | 670 private native void nativeSelectAll(long nativeImeAdapterAndroid); |
666 private native void nativeCut(long nativeImeAdapterAndroid); | 671 private native void nativeCut(long nativeImeAdapterAndroid); |
667 private native void nativeCopy(long nativeImeAdapterAndroid); | 672 private native void nativeCopy(long nativeImeAdapterAndroid); |
668 private native void nativePaste(long nativeImeAdapterAndroid); | 673 private native void nativePaste(long nativeImeAdapterAndroid); |
669 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); | 674 private native void nativeResetImeAdapter(long nativeImeAdapterAndroid); |
670 } | 675 } |
OLD | NEW |