Bug 1199997 TSFTextStore::QueryInsert() should return specified range if the TIP is one of buggy Chinese TIPs of Microsoft r=emk

This commit is contained in:
Masayuki Nakano 2015-09-04 20:55:09 +09:00
parent 4e251405fd
commit b34b550faa
3 changed files with 36 additions and 2 deletions

View File

@ -3164,6 +3164,15 @@ pref("intl.tsf.hack.google_ja_input.do_not_return_no_layout_error_at_first_char"
// ITfContextView::GetTextExt() if the specified range is the caret of
// composition string.
pref("intl.tsf.hack.google_ja_input.do_not_return_no_layout_error_at_caret", true);
// Whether hack ITextStoreACP::QueryInsert() or not. The method should return
// new selection after specified length text is inserted at specified range.
// However, Microsoft's some Chinese TIPs expect that the result is same as
// specified range. If following prefs are true, ITextStoreACP::QueryInsert()
// returns specified range only when one of the TIPs is active.
// For Microsoft Pinyin and Microsoft Wubi
pref("intl.tsf.hack.ms_simplified_chinese.query_insert_result", true);
// For Microsoft ChangJie and Microsoft Quick
pref("intl.tsf.hack.ms_traditional_chinese.query_insert_result", true);
#endif
// If composition_font is set, Gecko sets the font to IME. IME may use

View File

@ -1287,6 +1287,8 @@ bool TSFTextStore::sDoNotReturnNoLayoutErrorToFreeChangJie = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToEasyChangjei = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret = false;
bool TSFTextStore::sHackQueryInsertForMSSimplifiedTIP = false;
bool TSFTextStore::sHackQueryInsertForMSTraditionalTIP = false;
#define TEXTSTORE_DEFAULT_VIEW (1)
@ -1936,8 +1938,23 @@ TSFTextStore::QueryInsert(LONG acpTestStart,
// XXX need to adjust to cluster boundary
// Assume we are given good offsets for now
*pacpResultStart = acpTestStart;
*pacpResultEnd = acpTestStart + cch;
const TSFStaticSink* kSink = TSFStaticSink::GetInstance();
if (IsWin8OrLater() && !mComposition.IsComposing() &&
((sHackQueryInsertForMSTraditionalTIP &&
(kSink->IsMSChangJieActive() || kSink->IsMSQuickQuickActive())) ||
(sHackQueryInsertForMSSimplifiedTIP &&
(kSink->IsMSPinyinActive() || kSink->IsMSWubiActive())))) {
MOZ_LOG(sTextStoreLog, LogLevel::Warning,
("TSF: 0x%p TSFTextStore::QueryInsert() WARNING using different "
"result for the TIP", this));
// Chinese TIPs of Microsoft assume that QueryInsert() returns selected
// range which should be removed.
*pacpResultStart = acpTestStart;
*pacpResultEnd = acpTestEnd;
} else {
*pacpResultStart = acpTestStart;
*pacpResultEnd = acpTestStart + cch;
}
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: 0x%p TSFTextStore::QueryInsert() succeeded: "
@ -5232,6 +5249,12 @@ TSFTextStore::Initialize()
Preferences::GetBool(
"intl.tsf.hack.google_ja_input.do_not_return_no_layout_error_at_caret",
true);
sHackQueryInsertForMSSimplifiedTIP =
Preferences::GetBool(
"intl.tsf.hack.ms_simplified_chinese.query_insert_result", true);
sHackQueryInsertForMSTraditionalTIP =
Preferences::GetBool(
"intl.tsf.hack.ms_traditional_chinese.query_insert_result", true);
MOZ_LOG(sTextStoreLog, LogLevel::Info,
("TSF: TSFTextStore::Initialize(), sThreadMgr=0x%p, "

View File

@ -841,6 +841,8 @@ protected:
static bool sDoNotReturnNoLayoutErrorToEasyChangjei;
static bool sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar;
static bool sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret;
static bool sHackQueryInsertForMSSimplifiedTIP;
static bool sHackQueryInsertForMSTraditionalTIP;
};
} // namespace widget