Bug 1298169 - Use StaticRefPtr. r=masayuki, a=ritu
authorRandell Jesup <rjesup@jesup.org>
Tue, 20 Sep 2016 01:12:09 -0400
changeset 350347 0bf13f15679f5da3e1b0b27c5d322c7d8587906e
parent 350346 89618d3e83e0f2c7c8818b02f2cf3907a089675a
child 350348 1f49c2d12fdade360d98d4fc4efa78965ffd288b
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, ritu
bugs1298169
milestone50.0
Bug 1298169 - Use StaticRefPtr. r=masayuki, a=ritu
dom/events/IMEStateManager.cpp
dom/events/IMEStateManager.h
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -131,17 +131,17 @@ GetIMEStateSetOpenName(IMEState::Open aO
     case IMEState::CLOSED:
       return "CLOSED";
     default:
       return "illegal value";
   }
 }
 
 StaticRefPtr<nsIContent> IMEStateManager::sContent;
-nsPresContext* IMEStateManager::sPresContext = nullptr;
+StaticRefPtr<nsPresContext> IMEStateManager::sPresContext;
 nsIWidget* IMEStateManager::sFocusedIMEWidget = nullptr;
 nsIWidget* IMEStateManager::sActiveInputContextWidget = nullptr;
 StaticRefPtr<TabParent> IMEStateManager::sActiveTabParent;
 StaticRefPtr<IMEContentObserver> IMEStateManager::sActiveIMEContentObserver;
 TextCompositionArray* IMEStateManager::sTextCompositions = nullptr;
 bool IMEStateManager::sInstalledMenuKeyboardListener = false;
 bool IMEStateManager::sIsGettingNewIMEState = false;
 bool IMEStateManager::sCheckForIMEUnawareWebApps = false;
@@ -280,17 +280,17 @@ IMEStateManager::OnDestroyPresContext(ns
 
   if (aPresContext != sPresContext) {
     return NS_OK;
   }
 
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnDestroyPresContext(aPresContext=0x%p), "
      "sPresContext=0x%p, sContent=0x%p, sTextCompositions=0x%p",
-     aPresContext, sPresContext, sContent.get(), sTextCompositions));
+     aPresContext, sPresContext.get(), sContent.get(), sTextCompositions));
 
   DestroyIMEContentObserver();
 
   nsCOMPtr<nsIWidget> widget = sPresContext->GetRootWidget();
   if (widget) {
     IMEState newState = GetNewIMEState(sPresContext, nullptr);
     InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
                               InputContextAction::LOST_FOCUS);
