diff --git a/widget/gtk/nsGtkIMModule.cpp b/widget/gtk/nsGtkIMModule.cpp index 9dc2eeec9957..b0f42db8e3da 100644 --- a/widget/gtk/nsGtkIMModule.cpp +++ b/widget/gtk/nsGtkIMModule.cpp @@ -306,7 +306,8 @@ nsGtkIMModule::OnKeyEvent(nsWindow* aCaller, GdkEventKey* aEvent, { NS_PRECONDITION(aEvent, "aEvent must be non-null"); - if (!IsEditable() || MOZ_UNLIKELY(IsDestroyed())) { + if (!mInputContext.mIMEState.MaybeEditable() || + MOZ_UNLIKELY(IsDestroyed())) { return false; } @@ -495,7 +496,7 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller, aContext->mHTMLInputType != mInputContext.mHTMLInputType; // Release current IME focus if IME is enabled. - if (changingEnabledState && IsEditable()) { + if (changingEnabledState && mInputContext.mIMEState.MaybeEditable()) { EndIMEComposition(mLastFocusedWindow); Blur(); } @@ -505,7 +506,7 @@ nsGtkIMModule::SetInputContext(nsWindow* aCaller, if (changingEnabledState) { #if (MOZ_WIDGET_GTK == 3) static bool sInputPurposeSupported = !gtk_check_version(3, 6, 0); - if (sInputPurposeSupported && IsEditable()) { + if (sInputPurposeSupported && mInputContext.mIMEState.MaybeEditable()) { GtkIMContext* context = GetContext(); if (context) { GtkInputPurpose purpose = GTK_INPUT_PURPOSE_FREE_FORM; @@ -602,14 +603,6 @@ nsGtkIMModule::IsEnabled() mInputContext.mIMEState.mEnabled == IMEState::PASSWORD); } -bool -nsGtkIMModule::IsEditable() -{ - return mInputContext.mIMEState.mEnabled == IMEState::ENABLED || - mInputContext.mIMEState.mEnabled == IMEState::PLUGIN || - mInputContext.mIMEState.mEnabled == IMEState::PASSWORD; -} - void nsGtkIMModule::Focus() { diff --git a/widget/gtk/nsGtkIMModule.h b/widget/gtk/nsGtkIMModule.h index e9678365e207..36f3b01cd478 100644 --- a/widget/gtk/nsGtkIMModule.h +++ b/widget/gtk/nsGtkIMModule.h @@ -251,12 +251,6 @@ protected: // state. So, this means *current* IM context. GtkIMContext* GetContext(); - // "Editable" means the users can input characters. They may be not able to - // use IMEs but they can use dead keys. - // I.e., the focus is in the normal editors or the password editors or - // the |ime-mode: disabled;| editors. - bool IsEditable(); - // If the owner window and IM context have been destroyed, returns TRUE. bool IsDestroyed() { return !mOwnerWindow; } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index a7b44247a0d5..71e01395768c 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -384,10 +384,21 @@ struct IMEState { { } + // Returns true if the user can input characters. + // This means that a plain text editor, an HTML editor, a password editor or + // a plain text editor whose ime-mode is "disabled". bool IsEditable() const { return mEnabled == ENABLED || mEnabled == PASSWORD; } + // Returns true if the user might be able to input characters. + // This means that a plain text editor, an HTML editor, a password editor, + // a plain text editor whose ime-mode is "disabled" or a windowless plugin + // has focus. + bool MaybeEditable() const + { + return IsEditable() || mEnabled == PLUGIN; + } }; struct InputContext {