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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 if (b < 0) b = 0; | 453 if (b < 0) b = 0; |
454 if (a > textLength) a = textLength; | 454 if (a > textLength) a = textLength; |
455 if (b > textLength) b = textLength; | 455 if (b > textLength) b = textLength; |
456 | 456 |
457 if (a == b) { | 457 if (a == b) { |
458 removeComposingSpans(mEditable); | 458 removeComposingSpans(mEditable); |
459 } else { | 459 } else { |
460 super.setComposingRegion(a, b); | 460 super.setComposingRegion(a, b); |
461 } | 461 } |
462 updateSelectionIfRequired(); | 462 updateSelectionIfRequired(); |
463 return mImeAdapter.setComposingRegion(a, b); | 463 |
| 464 CharSequence regionText = null; |
| 465 if (b > a) { |
| 466 regionText = mEditable.subSequence(start, end); |
| 467 } |
| 468 return mImeAdapter.setComposingRegion(regionText, a, b); |
464 } | 469 } |
465 | 470 |
466 boolean isActive() { | 471 boolean isActive() { |
467 return getInputMethodManagerWrapper().isActive(mInternalView); | 472 return getInputMethodManagerWrapper().isActive(mInternalView); |
468 } | 473 } |
469 | 474 |
470 private InputMethodManagerWrapper getInputMethodManagerWrapper() { | 475 private InputMethodManagerWrapper getInputMethodManagerWrapper() { |
471 return mImeAdapter.getInputMethodManagerWrapper(); | 476 return mImeAdapter.getInputMethodManagerWrapper(); |
472 } | 477 } |
473 | 478 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 @VisibleForTesting | 524 @VisibleForTesting |
520 ImeState getImeStateForTesting() { | 525 ImeState getImeStateForTesting() { |
521 String text = mEditable.toString(); | 526 String text = mEditable.toString(); |
522 int selectionStart = Selection.getSelectionStart(mEditable); | 527 int selectionStart = Selection.getSelectionStart(mEditable); |
523 int selectionEnd = Selection.getSelectionEnd(mEditable); | 528 int selectionEnd = Selection.getSelectionEnd(mEditable); |
524 int compositionStart = getComposingSpanStart(mEditable); | 529 int compositionStart = getComposingSpanStart(mEditable); |
525 int compositionEnd = getComposingSpanEnd(mEditable); | 530 int compositionEnd = getComposingSpanEnd(mEditable); |
526 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); | 531 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); |
527 } | 532 } |
528 } | 533 } |
OLD | NEW |