Bug 806996 part.1 Remove nsTextStateManager::mDestroying r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 09 Nov 2012 17:40:39 +0900
changeset 112788 9f66e17df8cf82f9f327038ae156d51792aa66de
parent 112787 ed1c4f642584e18d5dc57d496d3fc33bb9e5714e
child 112789 db12b505016faffb1056bcbd177886f0a778eed3
push id17778
push usermasayuki@d-toybox.com
push dateFri, 09 Nov 2012 08:40:54 +0000
treeherdermozilla-inbound@927017027942 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs806996
milestone19.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 806996 part.1 Remove nsTextStateManager::mDestroying r=smaug
content/events/src/nsIMEStateManager.cpp
--- a/content/events/src/nsIMEStateManager.cpp
+++ b/content/events/src/nsIMEStateManager.cpp
@@ -63,17 +63,16 @@ public:
                 nsINode* aNode);
   void     Destroy(void);
   bool     IsManaging(nsPresContext* aPresContext, nsIContent* aContent);
 
   nsCOMPtr<nsIWidget>            mWidget;
   nsCOMPtr<nsISelection>         mSel;
   nsCOMPtr<nsIContent>           mRootContent;
   nsCOMPtr<nsINode>              mEditableNode;
-  bool                           mDestroying;
 
 private:
   void NotifyContentAdded(nsINode* aContainer, int32_t aStart, int32_t aEnd);
 };
 
 /******************************************************************/
 /* nsIMEStateManager                                              */
 /******************************************************************/
@@ -663,17 +662,16 @@ nsIMEStateManager::NotifyIME(Notificatio
   if (!widget) {
     return NS_ERROR_NOT_AVAILABLE;
   }
   return NotifyIME(aNotification, widget);
 }
 
 nsTextStateManager::nsTextStateManager()
 {
-  mDestroying = false;
 }
 
 nsresult
 nsTextStateManager::Init(nsIWidget* aWidget,
                          nsPresContext* aPresContext,
                          nsINode* aNode)
 {
   mWidget = aWidget;
@@ -750,19 +748,18 @@ nsTextStateManager::Destroy(void)
   mEditableNode = nullptr;
   mWidget = nullptr;
 }
 
 bool
 nsTextStateManager::IsManaging(nsPresContext* aPresContext,
                                   nsIContent* aContent)
 {
-  return !mDestroying &&
-    mEditableNode == nsIMEStateManager::GetRootEditableNode(aPresContext,
-                                                            aContent);
+  return mEditableNode == nsIMEStateManager::GetRootEditableNode(aPresContext,
+                                                                 aContent);
 }
 
 NS_IMPL_ISUPPORTS2(nsTextStateManager,
                    nsIMutationObserver,
                    nsISelectionListener)
 
 // Helper class, used for selection change notification
 class SelectionChangeEvent : public nsRunnable {
@@ -963,23 +960,23 @@ nsIMEStateManager::IsEditableIMEState(ns
       MOZ_NOT_REACHED("Unknown IME enable state");
       return false;
   }
 }
 
 void
 nsIMEStateManager::DestroyTextStateManager()
 {
-  if (!sTextStateObserver || sTextStateObserver->mDestroying) {
+  if (!sTextStateObserver) {
     return;
   }
 
-  sTextStateObserver->mDestroying = true;
-  sTextStateObserver->Destroy();
-  NS_RELEASE(sTextStateObserver);
+  nsRefPtr<nsTextStateManager> tsm;
+  tsm.swap(sTextStateObserver);
+  tsm->Destroy();
 }
 
 void
 nsIMEStateManager::CreateTextStateManager()
 {
   if (sTextStateObserver) {
     NS_WARNING("text state observer has been there already");
     MOZ_ASSERT(sTextStateObserver->IsManaging(sPresContext, sContent));
@@ -1013,20 +1010,18 @@ nsIMEStateManager::CreateTextStateManage
   sTextStateObserver = new nsTextStateManager();
   NS_ENSURE_TRUE_VOID(sTextStateObserver);
   NS_ADDREF(sTextStateObserver);
   rv = sTextStateObserver->Init(widget, sPresContext, editableNode);
   if (NS_SUCCEEDED(rv)) {
     return;
   }
 
-  sTextStateObserver->mDestroying = true;
-  sTextStateObserver->Destroy();
-  NS_RELEASE(sTextStateObserver);
   widget->OnIMEFocusChange(false);
+  DestroyTextStateManager();
 }
 
 nsresult
 nsIMEStateManager::GetFocusSelectionAndRoot(nsISelection** aSel,
                                             nsIContent** aRoot)
 {
   if (!sTextStateObserver || !sTextStateObserver->mEditableNode ||
       !sTextStateObserver->mSel)