@@ -336,17 +336,17 @@ IMEStateManager::OnRemoveContent(nsPresC
   if (!sPresContext || !sContent ||
       !nsContentUtils::ContentIsDescendantOf(sContent, aContent)) {
     return NS_OK;
   }
 
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnRemoveContent(aPresContext=0x%p, aContent=0x%p), "
      "sPresContext=0x%p, sContent=0x%p, sTextCompositions=0x%p",
-     aPresContext, aContent, sPresContext, sContent.get(), sTextCompositions));
+     aPresContext, aContent, sPresContext.get(), sContent.get(), sTextCompositions));
 
   DestroyIMEContentObserver();
 
   // Current IME transaction should commit
   nsCOMPtr<nsIWidget> widget = sPresContext->GetRootWidget();
   if (widget) {
     IMEState newState = GetNewIMEState(sPresContext, nullptr);
     InputContextAction action(InputContextAction::CAUSE_UNKNOWN,
@@ -386,17 +386,17 @@ IMEStateManager::OnChangeFocusInternal(n
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnChangeFocusInternal(aPresContext=0x%p, "
      "aContent=0x%p (TabParent=0x%p), aAction={ mCause=%s, mFocusChange=%s }), "
      "sPresContext=0x%p, sContent=0x%p, sActiveTabParent=0x%p, "
      "sActiveIMEContentObserver=0x%p, sInstalledMenuKeyboardListener=%s",
      aPresContext, aContent, newTabParent.get(),
      GetActionCauseName(aAction.mCause),
      GetActionFocusChangeName(aAction.mFocusChange),
-     sPresContext, sContent.get(), sActiveTabParent.get(),
+     sPresContext.get(), sContent.get(), sActiveTabParent.get(),
      sActiveIMEContentObserver.get(),
      GetBoolName(sInstalledMenuKeyboardListener)));
 
   bool focusActuallyChanging =
     (sContent != aContent || sPresContext != aPresContext ||
      sActiveTabParent != newTabParent);
 
   nsCOMPtr<nsIWidget> oldWidget =
@@ -562,17 +562,17 @@ IMEStateManager::OnInstalledMenuKeyboard
 bool
 IMEStateManager::OnMouseButtonEventInEditor(nsPresContext* aPresContext,
                                             nsIContent* aContent,
                                             nsIDOMMouseEvent* aMouseEvent)
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnMouseButtonEventInEditor(aPresContext=0x%p, "
      "aContent=0x%p, aMouseEvent=0x%p), sPresContext=0x%p, sContent=0x%p",
-     aPresContext, aContent, aMouseEvent, sPresContext, sContent.get()));
+     aPresContext, aContent, aMouseEvent, sPresContext.get(), sContent.get()));
 
   if (sPresContext != aPresContext || sContent != aContent) {
     MOZ_LOG(sISMLog, LogLevel::Debug,
       ("  OnMouseButtonEventInEditor(), "
        "the mouse event isn't fired on the editor managed by ISM"));
     return false;
   }
 
@@ -619,17 +619,17 @@ IMEStateManager::OnMouseButtonEventInEdi
 void
 IMEStateManager::OnClickInEditor(nsPresContext* aPresContext,
                                  nsIContent* aContent,
                                  nsIDOMMouseEvent* aMouseEvent)
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnClickInEditor(aPresContext=0x%p, aContent=0x%p, aMouseEvent=0x%p), "
      "sPresContext=0x%p, sContent=0x%p",
-     aPresContext, aContent, aMouseEvent, sPresContext, sContent.get()));
+     aPresContext, aContent, aMouseEvent, sPresContext.get(), sContent.get()));
 
   if (sPresContext != aPresContext || sContent != aContent) {
     MOZ_LOG(sISMLog, LogLevel::Debug,
       ("  OnClickInEditor(), "
        "the mouse event isn't fired on the editor managed by ISM"));
     return;
   }
 
@@ -681,17 +681,17 @@ IMEStateManager::OnClickInEditor(nsPresC
 void
 IMEStateManager::OnFocusInEditor(nsPresContext* aPresContext,
                                  nsIContent* aContent,
                                  nsIEditor* aEditor)
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("OnFocusInEditor(aPresContext=0x%p, aContent=0x%p, aEditor=0x%p), "
      "sPresContext=0x%p, sContent=0x%p, sActiveIMEContentObserver=0x%p",
-     aPresContext, aContent, aEditor, sPresContext, sContent.get(),
+     aPresContext, aContent, aEditor, sPresContext.get(), sContent.get(),
      sActiveIMEContentObserver.get()));
 
   if (sPresContext != aPresContext || sContent != aContent) {
     MOZ_LOG(sISMLog, LogLevel::Debug,
       ("  OnFocusInEditor(), "
        "an editor not managed by ISM gets focus"));
     return;
   }
