Bug 1409155 - IMEHandler should not associate IMC with any window if active IME is ATOK 2010 or earlier with x64 build on Win8 or later r=m_kato

ATOK started to be TIP of TSF since 2011.  Older than it, i.e., ATOK 2010 and
earlier have a lot of problems even for daily use.  Perhaps, the reason is
Win 8 has a lot of changes around IMM-IME support and TSF, and ATOK 2010 is
released earlier than Win 8.

ATOK 2006 crashes while converting a word with candidate window.
ATOK 2007 doesn't paint and resize suggest window and candidate window
correctly (showing white window or too big window).
ATOK 2008 and ATOK 2009 crash when user just opens their open state.
ATOK 2010 isn't installable newly on Win 7 or later, but we have a lot of
crash reports.

Note that ATOK 2006 is the first version supporting Win XP x64.  So, ATOK 2005
must not support x64 apps.

Unfortunately, we cannot block loading DLLs of them.  Therefore, IMEHandler
should disassociate IMC from active window when user changes active keyboard
layout to the legacy ATOK and not associate IME with any window when
SetInputContext() is called even with "enabled".  Additionally, when user
changes active keyboard layout from the legacy ATOK to one of the other
keyboard layouts, IMEHandler should associate IMC with current window for
new active IME.

MozReview-Commit-ID: RVYwmYxzO7

--HG--
extra : rebase_source : c237a3aca6ceb6a1f7251bd9421e4b905be5bc6c
This commit is contained in:
Masayuki Nakano 2017-10-25 23:51:27 +09:00
Родитель a2f6cf439f
Коммит e78b3f56ea
5 изменённых файлов: 94 добавлений и 23 удалений

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

@ -16,6 +16,7 @@
#include "mozilla/CheckedInt.h"
#include "mozilla/MiscEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/WindowsVersion.h"
#ifndef IME_PROP_ACCEPT_WIDE_VKEY
#define IME_PROP_ACCEPT_WIDE_VKEY 0x20
@ -225,6 +226,54 @@ bool IMMHandler::sAssumeVerticalWritingModeNotSupported = false;
bool IMMHandler::sHasFocus = false;
bool IMMHandler::sNativeCaretIsCreatedForPlugin = false;
#define IMPL_IS_IME_ACTIVE(aReadableName, aActualName) \
bool \
IMMHandler::Is ## aReadableName ## Active() \
{ \
return sIMEName.Equals(aActualName); \
} \
IMPL_IS_IME_ACTIVE(ATOK2006, u"ATOK 2006")
IMPL_IS_IME_ACTIVE(ATOK2007, u"ATOK 2007")
IMPL_IS_IME_ACTIVE(ATOK2008, u"ATOK 2008")
IMPL_IS_IME_ACTIVE(ATOK2009, u"ATOK 2009")
IMPL_IS_IME_ACTIVE(ATOK2010, u"ATOK 2010")
// NOTE: Even on Windows for en-US, the name of Google Japanese Input is
// written in Japanese.
IMPL_IS_IME_ACTIVE(GoogleJapaneseInput,
u"Google \x65E5\x672C\x8A9E\x5165\x529B "
u"IMM32 \x30E2\x30B8\x30E5\x30FC\x30EB")
IMPL_IS_IME_ACTIVE(Japanist2003, u"Japanist 2003")
#undef IMPL_IS_IME_ACTIVE
// static
bool
IMMHandler::IsActiveIMEInBlockList()
{
if (sIMEName.IsEmpty()) {
return false;
}
#ifdef _WIN64
// ATOK started to be TIP of TSF since 2011. Older than it, i.e., ATOK 2010
// and earlier have a lot of problems even for daily use. Perhaps, the
// reason is Win 8 has a lot of changes around IMM-IME support and TSF,
// and ATOK 2010 is released earlier than Win 8.
// ATOK 2006 crashes while converting a word with candidate window.
// ATOK 2007 doesn't paint and resize suggest window and candidate window
// correctly (showing white window or too big window).
// ATOK 2008 and ATOK 2009 crash when user just opens their open state.
// ATOK 2010 isn't installable newly on Win 7 or later, but we have a lot of
// crash reports.
if (IsWin8OrLater() &&
(IsATOK2006Active() || IsATOK2007Active() || IsATOK2008Active() ||
IsATOK2009Active() || IsATOK2010Active())) {
return true;
}
#endif // #ifdef _WIN64
return false;
}
// static
void
IMMHandler::EnsureHandlerInstance()
@ -289,23 +338,6 @@ IMMHandler::IsTopLevelWindowOfComposition(nsWindow* aWindow)
return WinUtils::GetTopLevelHWND(wnd, true) == aWindow->GetWindowHandle();
}
// static
bool
IMMHandler::IsJapanist2003Active()
{
return sIMEName.EqualsLiteral("Japanist 2003");
}
// static
bool
IMMHandler::IsGoogleJapaneseInputActive()
{
// NOTE: Even on Windows for en-US, the name of Google Japanese Input is
// written in Japanese.
return sIMEName.Equals(u"Google \x65E5\x672C\x8A9E\x5165\x529B "
u"IMM32 \x30E2\x30B8\x30E5\x30FC\x30EB");
}
// static
bool
IMMHandler::ShouldDrawCompositionStringOurselves()

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

