mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 738695 - Part 2: Unify redundant IME mComposing and mCompositionStart variables. r=blassey
This commit is contained in:
parent
23afeac12e
commit
05adde8605
@ -89,15 +89,15 @@ public class GeckoInputConnection
|
||||
private static final int NOTIFY_IME_CANCELCOMPOSITION = 2;
|
||||
private static final int NOTIFY_IME_FOCUSCHANGE = 3;
|
||||
|
||||
private static final CharacterStyle COMPOSING_SPAN = new UnderlineSpan();
|
||||
private static final int NO_COMPOSITION_STRING = -1;
|
||||
|
||||
private static final Timer mIMETimer = new Timer("GeckoInputConnection Timer");
|
||||
private static int mIMEState;
|
||||
private static String mIMETypeHint;
|
||||
private static String mIMEActionHint;
|
||||
|
||||
// Is a composition active?
|
||||
private boolean mComposing;
|
||||
private int mCompositionStart = -1;
|
||||
private int mCompositionStart = NO_COMPOSITION_STRING;
|
||||
private Editable mEditable;
|
||||
private Editable.Factory mEditableFactory;
|
||||
private boolean mBatchMode;
|
||||
@ -142,7 +142,7 @@ public class GeckoInputConnection
|
||||
public boolean commitText(CharSequence text, int newCursorPosition) {
|
||||
replaceText(text, newCursorPosition, false);
|
||||
|
||||
if (mComposing) {
|
||||
if (hasCompositionString()) {
|
||||
if (DEBUG) Log.d(LOGTAG, ". . . commitText: endComposition");
|
||||
endComposition();
|
||||
}
|
||||
@ -151,7 +151,7 @@ public class GeckoInputConnection
|
||||
|
||||
@Override
|
||||
public boolean finishComposingText() {
|
||||
if (mComposing) {
|
||||
if (hasCompositionString()) {
|
||||
if (DEBUG) Log.d(LOGTAG, ". . . finishComposingText: endComposition");
|
||||
endComposition();
|
||||
}
|
||||
@ -369,7 +369,8 @@ public class GeckoInputConnection
|
||||
if (!(text instanceof Spannable)) {
|
||||
sp = new SpannableStringBuilder(text);
|
||||
text = sp;
|
||||
sp.setSpan(COMPOSING_SPAN, 0, sp.length(),
|
||||
// Underline the active composition string.
|
||||
sp.setSpan(new UnderlineSpan(), 0, sp.length(),
|
||||
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | Spanned.SPAN_COMPOSING);
|
||||
} else {
|
||||
sp = (Spannable) text;
|
||||
@ -416,7 +417,7 @@ public class GeckoInputConnection
|
||||
|
||||
@Override
|
||||
public boolean setComposingRegion(int start, int end) {
|
||||
if (mComposing) {
|
||||
if (hasCompositionString()) {
|
||||
if (DEBUG) Log.d(LOGTAG, ". . . setComposingRegion: endComposition");
|
||||
endComposition();
|
||||
}
|
||||
@ -449,7 +450,7 @@ public class GeckoInputConnection
|
||||
// In that case we are not updated when a composition
|
||||
// is destroyed, and Bad Things happen
|
||||
|
||||
if (!mComposing)
|
||||
if (!hasCompositionString())
|
||||
return false;
|
||||
|
||||
String text = getComposingText();
|
||||
@ -551,15 +552,14 @@ public class GeckoInputConnection
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
mComposing = false;
|
||||
mCompositionStart = -1;
|
||||
mCompositionStart = NO_COMPOSITION_STRING;
|
||||
mBatchMode = false;
|
||||
mUpdateRequest = null;
|
||||
}
|
||||
|
||||
// TextWatcher
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (mComposing && mCompositionStart != start) {
|
||||
if (hasCompositionString() && mCompositionStart != start) {
|
||||
// Changed range is different from the composition, need to reset the composition
|
||||
endComposition();
|
||||
}
|
||||
@ -575,11 +575,10 @@ public class GeckoInputConnection
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mComposing) {
|
||||
if (!hasCompositionString()) {
|
||||
if (DEBUG) Log.d(LOGTAG, ". . . onTextChanged: IME_COMPOSITION_BEGIN");
|
||||
GeckoAppShell.sendEventToGecko(
|
||||
GeckoEvent.createIMEEvent(GeckoEvent.IME_COMPOSITION_BEGIN, 0, 0));
|
||||
mComposing = true;
|
||||
mCompositionStart = start;
|
||||
|
||||
if (DEBUG) {
|
||||
@ -614,8 +613,7 @@ public class GeckoInputConnection
|
||||
if (DEBUG) Log.d(LOGTAG, "IME: endComposition: IME_COMPOSITION_END");
|
||||
GeckoAppShell.sendEventToGecko(
|
||||
GeckoEvent.createIMEEvent(GeckoEvent.IME_COMPOSITION_END, 0, 0));
|
||||
mComposing = false;
|
||||
mCompositionStart = -1;
|
||||
mCompositionStart = NO_COMPOSITION_STRING;
|
||||
}
|
||||
|
||||
private void sendTextToGecko(CharSequence text, int caretPos) {
|
||||
@ -1012,6 +1010,10 @@ public class GeckoInputConnection
|
||||
mEditable.setSpan(this, 0, contents.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
Selection.setSelection(mEditable, contents.length());
|
||||
}
|
||||
|
||||
private boolean hasCompositionString() {
|
||||
return mCompositionStart != NO_COMPOSITION_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
class DebugGeckoInputConnection extends GeckoInputConnection {
|
||||
|
Loading…
Reference in New Issue
Block a user