Bug 1368318 Call TSFTextStore::ThinksHavingFocus() before clearing sEnabledTextStore since the method refers it r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 29 May 2017 12:18:11 +0900
changeset 585882 9585de3f94e4c82dfb207333fce84cd71497c10c
parent 585803 4541134e973a6bd5e667a603e844854c8e5361da
child 585883 8b79ae91a32adeee0946b45ba7c63748eface9db
push id61218
push usermasayuki@d-toybox.com
push dateMon, 29 May 2017 08:09:56 +0000
reviewersm_kato
bugs1368318
milestone55.0a1
Bug 1368318 Call TSFTextStore::ThinksHavingFocus() before clearing sEnabledTextStore since the method refers it r?m_kato MozReview-Commit-ID: GdALZTWioNW
widget/windows/TSFTextStore.cpp
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -4976,32 +4976,33 @@ TSFTextStore::OnFocusChange(bool aGotFoc
      GetInputContextString(aContext).get(),
      sThreadMgr.get(), sEnabledTextStore.get()));
 
   if (NS_WARN_IF(!IsInTSFMode())) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   RefPtr<ITfDocumentMgr> prevFocusedDocumentMgr;
+  bool hasFocus = ThinksHavingFocus();
   RefPtr<TSFTextStore> oldTextStore = sEnabledTextStore.forget();
 
-  // If currently sEnableTextStore has focus, notifies TSF of losing focus.
-  if (ThinksHavingFocus()) {
+  // If currently oldTextStore still has focus, notifies TSF of losing focus.
+  if (hasFocus) {
     RefPtr<ITfThreadMgr> threadMgr = sThreadMgr;
     DebugOnly<HRESULT> hr =
       threadMgr->AssociateFocus(
         oldTextStore->mWidget->GetWindowHandle(),
         nullptr, getter_AddRefs(prevFocusedDocumentMgr));
     NS_ASSERTION(SUCCEEDED(hr), "Disassociating focus failed");
     NS_ASSERTION(prevFocusedDocumentMgr == oldTextStore->mDocumentMgr,
                  "different documentMgr has been associated with the window");
   }
 
-  // If there is sEnabledTextStore, we don't use it in the new focused editor.
-  // Release it now.
+  // Even if there was a focused TextStore, we won't use it with new focused
+  // editor.  So, release it now.
   if (oldTextStore) {
     oldTextStore->Destroy();
   }
 
   if (NS_WARN_IF(!sThreadMgr)) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
       ("  TSFTextStore::OnFocusChange() FAILED, due to "
        "sThreadMgr being destroyed during calling "