| 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.annotation.TargetApi; |
| 8 import android.os.Build; |
| 7 import android.text.Editable; | 9 import android.text.Editable; |
| 8 import android.text.InputType; | 10 import android.text.InputType; |
| 9 import android.text.Selection; | 11 import android.text.Selection; |
| 10 import android.util.StringBuilderPrinter; | 12 import android.util.StringBuilderPrinter; |
| 11 import android.view.KeyCharacterMap; | 13 import android.view.KeyCharacterMap; |
| 12 import android.view.KeyEvent; | 14 import android.view.KeyEvent; |
| 13 import android.view.View; | 15 import android.view.View; |
| 14 import android.view.inputmethod.BaseInputConnection; | 16 import android.view.inputmethod.BaseInputConnection; |
| 15 import android.view.inputmethod.EditorInfo; | 17 import android.view.inputmethod.EditorInfo; |
| 16 import android.view.inputmethod.ExtractedText; | 18 import android.view.inputmethod.ExtractedText; |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 535 } |
| 534 updateSelectionIfRequired(); | 536 updateSelectionIfRequired(); |
| 535 | 537 |
| 536 CharSequence regionText = null; | 538 CharSequence regionText = null; |
| 537 if (b > a) { | 539 if (b > a) { |
| 538 regionText = editable.subSequence(a, b); | 540 regionText = editable.subSequence(a, b); |
| 539 } | 541 } |
| 540 return mImeAdapter.setComposingRegion(regionText, a, b); | 542 return mImeAdapter.setComposingRegion(regionText, a, b); |
| 541 } | 543 } |
| 542 | 544 |
| 545 /** |
| 546 * @see BaseInputConnection#requestCursorUpdates(int) |
| 547 */ |
| 548 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 549 @Override |
| 550 public boolean requestCursorUpdates(int cursorUpdateMode) { |
| 551 return mImeAdapter.onRequestCursorUpdates(cursorUpdateMode); |
| 552 } |
| 553 |
| 543 @VisibleForTesting | 554 @VisibleForTesting |
| 544 static class ImeState { | 555 static class ImeState { |
| 545 public final String text; | 556 public final String text; |
| 546 public final int selectionStart; | 557 public final int selectionStart; |
| 547 public final int selectionEnd; | 558 public final int selectionEnd; |
| 548 public final int compositionStart; | 559 public final int compositionStart; |
| 549 public final int compositionEnd; | 560 public final int compositionEnd; |
| 550 | 561 |
| 551 public ImeState(String text, int selectionStart, int selectionEnd, | 562 public ImeState(String text, int selectionStart, int selectionEnd, |
| 552 int compositionStart, int compositionEnd) { | 563 int compositionStart, int compositionEnd) { |
| 553 this.text = text; | 564 this.text = text; |
| 554 this.selectionStart = selectionStart; | 565 this.selectionStart = selectionStart; |
| 555 this.selectionEnd = selectionEnd; | 566 this.selectionEnd = selectionEnd; |
| 556 this.compositionStart = compositionStart; | 567 this.compositionStart = compositionStart; |
| 557 this.compositionEnd = compositionEnd; | 568 this.compositionEnd = compositionEnd; |
| 558 } | 569 } |
| 559 } | 570 } |
| 560 | 571 |
| 561 @VisibleForTesting | 572 @VisibleForTesting |
| 562 ImeState getImeStateForTesting() { | 573 ImeState getImeStateForTesting() { |
| 563 Editable editable = getEditableInternal(); | 574 Editable editable = getEditableInternal(); |
| 564 String text = editable.toString(); | 575 String text = editable.toString(); |
| 565 int selectionStart = Selection.getSelectionStart(editable); | 576 int selectionStart = Selection.getSelectionStart(editable); |
| 566 int selectionEnd = Selection.getSelectionEnd(editable); | 577 int selectionEnd = Selection.getSelectionEnd(editable); |
| 567 int compositionStart = getComposingSpanStart(editable); | 578 int compositionStart = getComposingSpanStart(editable); |
| 568 int compositionEnd = getComposingSpanEnd(editable); | 579 int compositionEnd = getComposingSpanEnd(editable); |
| 569 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); | 580 return new ImeState(text, selectionStart, selectionEnd, compositionStart
, compositionEnd); |
| 570 } | 581 } |
| 571 } | 582 } |
| OLD | NEW |