Bug 1618759 - Part 6. Don't open on-screen keyboard when inputmode is none. r=masayuki

`inputmode=none` means that OSK is closed.

`SetInputContext` doesn't call `DismissOnScreenKeyboard` directly since
`DismissOnScreenKeyboard` has no hack of Firefox VR.

Depends on D68316

Differential Revision: https://phabricator.services.mozilla.com/D68317

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Makoto Kato 2020-04-07 13:29:28 +00:00
Родитель 697c8ef8d4
Коммит adc03fb040
2 изменённых файлов: 24 добавлений и 8 удалений

Просмотреть файл

@ -301,7 +301,8 @@ nsresult IMEHandler::NotifyIME(nsWindow* aWindow,
nsresult rv = TSFTextStore::OnFocusChange(true, aWindow,
aWindow->GetInputContext());
MaybeCreateNativeCaret(aWindow);
IMEHandler::MaybeShowOnScreenKeyboard(aWindow);
IMEHandler::MaybeShowOnScreenKeyboard(aWindow,
aWindow->GetInputContext());
return rv;
}
case NOTIFY_IME_OF_BLUR:
@ -361,7 +362,8 @@ nsresult IMEHandler::NotifyIME(nsWindow* aWindow,
case NOTIFY_IME_OF_FOCUS:
sFocusedWindow = aWindow;
IMMHandler::OnFocusChange(true, aWindow);
IMEHandler::MaybeShowOnScreenKeyboard(aWindow);
IMEHandler::MaybeShowOnScreenKeyboard(aWindow,
aWindow->GetInputContext());
MaybeCreateNativeCaret(aWindow);
return NS_OK;
case NOTIFY_IME_OF_BLUR:
@ -476,8 +478,10 @@ void IMEHandler::SetInputContext(nsWindow* aWindow, InputContext& aInputContext,
aWindow->DispatchPluginSettingEvents();
}
if (aAction.UserMightRequestOpenVKB()) {
IMEHandler::MaybeShowOnScreenKeyboard(aWindow);
if (aInputContext.mHTMLInputInputmode.EqualsLiteral("none")) {
IMEHandler::MaybeDismissOnScreenKeyboard(aWindow, Sync::Yes);
} else if (aAction.UserMightRequestOpenVKB()) {
IMEHandler::MaybeShowOnScreenKeyboard(aWindow, aInputContext);
}
bool enable = WinUtils::IsIMEEnabled(aInputContext);
@ -775,7 +779,11 @@ void IMEHandler::AppendInputScopeFromType(const nsAString& aHTMLInputType,
}
// static
void IMEHandler::MaybeShowOnScreenKeyboard(nsWindow* aWindow) {
void IMEHandler::MaybeShowOnScreenKeyboard(nsWindow* aWindow,
const InputContext& aInputContext) {
if (aInputContext.mHTMLInputInputmode.EqualsLiteral("none")) {
return;
}
#ifdef NIGHTLY_BUILD
if (FxRWindowManager::GetInstance()->IsFxRWindow(sFocusedWindow)) {
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
@ -805,7 +813,7 @@ void IMEHandler::MaybeShowOnScreenKeyboard(nsWindow* aWindow) {
}
// static
void IMEHandler::MaybeDismissOnScreenKeyboard(nsWindow* aWindow) {
void IMEHandler::MaybeDismissOnScreenKeyboard(nsWindow* aWindow, Sync aSync) {
#ifdef NIGHTLY_BUILD
if (FxRWindowManager::GetInstance()->IsFxRWindow(aWindow)) {
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
@ -817,6 +825,11 @@ void IMEHandler::MaybeDismissOnScreenKeyboard(nsWindow* aWindow) {
return;
}
if (aSync == Sync::Yes) {
DismissOnScreenKeyboard(aWindow);
return;
}
RefPtr<nsWindow> window(aWindow);
NS_DispatchToCurrentThreadQueue(
NS_NewRunnableFunction("IMEHandler::MaybeDismissOnScreenKeyboard",

Просмотреть файл

@ -222,8 +222,11 @@ class IMEHandler final {
static bool IsTSFAvailable() { return (sIsInTSFMode && !sPluginHasFocus); }
static bool IsIMMActive();
static void MaybeShowOnScreenKeyboard(nsWindow* aWindow);
static void MaybeDismissOnScreenKeyboard(nsWindow* aWindow);
static void MaybeShowOnScreenKeyboard(nsWindow* aWindow,
const InputContext& aInputContext);
enum class Sync { Yes, No };
static void MaybeDismissOnScreenKeyboard(nsWindow* aWindow,
Sync aSync = Sync::No);
static bool WStringStartsWithCaseInsensitive(const std::wstring& aHaystack,
const std::wstring& aNeedle);
static bool NeedOnScreenKeyboard();