Bug 1379997 - part2: Remove "intl.tsf.hack.ms_japanese_ime.do_not_associate_imc_on_win10" pref completely r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 01 Aug 2017 00:13:57 +0900
changeset 618482 078f545e02d6bf63c07469a0ab72d7eb289ea48e
parent 618481 7688b1c11708132a87098ac9856d7443a51d0e4b
child 640088 3ead1847d94592312913e8f46354b8ebf1f7c9f7
push id71353
push usermasayuki@d-toybox.com
push dateMon, 31 Jul 2017 15:38:39 +0000
reviewersm_kato
bugs1379997
milestone56.0a1
Bug 1379997 - part2: Remove "intl.tsf.hack.ms_japanese_ime.do_not_associate_imc_on_win10" pref completely r?m_kato "intl.tsf.hack.ms_japanese_ime.do_not_associate_imc_on_win10" should be unnecessary anymore because it failed to avoid the crash of MS-IME for Japanese but causing other regression. Therefore, this patch removes it completely. MozReview-Commit-ID: 91jjxfIYReW
modules/libpref/init/all.js
widget/windows/WinIMEHandler.cpp
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -3829,23 +3829,16 @@ pref("intl.tsf.hack.free_chang_jie.do_no
 // 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
 pref("intl.tsf.hack.ms_traditional_chinese.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);
-// Whether default IMC should be associated with focused window when MS-IME
-// for Japanese on Win10 is active.  MS-IME for Japanese on Win10 has a crash
-// bug.  While restoring default IMC when MS-IME for Japanese is active,
-// it sometimes crashes after Creators Update.  This pref avoid the crash.
-// Note that making this true causes bug 1379997 and cannot prevent the crash
-// mentioned above.
-pref("intl.tsf.hack.ms_japanese_ime.do_not_associate_imc_on_win10", false);
 // 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);
 // 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()
--- a/widget/windows/WinIMEHandler.cpp
+++ b/widget/windows/WinIMEHandler.cpp
@@ -416,29 +416,17 @@ IMEHandler::OnDestroyWindow(nsWindow* aW
   AssociateIMEContext(aWindow, true);
 }
 
 #ifdef NS_ENABLE_TSF
 // static
 bool
 IMEHandler::NeedsToAssociateIMC()
 {
-  if (sAssociateIMCOnlyWhenIMM_IMEActive) {
-    return IsIMMActive();
-  }
-
-  // Even if IMC should be associated with focused widget with non-IMM-IME,
-  // we need to avoid crash bug of MS-IME for Japanese on Win10.  It crashes
-  // while we're associating default IME to a window when it's active.
-  static const bool sDoNotAssociateIMCWhenMSJapaneseIMEActiveOnWin10 =
-    IsWin10OrLater() &&
-    Preferences::GetBool(
-      "intl.tsf.hack.ms_japanese_ime.do_not_associate_imc_on_win10", true);
-  return !sDoNotAssociateIMCWhenMSJapaneseIMEActiveOnWin10 ||
-         !TSFTextStore::IsMSJapaneseIMEActive();
+  return !sAssociateIMCOnlyWhenIMM_IMEActive || !IsIMMActive();
 }
 #endif // #ifdef NS_ENABLE_TSF
 
 // static
 void
 IMEHandler::SetInputContext(nsWindow* aWindow,
                             InputContext& aInputContext,
                             const InputContextAction& aAction)
@@ -561,16 +549,23 @@ IMEHandler::OnKeyboardLayoutChanged()
   // observe active TIP change.  If you need to be notified of this, you
   // need to create TSFStaticSink::Observe() or something and call it
   // TSFStaticSink::EnsureInitActiveTIPKeyboard() forcibly.
 
   if (!sIsIMMEnabled || !IsTSFAvailable()) {
     return;
   }
 
+  // We don't need to do anything when sAssociateIMCOnlyWhenIMM_IMEActive is
+  // false because IMContext won't be associated/disassociated when changing
+  // active keyboard layout/IME.
+  if (!sAssociateIMCOnlyWhenIMM_IMEActive) {
+    return;
+  }
+
   // If there is no TSFTextStore which has focus, i.e., no editor has focus,
   // nothing to do here.
   nsWindowBase* windowBase = TSFTextStore::GetEnabledWindowBase();
   if (!windowBase) {
     return;
   }
 
   // If IME isn't available, nothing to do here.