Bug 1187583 part.2 Apply the TS_E_NOLAYOUT hacks for MS-IME to MS Office IME 2010 for Japanese too r=emk
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 19 Sep 2015 22:22:40 +0900
changeset 296024 dec41eaf2fedc00d0fe809e83fe2985c17426371
parent 296023 255824a521c1f7b7cb2b01a6302cdb95523cfb89
child 296025 d29fef133d8a0960a57031f71b299fa58aa4d74d
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1187583
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1187583 part.2 Apply the TS_E_NOLAYOUT hacks for MS-IME to MS Office IME 2010 for Japanese too r=emk
widget/windows/TSFTextStore.cpp
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -3518,43 +3518,52 @@ TSFTextStore::GetTextExt(TsViewCookie vc
   // NOTE: TSF (at least on Win 8.1) doesn't return TS_E_NOLAYOUT to the
   // caller even if we return it.  It's converted to just E_FAIL.
   // However, this is fixed on Win 10.
 
   const TSFStaticSink* kSink = TSFStaticSink::GetInstance();
   if (mComposition.IsComposing() && mComposition.mStart < acpEnd &&
       mLockedContent.IsLayoutChangedAfter(acpEnd)) {
     const Selection& currentSel = CurrentSelection();
-    if ((sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtFirstChar ||
-         sDoNotReturnNoLayoutErrorToMSJapaneseIMEAtCaret) &&
-        kSink->IsMSJapaneseIMEActive()) {
+    // The bug of Microsoft Office IME 2010 for Japanese is similar to
+    // MS-IME for Win 8.1 and Win 10.  Newer version of MS Office IME is not
+    // released yet.  So, we can hack it without prefs  because there must be
+    // no developers who want to disable this hack for tests.
+    const bool kIsMSOfficeJapaneseIME2010 =
+      kSink->IsMSOfficeJapaneseIME2010Active();
+    if (kIsMSOfficeJapaneseIME2010 ||
+        ((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()) {
+      if (IsWin8OrLater() || kIsMSOfficeJapaneseIME2010) {
         // 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 &&
+        if ((kIsMSOfficeJapaneseIME2010 ||
+             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 &&
+        else if ((kIsMSOfficeJapaneseIME2010 ||
+                  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));
         }