Chromium Code Reviews| 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 96f70be81ed207bbc996db25ddafe4f58ac82fe5..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,15 +549,22 @@ class ImeAdapter { |
| return; |
| } |
| - Selection.setSelection(editable, selectionStart, selectionEnd); |
| + if (prevSelectionStart != selectionStart || prevSelectionEnd != selectionEnd) { |
| + Selection.setSelection(editable, selectionStart, selectionEnd); |
| + } |
| - if (compositionStart == compositionEnd) { |
| - removeComposingSpans(getEditable()); |
| - } else { |
| - super.setComposingRegion(compositionStart, compositionEnd); |
| + 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); |
| } |
| @@ -564,6 +572,7 @@ class ImeAdapter { |
| protected void updateSelection( |
| int selectionStart, int selectionEnd, |
| int compositionStart, int compositionEnd) { |
| + mPendingUpdate = false; |
| // Avoid sending update if we sent an exact update already previously. |
| if (mLastUpdateSelectionStart == selectionStart && |
|
aurimas (slooooooooow)
2013/04/10 14:35:46
Can you explain why this if check for the last upd
Fredrik Öhrn
2013/04/10 15:27:36
When setIgnoreTextInputStateUpdates(false) calls t
aurimas (slooooooooow)
2013/04/10 15:49:12
If the keyboard did change the selection or compos
|
| mLastUpdateSelectionEnd == selectionEnd && |
| @@ -739,6 +748,7 @@ class ImeAdapter { |
| if (DEBUG) Log.w(TAG, "restartInput"); |
| getInputMethodManagerWrapper().restartInput(mInternalView); |
| mIgnoreTextInputStateUpdates = false; |
| + mPendingUpdate = false; |
| mNumNestedBatchEdits = 0; |
| } |
| @@ -761,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), |