Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java

Issue 13820016: [Android] Remove zero length composing spans. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
index 1f73502d70a17ff4705137121f602660c23553eb..255013a9cbff5ff0d0a7b51b57ef300a020802e3 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
@@ -495,6 +495,7 @@ class ImeAdapter {
private boolean mSingleLine;
private int mNumNestedBatchEdits = 0;
private boolean mIgnoreTextInputStateUpdates = false;
+ private boolean mPendingUpdate = false;
private int mLastUpdateSelectionStart = INVALID_SELECTION;
private int mLastUpdateSelectionEnd = INVALID_SELECTION;
@@ -548,10 +549,22 @@ class ImeAdapter {
return;
}
- Selection.setSelection(editable, selectionStart, selectionEnd);
- super.setComposingRegion(compositionStart, compositionEnd);
+ if (prevSelectionStart != selectionStart || prevSelectionEnd != selectionEnd) {
+ Selection.setSelection(editable, selectionStart, selectionEnd);
+ }
+
+ if (prevCompositionStart != compositionStart || prevCompositionEnd != compositionEnd) {
+ if (compositionStart == compositionEnd) {
+ removeComposingSpans(getEditable());
+ } else {
+ super.setComposingRegion(compositionStart, compositionEnd);
+ }
+ }
- if (mIgnoreTextInputStateUpdates) return;
+ if (mIgnoreTextInputStateUpdates) {
+ mPendingUpdate = true;
+ return;
+ }
updateSelection(selectionStart, selectionEnd, compositionStart, compositionEnd);
}
@@ -559,6 +572,7 @@ class ImeAdapter {
protected void updateSelection(
int selectionStart, int selectionEnd,
int compositionStart, int compositionEnd) {
+ mPendingUpdate = false;
aurimas (slooooooooow) 2013/04/09 17:09:26 Can you explain this PendingUpdate flag and why we
// Avoid sending update if we sent an exact update already previously.
if (mLastUpdateSelectionStart == selectionStart &&
mLastUpdateSelectionEnd == selectionEnd &&
@@ -734,6 +748,7 @@ class ImeAdapter {
if (DEBUG) Log.w(TAG, "restartInput");
getInputMethodManagerWrapper().restartInput(mInternalView);
mIgnoreTextInputStateUpdates = false;
+ mPendingUpdate = false;
mNumNestedBatchEdits = 0;
}
@@ -742,7 +757,11 @@ class ImeAdapter {
if (DEBUG) Log.w(TAG, "setComposingRegion [" + start + " " + end + "]");
int a = Math.min(start, end);
int b = Math.max(start, end);
- super.setComposingRegion(a, b);
+ if (a == b) {
+ removeComposingSpans(getEditable());
+ } else {
+ super.setComposingRegion(a, b);
+ }
return mImeAdapter.setComposingRegion(a, b);
}
@@ -752,7 +771,7 @@ class ImeAdapter {
void setIgnoreTextInputStateUpdates(boolean shouldIgnore) {
mIgnoreTextInputStateUpdates = shouldIgnore;
- if (shouldIgnore) return;
+ if (shouldIgnore || !mPendingUpdate) return;
Editable editable = getEditable();
updateSelection(Selection.getSelectionStart(editable),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698