@@ -761,17 +761,17 @@ IMEStateManager::UpdateIMEState(const IM
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("UpdateIMEState(aNewIMEState={ mEnabled=%s, "
      "mOpen=%s }, aContent=0x%p, aEditor=0x%p), "
      "sPresContext=0x%p, sContent=0x%p, sActiveIMEContentObserver=0x%p, "
      "sIsGettingNewIMEState=%s",
      GetIMEStateEnabledName(aNewIMEState.mEnabled),
      GetIMEStateSetOpenName(aNewIMEState.mOpen), aContent, aEditor,
-     sPresContext, sContent.get(), sActiveIMEContentObserver.get(),
+     sPresContext.get(), sContent.get(), sActiveIMEContentObserver.get(),
      GetBoolName(sIsGettingNewIMEState)));
 
   if (sIsGettingNewIMEState) {
     MOZ_LOG(sISMLog, LogLevel::Debug,
       ("  UpdateIMEState(), "
        "does nothing because of called while getting new IME state"));
     return;
   }
@@ -929,17 +929,17 @@ IMEStateManager::SetInputContextForChild
      "sActiveTabParent=0x%p",
      aTabParent, GetIMEStateEnabledName(aInputContext.mIMEState.mEnabled),
      GetIMEStateSetOpenName(aInputContext.mIMEState.mOpen),
      NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputType).get(),
      NS_ConvertUTF16toUTF8(aInputContext.mHTMLInputInputmode).get(),
      NS_ConvertUTF16toUTF8(aInputContext.mActionHint).get(),
      GetActionCauseName(aAction.mCause),
      GetActionFocusChangeName(aAction.mFocusChange),
-     sPresContext, sActiveTabParent.get()));
+     sPresContext.get(), sActiveTabParent.get()));
 
   if (aTabParent != sActiveTabParent) {
     MOZ_LOG(sISMLog, LogLevel::Error,
       ("  SetInputContextForChildProcess(), FAILED, "
        "because non-focused tab parent tries to set input context"));
     return;
   }
 
@@ -1560,17 +1560,17 @@ IMEStateManager::DestroyIMEContentObserv
 // static
 void
 IMEStateManager::CreateIMEContentObserver(nsIEditor* aEditor)
 {
   MOZ_LOG(sISMLog, LogLevel::Info,
     ("CreateIMEContentObserver(aEditor=0x%p), "
      "sPresContext=0x%p, sContent=0x%p, sActiveIMEContentObserver=0x%p, "
      "sActiveIMEContentObserver->IsManaging(sPresContext, sContent)=%s",
-     aEditor, sPresContext, sContent.get(), sActiveIMEContentObserver.get(),
+     aEditor, sPresContext.get(), sContent.get(), sActiveIMEContentObserver.get(),
      GetBoolName(sActiveIMEContentObserver ?
        sActiveIMEContentObserver->IsManaging(sPresContext, sContent) : false)));
 
   if (NS_WARN_IF(sActiveIMEContentObserver)) {
     MOZ_LOG(sISMLog, LogLevel::Error,
       ("  CreateIMEContentObserver(), FAILED due to "
        "there is already an active IMEContentObserver"));
     MOZ_ASSERT(sActiveIMEContentObserver->IsManaging(sPresContext, sContent));
--- a/dom/events/IMEStateManager.h
+++ b/dom/events/IMEStateManager.h
@@ -262,17 +262,17 @@ protected:
 
   static bool IsEditable(nsINode* node);
 
   static bool IsIMEObserverNeeded(const IMEState& aState);
 
   static nsIContent* GetRootContent(nsPresContext* aPresContext);
 
   static StaticRefPtr<nsIContent> sContent;
-  static nsPresContext* sPresContext;
+  static StaticRefPtr<nsPresContext> sPresContext;
   static nsIWidget* sFocusedIMEWidget;
   // sActiveInputContextWidget is the last widget whose SetInputContext() is
   // called.
   static nsIWidget* sActiveInputContextWidget;
   static StaticRefPtr<TabParent> sActiveTabParent;
   // sActiveIMEContentObserver points to the currently active
   // IMEContentObserver.  This is null if there is no focused editor.
   static StaticRefPtr<IMEContentObserver> sActiveIMEContentObserver;