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

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

Issue 13909003: [Android] Suppress unnecessary selection updates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ime
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 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),
« 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