Bug 627019 - ignore IME changes from gecko when other changes are still pending

From 5797f333373ae0c21c6aa0c0192b4e2ab0acde37 Mon Sep 17 00:00:00 2001
---
 embedding/android/GeckoAppShell.java        |    3 +++
 embedding/android/GeckoInputConnection.java |   23 ++++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)
This commit is contained in:
James Willcox 2011-08-16 16:57:41 -04:00
Родитель 9988369722
Коммит 5de8b0dbfc
2 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -558,6 +558,9 @@ public class GeckoAppShell
if (imm == null)
return;
// Log.d("GeckoAppJava", String.format("IME: notifyIMEChange: t=%s s=%d ne=%d oe=%d",
// text, start, newEnd, end));
if (newEnd < 0)
GeckoApp.surfaceView.inputConnection.notifySelectionChange(
imm, start, end);

Просмотреть файл

@ -509,9 +509,14 @@ public class GeckoInputConnection
public void notifyTextChange(InputMethodManager imm, String text,
int start, int oldEnd, int newEnd) {
//Log.d("GeckoAppJava", "IME: notifyTextChange");
// Log.d("GeckoAppShell", String.format("IME: notifyTextChange: text=%s s=%d ne=%d oe=%d",
// text, start, newEnd, oldEnd));
if (!text.contentEquals(GeckoApp.surfaceView.mEditable))
mNumPendingChanges = Math.max(mNumPendingChanges - 1, 0);
// If there are pending changes, that means this text is not the most up-to-date version
// and we'll step on ourselves if we change the editable right now.
if (mNumPendingChanges == 0 && !text.contentEquals(GeckoApp.surfaceView.mEditable))
GeckoApp.surfaceView.setEditable(text);
if (mUpdateRequest == null)
@ -537,7 +542,7 @@ public class GeckoInputConnection
public void notifySelectionChange(InputMethodManager imm,
int start, int end) {
//Log.d("GeckoAppJava", "IME: notifySelectionChange");
// Log.d("GeckoAppJava", String.format("IME: notifySelectionChange: s=%d e=%d", start, end));
if (mComposing)
imm.updateSelection(GeckoApp.surfaceView,
@ -548,6 +553,11 @@ public class GeckoInputConnection
else
imm.updateSelection(GeckoApp.surfaceView, start, end, -1, -1);
// We only change the selection if we are relatively sure that the text we have is
// up-to-date. Bail out if we are stil expecting changes.
if (mNumPendingChanges > 0)
return;
int maxLen = GeckoApp.surfaceView.mEditable.length();
Selection.setSelection(GeckoApp.surfaceView.mEditable,
Math.min(start, maxLen),
@ -558,11 +568,16 @@ public class GeckoInputConnection
mComposing = false;
mComposingText = "";
mUpdateRequest = null;
mNumPendingChanges = 0;
}
// TextWatcher
public void onTextChanged(CharSequence s, int start, int before, int count)
{
// Log.d("GeckoAppShell", String.format("IME: onTextChanged: t=%s s=%d b=%d l=%d",
// s, start, before, count));
mNumPendingChanges++;
GeckoAppShell.sendEventToGecko(
new GeckoEvent(GeckoEvent.IME_SET_SELECTION, start, before));
@ -611,6 +626,8 @@ public class GeckoInputConnection
int mCompositionSelStart;
// Length of fake selection
int mCompositionSelLen;
// Number of in flight changes
int mNumPendingChanges;
ExtractedTextRequest mUpdateRequest;
final ExtractedText mUpdateExtract = new ExtractedText();