Bug 989046 - f. Only unregister event in GeckoEditable if already registered; r=capella

This commit is contained in:
Jim Chen 2014-04-04 12:33:51 -04:00
parent 11d4068752
commit 4f6e8707c8

View File

@ -103,7 +103,8 @@ final class GeckoEditable
private int mIcUpdateSeqno;
private int mLastIcUpdateSeqno;
private boolean mUpdateGecko;
private boolean mFocused;
private boolean mFocused; // Used by IC thread
private boolean mGeckoFocused; // Used by Gecko thread
private volatile boolean mSuppressCompositions;
private volatile boolean mSuppressKeyUp;
@ -759,11 +760,16 @@ final class GeckoEditable
});
// Register/unregister Gecko-side text selection listeners
if (type == NOTIFY_IME_OF_BLUR) {
// and update the mGeckoFocused flag.
if (type == NOTIFY_IME_OF_BLUR && mGeckoFocused) {
// Check for focus here because Gecko may send us a blur before a focus in some
// cases, and we don't want to unregister an event that was not registered.
mGeckoFocused = false;
mSuppressCompositions = false;
GeckoAppShell.getEventDispatcher().
unregisterEventListener("TextSelection:IMECompositions", this);
} else if (type == NOTIFY_IME_OF_FOCUS) {
mGeckoFocused = true;
mSuppressCompositions = false;
GeckoAppShell.getEventDispatcher().
registerEventListener("TextSelection:IMECompositions", this);