Bug 1273510 part.3 We should not return TS_E_NOLAYOUT when ATOK decides its suggest window r?m_kato
Returing TS_E_NOLAYOUT while ATOK shows suggest window causes moving suggest window to odd position. This causes flicking the window. Therefore, we shouldn't return TS_E_NOLAYOUT in this case. In this case, ATOK queries whole rect of composition string. So, we can return TS_E_NOLAYOUT for other cases.
MozReview-Commit-ID: LBZQPFjqQgx
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3393,16 +3393,22 @@ pref("intl.tsf.enable", true);
// Support IMEs implemented with IMM in TSF mode.
pref("intl.tsf.support_imm", true);
// Enables/Disables hack for specific TIP.
// Whether creates native caret for ATOK or not.
pref("intl.tsf.hack.atok.create_native_caret", true);
+// Whether use available composition string rect for result of
+// ITfContextView::GetTextExt() even if the specified range is same as the
+// range of composition string but some character rects of them are not
+// available. Note that this is ignored if active ATOK is or older than 2016
+// and create_native_caret is true.
+pref("intl.tsf.hack.atok.do_not_return_no_layout_error_of_composition_string", true);
// Whether use composition start position for the result of
// ITfContextView::GetTextExt() if the specified range is larger than
// composition start offset.
// For Free ChangJie 2010
pref("intl.tsf.hack.free_chang_jie.do_not_return_no_layout_error", true);
// For Microsoft Pinyin and Microsoft Wubi
pref("intl.tsf.hack.ms_simplified_chinese.do_not_return_no_layout_error", true);
// For Microsoft ChangJie and Microsoft Quick
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1259,16 +1259,17 @@ StaticRefPtr<ITfDisplayAttributeMgr> TSF
StaticRefPtr<ITfCategoryMgr> TSFTextStore::sCategoryMgr;
StaticRefPtr<ITfDocumentMgr> TSFTextStore::sDisabledDocumentMgr;
StaticRefPtr<ITfContext> TSFTextStore::sDisabledContext;
StaticRefPtr<ITfInputProcessorProfiles> TSFTextStore::sInputProcessorProfiles;
StaticRefPtr<TSFTextStore> TSFTextStore::sEnabledTextStore;
DWORD TSFTextStore::sClientId = 0;
bool TSFTextStore::sCreateNativeCaretForLegacyATOK = false;
+bool TSFTextStore::sDoNotReturnNoLayoutErrorToATOKOfCompositionString = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToMSSimplifiedTIP = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToMSTraditionalTIP = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToFreeChangJie = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToEasyChangjei = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret = false;
bool TSFTextStore::sHackQueryInsertForMSSimplifiedTIP = false;
bool TSFTextStore::sHackQueryInsertForMSTraditionalTIP = false;
@@ -3737,16 +3738,32 @@ TSFTextStore::GetTextExt(TsViewCookie vc
return E_FAIL;
}
int32_t minOffsetOfLayoutChanged =
static_cast<int32_t>(mContentForTSF.MinOffsetOfLayoutChanged());
acpEnd = acpStart = std::max(minOffsetOfLayoutChanged - 1, 0);
dontReturnNoLayoutError = true;
}
}
+ // ATOK fails to handle TS_E_NOLAYOUT only when it decides the position of
+ // suggest window. In such case, ATOK tries to query rect of whole
+ // composition string.
+ // XXX For testing with legacy ATOK, we should hack it even if current ATOK
+ // refers native caret rect on windows whose window class is one of
+ // Mozilla window classes and we stop creating native caret for ATOK
+ // because creating native caret causes ATOK refers caret position
+ // when GetTextExt() returns TS_E_NOLAYOUT.
+ else if (sDoNotReturnNoLayoutErrorToATOKOfCompositionString &&
+ kSink->IsATOKActive() &&
+ (!kSink->IsATOKReferringNativeCaretActive() ||
+ !sCreateNativeCaretForLegacyATOK) &&
+ mComposition.mStart == acpStart &&
+ mComposition.EndOffset() == acpEnd) {
+ dontReturnNoLayoutError = true;
+ }
// Free ChangJie 2010 and Easy Changjei 1.0.12.0 doesn't handle
// ITfContextView::GetTextExt() properly. Prehaps, it's due to the bug of
// TSF. We need to check if this is necessary on Windows 10 before
// disabling this on Windows 10.
else if ((sDoNotReturnNoLayoutErrorToFreeChangJie &&
kSink->IsFreeChangJieActive()) ||
(sDoNotReturnNoLayoutErrorToEasyChangjei &&
kSink->IsEasyChangjeiActive())) {
@@ -5746,16 +5763,20 @@ TSFTextStore::Initialize()
sKeystrokeMgr = keystrokeMgr;
sDisplayAttrMgr = displayAttributeMgr;
sCategoryMgr = categoryMgr;
sDisabledDocumentMgr = disabledDocumentMgr;
sDisabledContext = disabledContext;
sCreateNativeCaretForLegacyATOK =
Preferences::GetBool("intl.tsf.hack.atok.create_native_caret", true);
+ sDoNotReturnNoLayoutErrorToATOKOfCompositionString =
+ Preferences::GetBool(
+ "intl.tsf.hack.atok.do_not_return_no_layout_error_of_composition_string",
+ true);
sDoNotReturnNoLayoutErrorToMSSimplifiedTIP =
Preferences::GetBool(
"intl.tsf.hack.ms_simplified_chinese.do_not_return_no_layout_error",
true);
sDoNotReturnNoLayoutErrorToMSTraditionalTIP =
Preferences::GetBool(
"intl.tsf.hack.ms_traditional_chinese.do_not_return_no_layout_error",
true);
@@ -5780,23 +5801,25 @@ TSFTextStore::Initialize()
Preferences::GetBool(
"intl.tsf.hack.ms_traditional_chinese.query_insert_result", true);
MOZ_LOG(sTextStoreLog, LogLevel::Info,
(" TSFTextStore::Initialize(), sThreadMgr=0x%p, "
"sClientId=0x%08X, sDisplayAttrMgr=0x%p, "
"sCategoryMgr=0x%p, sDisabledDocumentMgr=0x%p, sDisabledContext=%p, "
"sCreateNativeCaretForLegacyATOK=%s, "
+ "sDoNotReturnNoLayoutErrorToATOKOfCompositionString=%s, "
"sDoNotReturnNoLayoutErrorToFreeChangJie=%s, "
"sDoNotReturnNoLayoutErrorToEasyChangjei=%s, "
"sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar=%s, "
"sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret=%s",
sThreadMgr.get(), sClientId, sDisplayAttrMgr.get(),
sCategoryMgr.get(), sDisabledDocumentMgr.get(), sDisabledContext.get(),
GetBoolName(sCreateNativeCaretForLegacyATOK),
+ GetBoolName(sDoNotReturnNoLayoutErrorToATOKOfCompositionString),
GetBoolName(sDoNotReturnNoLayoutErrorToFreeChangJie),
GetBoolName(sDoNotReturnNoLayoutErrorToEasyChangjei),
GetBoolName(sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar),
GetBoolName(sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret)));
}
// static
void
--- a/widget/windows/TSFTextStore.h
+++ b/widget/windows/TSFTextStore.h
@@ -981,16 +981,17 @@ protected:
static StaticRefPtr<ITfInputProcessorProfiles> sInputProcessorProfiles;
// TSF client ID for the current application
static DWORD sClientId;
// Enables/Disables hack for specific TIP.
static bool sCreateNativeCaretForLegacyATOK;
+ static bool sDoNotReturnNoLayoutErrorToATOKOfCompositionString;
static bool sDoNotReturnNoLayoutErrorToMSSimplifiedTIP;
static bool sDoNotReturnNoLayoutErrorToMSTraditionalTIP;
static bool sDoNotReturnNoLayoutErrorToFreeChangJie;
static bool sDoNotReturnNoLayoutErrorToEasyChangjei;
static bool sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar;
static bool sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret;
static bool sHackQueryInsertForMSSimplifiedTIP;
static bool sHackQueryInsertForMSTraditionalTIP;