OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 import android.os.ResultReceiver; | 9 import android.os.ResultReceiver; |
10 import android.text.Editable; | 10 import android.text.Editable; |
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 } | 542 } |
543 | 543 |
544 if (prevSelectionStart == selectionStart && prevSelectionEnd == sele ctionEnd | 544 if (prevSelectionStart == selectionStart && prevSelectionEnd == sele ctionEnd |
545 && prevCompositionStart == compositionStart | 545 && prevCompositionStart == compositionStart |
546 && prevCompositionEnd == compositionEnd) { | 546 && prevCompositionEnd == compositionEnd) { |
547 // Nothing has changed; don't need to do anything | 547 // Nothing has changed; don't need to do anything |
548 return; | 548 return; |
549 } | 549 } |
550 | 550 |
551 Selection.setSelection(editable, selectionStart, selectionEnd); | 551 Selection.setSelection(editable, selectionStart, selectionEnd); |
552 super.setComposingRegion(compositionStart, compositionEnd); | 552 |
553 if (compositionStart == compositionEnd) { | |
554 removeComposingSpans(getEditable()); | |
nilesh
2013/04/10 16:19:05
Is there a reason to not use the local var 'editab
Fredrik Öhrn
2013/04/10 16:23:08
Copy and paste laziness on my part, will fix.
| |
555 } else { | |
556 super.setComposingRegion(compositionStart, compositionEnd); | |
557 } | |
553 | 558 |
554 if (mIgnoreTextInputStateUpdates) return; | 559 if (mIgnoreTextInputStateUpdates) return; |
555 updateSelection(selectionStart, selectionEnd, compositionStart, comp ositionEnd); | 560 updateSelection(selectionStart, selectionEnd, compositionStart, comp ositionEnd); |
556 } | 561 } |
557 | 562 |
558 @VisibleForTesting | 563 @VisibleForTesting |
559 protected void updateSelection( | 564 protected void updateSelection( |
560 int selectionStart, int selectionEnd, | 565 int selectionStart, int selectionEnd, |
561 int compositionStart, int compositionEnd) { | 566 int compositionStart, int compositionEnd) { |
562 // Avoid sending update if we sent an exact update already previousl y. | 567 // Avoid sending update if we sent an exact update already previousl y. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
735 getInputMethodManagerWrapper().restartInput(mInternalView); | 740 getInputMethodManagerWrapper().restartInput(mInternalView); |
736 mIgnoreTextInputStateUpdates = false; | 741 mIgnoreTextInputStateUpdates = false; |
737 mNumNestedBatchEdits = 0; | 742 mNumNestedBatchEdits = 0; |
738 } | 743 } |
739 | 744 |
740 @Override | 745 @Override |
741 public boolean setComposingRegion(int start, int end) { | 746 public boolean setComposingRegion(int start, int end) { |
742 if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + " ]"); | 747 if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + " ]"); |
743 int a = Math.min(start, end); | 748 int a = Math.min(start, end); |
744 int b = Math.max(start, end); | 749 int b = Math.max(start, end); |
745 super.setComposingRegion(a, b); | 750 if (a == b) { |
751 removeComposingSpans(getEditable()); | |
752 } else { | |
753 super.setComposingRegion(a, b); | |
754 } | |
746 return mImeAdapter.setComposingRegion(a, b); | 755 return mImeAdapter.setComposingRegion(a, b); |
747 } | 756 } |
748 | 757 |
749 boolean isActive() { | 758 boolean isActive() { |
750 return getInputMethodManagerWrapper().isActive(mInternalView); | 759 return getInputMethodManagerWrapper().isActive(mInternalView); |
751 } | 760 } |
752 | 761 |
753 void setIgnoreTextInputStateUpdates(boolean shouldIgnore) { | 762 void setIgnoreTextInputStateUpdates(boolean shouldIgnore) { |
754 mIgnoreTextInputStateUpdates = shouldIgnore; | 763 mIgnoreTextInputStateUpdates = shouldIgnore; |
755 if (shouldIgnore) return; | 764 if (shouldIgnore) return; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 int before, int after); | 858 int before, int after); |
850 | 859 |
851 private native void nativeImeBatchStateChanged(int nativeImeAdapterAndroid, boolean isBegin); | 860 private native void nativeImeBatchStateChanged(int nativeImeAdapterAndroid, boolean isBegin); |
852 | 861 |
853 private native void nativeUnselect(int nativeImeAdapterAndroid); | 862 private native void nativeUnselect(int nativeImeAdapterAndroid); |
854 private native void nativeSelectAll(int nativeImeAdapterAndroid); | 863 private native void nativeSelectAll(int nativeImeAdapterAndroid); |
855 private native void nativeCut(int nativeImeAdapterAndroid); | 864 private native void nativeCut(int nativeImeAdapterAndroid); |
856 private native void nativeCopy(int nativeImeAdapterAndroid); | 865 private native void nativeCopy(int nativeImeAdapterAndroid); |
857 private native void nativePaste(int nativeImeAdapterAndroid); | 866 private native void nativePaste(int nativeImeAdapterAndroid); |
858 } | 867 } |
OLD | NEW |