@ -157,7 +157,26 @@ public:
static void DefaultProcOfPluginEvent(nsWindow* aWindow,
const NPEvent* aEvent);
static bool IsGoogleJapaneseInputActive();
#define DECL_IS_IME_ACTIVE(aReadableName) \
static bool Is ## aReadableName ## Active(); \
// Japanese IMEs
DECL_IS_IME_ACTIVE(ATOK2006)
DECL_IS_IME_ACTIVE(ATOK2007)
DECL_IS_IME_ACTIVE(ATOK2008)
DECL_IS_IME_ACTIVE(ATOK2009)
DECL_IS_IME_ACTIVE(ATOK2010)
DECL_IS_IME_ACTIVE(GoogleJapaneseInput)
DECL_IS_IME_ACTIVE(Japanist2003)
#undef DECL_IS_IME_ACTIVE
/**
* IsActiveIMEInBlockList() returns true if we know active keyboard layout's
* IME has some crash bugs or something which make some damage to us. When
* this returns true, IMC shouldn't be associated with any windows.
*/
static bool IsActiveIMEInBlockList();
protected:
static void EnsureHandlerInstance();
@ -166,8 +185,6 @@ protected:
static bool IsComposingOnPlugin();
static bool IsComposingWindow(nsWindow* aWindow);
static bool IsJapanist2003Active();
static bool ShouldDrawCompositionStringOurselves();
static bool IsVerticalWritingSupported();
// aWindow can be nullptr if it's called without receiving WM_INPUTLANGCHANGE.

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

@ -43,6 +43,7 @@ namespace widget {
nsWindow* IMEHandler::sFocusedWindow = nullptr;
InputContextAction::Cause IMEHandler::sLastContextActionCause =
InputContextAction::CAUSE_UNKNOWN;
bool IMEHandler::sForceDisableCurrentIMM_IME = false;
bool IMEHandler::sPluginHasFocus = false;
#ifdef NS_ENABLE_TSF
@ -82,6 +83,8 @@ IMEHandler::Initialize()
#endif // #ifdef NS_ENABLE_TSF
IMMHandler::Initialize();
sForceDisableCurrentIMM_IME = IMMHandler::IsActiveIMEInBlockList();
}
// static
@ -185,8 +188,23 @@ IMEHandler::ProcessMessage(nsWindow* aWindow, UINT aMessage,
}
#endif // #ifdef NS_ENABLE_TSF
return IMMHandler::ProcessMessage(aWindow, aMessage, aWParam, aLParam,
aResult);
bool keepGoing =
IMMHandler::ProcessMessage(aWindow, aMessage, aWParam, aLParam, aResult);
// If user changes active IME to an IME which is listed in our block list,
// we should disassociate IMC from the window for preventing the IME to work
// and crash.
if (aMessage == WM_INPUTLANGCHANGE) {
bool disableIME = IMMHandler::IsActiveIMEInBlockList();
if (disableIME != sForceDisableCurrentIMM_IME) {
bool enable =
!disableIME && WinUtils::IsIMEEnabled(aWindow->InputContextRef());
AssociateIMEContext(aWindow, enable);
sForceDisableCurrentIMM_IME = disableIME;
}
}
return keepGoing;
}
#ifdef NS_ENABLE_TSF
@ -421,7 +439,8 @@ IMEHandler::OnDestroyWindow(nsWindow* aWindow)
bool
IMEHandler::NeedsToAssociateIMC()
{
return !sAssociateIMCOnlyWhenIMM_IMEActive || !IsIMMActive();
return !sForceDisableCurrentIMM_IME &&
(!sAssociateIMCOnlyWhenIMM_IMEActive || !IsIMMActive());
}
#endif // #ifdef NS_ENABLE_TSF

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

@ -146,6 +146,7 @@ private:
static nsWindow* sFocusedWindow;
static InputContextAction::Cause sLastContextActionCause;
static bool sForceDisableCurrentIMM_IME;
static bool sPluginHasFocus;
#ifdef NS_ENABLE_TSF

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

@ -108,6 +108,8 @@ public:
virtual bool HandleAppCommandMsg(const MSG& aAppCommandMsg,
LRESULT *aRetValue);
const InputContext& InputContextRef() const { return mInputContext; }
protected:
virtual int32_t LogToPhys(double aValue) = 0;
void ChangedDPI();