Bug 1466910 - 7. Don't coalesce notifyIMEContext calls; r?esawin
Right now we coalesce notifyIMEContext calls but only for legacy
reasons. With the current code we don't want to coalesce calls, in order
to be properly notified of blurring and focusing.
MozReview-Commit-ID: 6N2jhyyBKui
--- a/widget/android/GeckoEditableSupport.cpp
+++ b/widget/android/GeckoEditableSupport.cpp
@@ -1394,39 +1394,35 @@ GeckoEditableSupport::SetInputContext(co
if (mInputContext.mIMEState.mEnabled != IMEState::DISABLED &&
aAction.UserMightRequestOpenVKB()) {
// Don't reset keyboard when we should simply open the vkb
mEditable->NotifyIME(EditableListener::NOTIFY_IME_OPEN_VKB);
return;
}
- if (mIMEUpdatingContext) {
- return;
- }
- mIMEUpdatingContext = true;
-
- RefPtr<GeckoEditableSupport> self(this);
const bool inPrivateBrowsing = mInputContext.mInPrivateBrowsing;
- const bool isUserAction = aAction.IsHandlingUserInput() || aContext.mHasHandledUserInput;
+ const bool isUserAction =
+ aAction.IsHandlingUserInput() || aContext.mHasHandledUserInput;
const int32_t flags =
(inPrivateBrowsing ? EditableListener::IME_FLAG_PRIVATE_BROWSING : 0) |
(isUserAction ? EditableListener::IME_FLAG_USER_ACTION : 0);
- nsAppShell::PostEvent([this, self, flags] {
+ // Post an event to keep calls in order relative to NotifyIME.
+ nsAppShell::PostEvent([this, self = RefPtr<GeckoEditableSupport>(this),
+ flags, context = mInputContext] {
nsCOMPtr<nsIWidget> widget = GetWidget();
- mIMEUpdatingContext = false;
if (!widget || widget->Destroyed()) {
return;
}
- mEditable->NotifyIMEContext(mInputContext.mIMEState.mEnabled,
- mInputContext.mHTMLInputType,
- mInputContext.mHTMLInputInputmode,
- mInputContext.mActionHint,
+ mEditable->NotifyIMEContext(context.mIMEState.mEnabled,
+ context.mHTMLInputType,
+ context.mHTMLInputInputmode,
+ context.mActionHint,
flags);
});
}
InputContext
GeckoEditableSupport::GetInputContext()
{
InputContext context = mInputContext;
--- a/widget/android/GeckoEditableSupport.h
+++ b/widget/android/GeckoEditableSupport.h
@@ -97,17 +97,16 @@ class GeckoEditableSupport final
java::GeckoEditableChild::GlobalRef mEditable;
bool mEditableAttached;
InputContext mInputContext;
AutoTArray<UniquePtr<mozilla::WidgetEvent>, 4> mIMEKeyEvents;
AutoTArray<IMETextChange, 4> mIMETextChanges;
RefPtr<TextRangeArray> mIMERanges;
int32_t mIMEMaskEventsCount; // Mask events when > 0.
int32_t mIMEFocusCount; // We are focused when > 0.
- bool mIMEUpdatingContext;
bool mIMESelectionChanged;
bool mIMETextChangedDuringFlush;
bool mIMEMonitorCursor;
static bool sDispatchKeyEventsInCompositionForAnyApps;
void ObservePrefs();
@@ -177,17 +176,16 @@ public:
java::GeckoEditableChild::Param aEditableChild)
: mIsRemote(!aWindow)
, mWindow(aPtr, aWindow)
, mEditable(aEditableChild)
, mEditableAttached(!mIsRemote)
, mIMERanges(new TextRangeArray())
, mIMEMaskEventsCount(1) // Mask IME events since there's no focus yet
, mIMEFocusCount(0)
- , mIMEUpdatingContext(false)
, mIMESelectionChanged(false)
, mIMETextChangedDuringFlush(false)
, mIMEMonitorCursor(false)
{
ObservePrefs();
}
// Constructor for content process GeckoEditableChild.