Bug 1204523 part.2 Hack TSFTextStore::GetTextExt() for TS_E_NOLAYOUT issue of MS-IME for Japanese r=emk

This commit is contained in:
Masayuki Nakano 2015-09-18 09:58:17 +09:00
parent 26cadf342d
commit 206cb16099
3 changed files with 57 additions and 3 deletions

View File

@ -3165,10 +3165,12 @@ pref("intl.tsf.hack.easy_changjei.do_not_return_no_layout_error", true);
// Whether use previous character rect for the result of
// ITfContextView::GetTextExt() if the specified range is the first character
// of selected clause of composition string.
pref("intl.tsf.hack.ms_japanese_ime.do_not_return_no_layout_error_at_first_char", true);
pref("intl.tsf.hack.google_ja_input.do_not_return_no_layout_error_at_first_char", true);
// Whether use previous character rect for the result of
// ITfContextView::GetTextExt() if the specified range is the caret of
// composition string.
pref("intl.tsf.hack.ms_japanese_ime.do_not_return_no_layout_error_at_caret", true);
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.

View File

@ -1290,6 +1290,8 @@ 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::sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar = false;
bool TSFTextStore::sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret = false;
bool TSFTextStore::sHackQueryInsertForMSSimplifiedTIP = false;
@ -3514,9 +3516,45 @@ TSFTextStore::GetTextExt(TsViewCookie vcView,
if (mComposition.IsComposing() && mComposition.mStart < acpEnd &&
mLockedContent.IsLayoutChangedAfter(acpEnd)) {
const Selection& currentSel = CurrentSelection();
if ((sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar ||
sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret) &&
kSink->IsGoogleJapaneseInputActive()) {
if ((sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar ||
sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret) &&
kSink->IsMSJapaneseIMEActive()) {
// MS IME for Japanese doesn't support asynchronous handling at deciding
// its suggest list window position. The feature was implemented
// starting from Windows 8.
if (IsWin8OrLater()) {
// Basically, MS-IME tries to retrieve whole composition string rect
// at deciding suggest window immediately after unlocking the document.
// However, in e10s mode, the content hasn't updated yet in most cases.
// Therefore, if the first character at the retrieving range rect is
// available, we should use it as the result.
if (sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar &&
!mLockedContent.IsLayoutChangedAfter(acpStart) &&
acpStart < acpEnd) {
acpEnd = acpStart;
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::GetTextExt() hacked the offsets "
"of the first character of changing range of the composition "
"string for TIP acpStart=%d, acpEnd=%d",
this, acpStart, acpEnd));
}
// Although, the condition is not clear, MS-IME sometimes retrieves the
// caret rect immediately after modifying the composition string but
// before unlocking the document. In such case, we should return the
// nearest character rect.
else if (sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret &&
acpStart == acpEnd &&
currentSel.IsCollapsed() && currentSel.EndOffset() == acpEnd) {
acpEnd = acpStart = mLockedContent.MinOffsetOfLayoutChanged();
MOZ_LOG(sTextStoreLog, LogLevel::Debug,
("TSF: 0x%p TSFTextStore::GetTextExt() hacked the offsets "
"of the caret of the composition string for TIP acpStart=%d, "
"acpEnd=%d", this, acpStart, acpEnd));
}
}
} else if ((sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar ||
sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret) &&
kSink->IsGoogleJapaneseInputActive()) {
// Google Japanese Input doesn't handle ITfContextView::GetTextExt()
// properly due to the same bug of TSF mentioned above. Google Japanese
// Input calls this twice for the first character of changing range of
@ -5244,6 +5282,14 @@ TSFTextStore::Initialize()
sDoNotReturnNoLayoutErrorToEasyChangjei =
Preferences::GetBool(
"intl.tsf.hack.easy_changjei.do_not_return_no_layout_error", true);
sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar =
Preferences::GetBool(
"intl.tsf.hack.ms_japanese_ime."
"do_not_return_no_layout_error_at_first_char", true);
sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret =
Preferences::GetBool(
"intl.tsf.hack.ms_japanese_ime.do_not_return_no_layout_error_at_caret",
true);
sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar =
Preferences::GetBool(
"intl.tsf.hack.google_ja_input."
@ -5266,6 +5312,8 @@ TSFTextStore::Initialize()
"sCreateNativeCaretForATOK=%s, "
"sDoNotReturnNoLayoutErrorToFreeChangJie=%s, "
"sDoNotReturnNoLayoutErrorToEasyChangjei=%s, "
"sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar=%s, "
"sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret=%s, "
"sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar=%s, "
"sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret=%s",
sThreadMgr.get(), sClientId, sDisplayAttrMgr.get(),
@ -5273,6 +5321,8 @@ TSFTextStore::Initialize()
GetBoolName(sCreateNativeCaretForATOK),
GetBoolName(sDoNotReturnNoLayoutErrorToFreeChangJie),
GetBoolName(sDoNotReturnNoLayoutErrorToEasyChangjei),
GetBoolName(sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar),
GetBoolName(sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret),
GetBoolName(sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar),
GetBoolName(sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret)));
}

View File

@ -839,6 +839,8 @@ protected:
static bool sDoNotReturnNoLayoutErrorToMSTraditionalTIP;
static bool sDoNotReturnNoLayoutErrorToFreeChangJie;
static bool sDoNotReturnNoLayoutErrorToEasyChangjei;
static bool sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar;
static bool sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret;
static bool sDoNotReturnNoLayoutErrorToGoogleJaInputAtFirstChar;
static bool sDoNotReturnNoLayoutErrorToGoogleJaInputAtCaret;
static bool sHackQueryInsertForMSSimplifiedTIP;