From 6cf432407d86ed1953ba68ce7db077737decd144 Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Tue, 14 Sep 2021 14:35:17 +0000 Subject: [PATCH] Bug 1729402 - Changing inputmode might not set input-purpose on GTK. r=masayuki I have to consider that we have to set input-purpose even if inputmode only is changed. Differential Revision: https://phabricator.services.mozilla.com/D125209 --- widget/IMEData.h | 19 +++++++++++++++++++ widget/gtk/IMContextWrapper.cpp | 4 +--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/widget/IMEData.h b/widget/IMEData.h index 20ccc96c6592..11006bbeedeb 100644 --- a/widget/IMEData.h +++ b/widget/IMEData.h @@ -410,6 +410,25 @@ struct InputContext final { !mHTMLInputType.EqualsLiteral("email"); } + bool IsInputAttributeChanged(const InputContext& aOldContext) const { + return mIMEState.mEnabled != aOldContext.mIMEState.mEnabled || +#if defined(ANDROID) || defined(MOZ_WIDGET_GTK) || defined(XP_WIN) + // input type and inputmode are supported by Windows IME API, GTK + // IME API and Android IME API + mHTMLInputType != aOldContext.mHTMLInputType || + mHTMLInputInputmode != aOldContext.mHTMLInputInputmode || +#endif +#if defined(ANDROID) || defined(MOZ_WIDGET_GTK) + // autocapitalize is supported by Android IME API and GTK IME API + mAutocapitalize != aOldContext.mAutocapitalize || +#endif +#if defined(ANDROID) + // enterkeyhint is only supported by Android IME API. + mActionHint != aOldContext.mActionHint || +#endif + false; + } + IMEState mIMEState; /* The type of the input if the input is a html input field */ diff --git a/widget/gtk/IMContextWrapper.cpp b/widget/gtk/IMContextWrapper.cpp index e82e0d4f1f51..a7b93b75fa59 100644 --- a/widget/gtk/IMContextWrapper.cpp +++ b/widget/gtk/IMContextWrapper.cpp @@ -1275,9 +1275,7 @@ void IMContextWrapper::SetInputContext(nsWindow* aCaller, return; } - bool changingEnabledState = - aContext->mIMEState.mEnabled != mInputContext.mIMEState.mEnabled || - aContext->mHTMLInputType != mInputContext.mHTMLInputType; + bool changingEnabledState = aContext->IsInputAttributeChanged(mInputContext); // Release current IME focus if IME is enabled. if (changingEnabledState && mInputContext.mIMEState.IsEditable()) {