Skip to content

Commit

Permalink
Bug 1729402 - Changing inputmode might not set input-purpose on GTK. …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
makotokato committed Sep 14, 2021
1 parent 76db511 commit 6cf4324
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 19 additions & 0 deletions widget/IMEData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 1 addition & 3 deletions widget/gtk/IMContextWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 6cf4324

Please sign in to comment.