OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.SystemClock; | 7 import android.os.SystemClock; |
8 import android.text.Editable; | 8 import android.text.Editable; |
9 import android.text.InputType; | 9 import android.text.InputType; |
10 import android.text.Selection; | 10 import android.text.Selection; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 mLastUpdateCompositionStart = compositionStart; | 206 mLastUpdateCompositionStart = compositionStart; |
207 mLastUpdateCompositionEnd = compositionEnd; | 207 mLastUpdateCompositionEnd = compositionEnd; |
208 } | 208 } |
209 | 209 |
210 /** | 210 /** |
211 * @see BaseInputConnection#setComposingText(java.lang.CharSequence, int) | 211 * @see BaseInputConnection#setComposingText(java.lang.CharSequence, int) |
212 */ | 212 */ |
213 @Override | 213 @Override |
214 public boolean setComposingText(CharSequence text, int newCursorPosition) { | 214 public boolean setComposingText(CharSequence text, int newCursorPosition) { |
215 if (DEBUG) Log.w(TAG, "setComposingText [" + text + "] [" + newCursorPos
ition + "]"); | 215 if (DEBUG) Log.w(TAG, "setComposingText [" + text + "] [" + newCursorPos
ition + "]"); |
| 216 if (mEditable.length() == mImeAdapter.getInputElementMaxLength()) { |
| 217 finishComposingText(); |
| 218 return true; |
| 219 } |
216 if (maybePerformEmptyCompositionWorkaround(text)) return true; | 220 if (maybePerformEmptyCompositionWorkaround(text)) return true; |
217 super.setComposingText(text, newCursorPosition); | 221 super.setComposingText(text, newCursorPosition); |
218 updateSelectionIfRequired(); | 222 updateSelectionIfRequired(); |
219 return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPos
ition, false); | 223 return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPos
ition, false); |
220 } | 224 } |
221 | 225 |
222 /** | 226 /** |
223 * @see BaseInputConnection#commitText(java.lang.CharSequence, int) | 227 * @see BaseInputConnection#commitText(java.lang.CharSequence, int) |
224 */ | 228 */ |
225 @Override | 229 @Override |
226 public boolean commitText(CharSequence text, int newCursorPosition) { | 230 public boolean commitText(CharSequence text, int newCursorPosition) { |
227 if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition
+ "]"); | 231 if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition
+ "]"); |
| 232 if (mEditable.length() == mImeAdapter.getInputElementMaxLength()) { |
| 233 finishComposingText(); |
| 234 return true; |
| 235 } |
228 if (maybePerformEmptyCompositionWorkaround(text)) return true; | 236 if (maybePerformEmptyCompositionWorkaround(text)) return true; |
229 super.commitText(text, newCursorPosition); | 237 super.commitText(text, newCursorPosition); |
230 updateSelectionIfRequired(); | 238 updateSelectionIfRequired(); |
231 return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPos
ition, | 239 return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPos
ition, |
232 text.length() > 0); | 240 text.length() > 0); |
233 } | 241 } |
234 | 242 |
235 /** | 243 /** |
236 * @see BaseInputConnection#performEditorAction(int) | 244 * @see BaseInputConnection#performEditorAction(int) |
237 */ | 245 */ |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 @VisibleForTesting | 532 @VisibleForTesting |
525 ImeState getImeStateForTesting() { | 533 ImeState getImeStateForTesting() { |
526 String text = mEditable.toString(); | 534 String text = mEditable.toString(); |
527 int selectionStart = Selection.getSelectionStart(mEditable); | 535 int selectionStart = Selection.getSelectionStart(mEditable); |
528 int selectionEnd = Selection.getSelectionEnd(mEditable); | 536 int selectionEnd = Selection.getSelectionEnd(mEditable); |
529 int compositionStart = getComposingSpanStart(mEditable); | 537 int compositionStart = getComposingSpanStart(mEditable); |
530 int compositionEnd = getComposingSpanEnd(mEditable); | 538 int compositionEnd = getComposingSpanEnd(mEditable); |
531 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); | 539 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); |
532 } | 540 } |
533 } | 541 } |
OLD | NEW |