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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 (maybePerformEmptyCompositionWorkaround(text)) return true; | 216 if (maybePerformEmptyCompositionWorkaround(text)) return true; |
217 super.setComposingText(text, newCursorPosition); | 217 super.setComposingText(text, newCursorPosition); |
218 updateSelectionIfRequired(); | 218 updateSelectionIfRequired(); |
219 return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(), | 219 return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPos
ition, false); |
220 newCursorPosition, false); | |
221 } | 220 } |
222 | 221 |
223 /** | 222 /** |
224 * @see BaseInputConnection#commitText(java.lang.CharSequence, int) | 223 * @see BaseInputConnection#commitText(java.lang.CharSequence, int) |
225 */ | 224 */ |
226 @Override | 225 @Override |
227 public boolean commitText(CharSequence text, int newCursorPosition) { | 226 public boolean commitText(CharSequence text, int newCursorPosition) { |
228 if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition
+ "]"); | 227 if (DEBUG) Log.w(TAG, "commitText [" + text + "] [" + newCursorPosition
+ "]"); |
229 if (maybePerformEmptyCompositionWorkaround(text)) return true; | 228 if (maybePerformEmptyCompositionWorkaround(text)) return true; |
230 super.commitText(text, newCursorPosition); | 229 super.commitText(text, newCursorPosition); |
231 updateSelectionIfRequired(); | 230 updateSelectionIfRequired(); |
232 return mImeAdapter.checkCompositionQueueAndCallNative(text.toString(), | 231 return mImeAdapter.checkCompositionQueueAndCallNative(text, newCursorPos
ition, |
233 newCursorPosition, text.length() > 0); | 232 text.length() > 0); |
234 } | 233 } |
235 | 234 |
236 /** | 235 /** |
237 * @see BaseInputConnection#performEditorAction(int) | 236 * @see BaseInputConnection#performEditorAction(int) |
238 */ | 237 */ |
239 @Override | 238 @Override |
240 public boolean performEditorAction(int actionCode) { | 239 public boolean performEditorAction(int actionCode) { |
241 if (DEBUG) Log.w(TAG, "performEditorAction [" + actionCode + "]"); | 240 if (DEBUG) Log.w(TAG, "performEditorAction [" + actionCode + "]"); |
242 if (actionCode == EditorInfo.IME_ACTION_NEXT) { | 241 if (actionCode == EditorInfo.IME_ACTION_NEXT) { |
243 restartInput(); | 242 restartInput(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 @VisibleForTesting | 496 @VisibleForTesting |
498 ImeState getImeStateForTesting() { | 497 ImeState getImeStateForTesting() { |
499 String text = mEditable.toString(); | 498 String text = mEditable.toString(); |
500 int selectionStart = Selection.getSelectionStart(mEditable); | 499 int selectionStart = Selection.getSelectionStart(mEditable); |
501 int selectionEnd = Selection.getSelectionEnd(mEditable); | 500 int selectionEnd = Selection.getSelectionEnd(mEditable); |
502 int compositionStart = getComposingSpanStart(mEditable); | 501 int compositionStart = getComposingSpanStart(mEditable); |
503 int compositionEnd = getComposingSpanEnd(mEditable); | 502 int compositionEnd = getComposingSpanEnd(mEditable); |
504 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); | 503 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); |
505 } | 504 } |
506 } | 505 } |
OLD | NEW |