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

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

Issue 13105005: [android] Adding a check not to send the same update to IME. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 0e55c152e8ade9f6506f6768b8e5c2a01a941dd2..1f73502d70a17ff4705137121f602660c23553eb 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
@@ -63,6 +63,7 @@ class ImeAdapter {
* Selection value should be -1 if not known. See EditorInfo.java for details.
*/
static final int INVALID_SELECTION = -1;
+ static final int INVALID_COMPOSITION = -1;
static int sEventTypeRawKeyDown;
static int sEventTypeKeyUp;
@@ -495,6 +496,11 @@ class ImeAdapter {
private int mNumNestedBatchEdits = 0;
private boolean mIgnoreTextInputStateUpdates = false;
+ private int mLastUpdateSelectionStart = INVALID_SELECTION;
+ private int mLastUpdateSelectionEnd = INVALID_SELECTION;
+ private int mLastUpdateCompositionStart = INVALID_COMPOSITION;
+ private int mLastUpdateCompositionEnd = INVALID_COMPOSITION;
+
/**
* Updates the AdapterInputConnection's internal representation of the text
* being edited and its selection and composition properties. The resulting
@@ -553,6 +559,13 @@ class ImeAdapter {
protected void updateSelection(
int selectionStart, int selectionEnd,
int compositionStart, int compositionEnd) {
+ // Avoid sending update if we sent an exact update already previously.
+ if (mLastUpdateSelectionStart == selectionStart &&
+ mLastUpdateSelectionEnd == selectionEnd &&
+ mLastUpdateCompositionStart == compositionStart &&
+ mLastUpdateCompositionEnd == compositionEnd) {
+ return;
+ }
if (DEBUG) {
Log.w(TAG, "updateSelection [" + selectionStart + " " + selectionEnd + "] ["
+ compositionStart + " " + compositionEnd + "]");
@@ -561,6 +574,10 @@ class ImeAdapter {
// if it happens not within a batch edit, or at the end of each top level batch edit.
getInputMethodManagerWrapper().updateSelection(mInternalView,
selectionStart, selectionEnd, compositionStart, compositionEnd);
+ mLastUpdateSelectionStart = selectionStart;
+ mLastUpdateSelectionEnd = selectionEnd;
+ mLastUpdateCompositionStart = compositionStart;
+ mLastUpdateCompositionEnd = compositionEnd;
}
@Override
« 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