Bug 1208969 - TSFTextStore shouldn't grant document lock after starting to destroy the context. r=emk, a=sylvestre
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 29 Sep 2015 17:08:42 +0900
changeset 297913 1c3b3f30e9f8925c632fc4d5be5f2af1a81b9e1b
parent 297912 989edb32c8e5bb2b5fec369075f7ab9e07545b87
child 297914 7e06450a934c166a81645b56b1818f6e024e6397
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk, sylvestre
bugs1208969
milestone43.0a2
Bug 1208969 - TSFTextStore shouldn't grant document lock after starting to destroy the context. r=emk, a=sylvestre
widget/windows/TSFTextStore.cpp
widget/windows/TSFTextStore.h
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1315,16 +1315,17 @@ TSFTextStore::TSFTextStore()
   , mRequestedAttrValues(false)
   , mIsRecordingActionsWithoutLock(false)
   , mPendingOnSelectionChange(false)
   , mPendingOnLayoutChange(false)
   , mPendingDestroy(false)
   , mDeferClearingLockedContent(false)
   , mNativeCaretIsCreated(false)
   , mDeferNotifyingTSF(false)
+  , mDestroyed(false)
 {
   for (int32_t i = 0; i < NUM_OF_SUPPORTED_ATTRS; i++) {
     mRequestedAttrs[i] = false;
   }
 
   // We hope that 5 or more actions don't occur at once.
   mPendingActions.SetCapacity(5);
 
@@ -1399,16 +1400,18 @@ bool
 TSFTextStore::Destroy()
 {
   MOZ_LOG(sTextStoreLog, LogLevel::Info,
     ("TSF: 0x%p TSFTextStore::Destroy(), mLock=%s, "
      "mComposition.IsComposing()=%s",
      this, GetLockFlagNameStr(mLock).get(),
      GetBoolName(mComposition.IsComposing())));
 
+  mDestroyed = true;
+
   if (mLock) {
     mPendingDestroy = true;
     return true;
   }
 
   // If there is composition, TSF keeps the composition even after the text
   // store destroyed.  So, we should clear the composition here.
   if (mComposition.IsComposing()) {
@@ -1560,25 +1563,31 @@ TSFTextStore::UnadviseSink(IUnknown* pun
 }
 
 STDMETHODIMP
 TSFTextStore::RequestLock(DWORD dwLockFlags,
                           HRESULT* phrSession)
 {
   MOZ_LOG(sTextStoreLog, LogLevel::Info,
     ("TSF: 0x%p TSFTextStore::RequestLock(dwLockFlags=%s, phrSession=0x%p), "
-     "mLock=%s", this, GetLockFlagNameStr(dwLockFlags).get(), phrSession,
-     GetLockFlagNameStr(mLock).get()));
+     "mLock=%s, mDestroyed=%s", this, GetLockFlagNameStr(dwLockFlags).get(),
+     phrSession, GetLockFlagNameStr(mLock).get(), GetBoolName(mDestroyed)));
 
   if (!mSink) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
       ("TSF: 0x%p   TSFTextStore::RequestLock() FAILED due to "
        "any sink not stored", this));
     return E_FAIL;
   }
+  if (mDestroyed) {
+    MOZ_LOG(sTextStoreLog, LogLevel::Error,
+      ("TSF: 0x%p   TSFTextStore::RequestLock() FAILED due to "
+       "being destroyed", this));
+    return E_FAIL;
+  }
   if (!phrSession) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
       ("TSF: 0x%p   TSFTextStore::RequestLock() FAILED due to "
        "null phrSession", this));
     return E_INVALIDARG;
   }
 
   if (!mLock) {
--- a/widget/windows/TSFTextStore.h
+++ b/widget/windows/TSFTextStore.h
@@ -800,16 +800,19 @@ protected:
   bool                         mNativeCaretIsCreated;
   // While the instance is dispatching events, the event may not be handled
   // synchronously in e10s mode.  So, in such case, in strictly speaking,
   // we shouldn't query layout information.  However, TS_E_NOLAYOUT bugs of
   // ITextStoreAPC::GetTextExt() blocks us to behave ideally.
   // For preventing it to be called, we should put off notifying TSF of
   // anything until layout information becomes available.
   bool                         mDeferNotifyingTSF;
+  // Immediately after a call of Destroy(), mDestroyed becomes true.  If this
+  // is true, the instance shouldn't grant any requests from the TIP anymore.
+  bool                         mDestroyed;
 
 
   // TSF thread manager object for the current application
   static StaticRefPtr<ITfThreadMgr> sThreadMgr;
   // sMessagePump is QI'ed from sThreadMgr
   static StaticRefPtr<ITfMessagePump> sMessagePump;
   // sKeystrokeMgr is QI'ed from sThreadMgr
   static StaticRefPtr<ITfKeystrokeMgr> sKeystrokeMgr;