Bug 1083067 part.10 nsGtkIMModule should use NS_INLINE_DECL_REFCOUNTING r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 10 Nov 2014 18:07:45 +0900
changeset 226179 1996f71aedd5058194c3ba70e15485e9dba07499
parent 226178 4188de0daebf7bc0079a43b6a20cfe998a0a0863
child 226180 36e3a60e3dc62b46367fd7578516f683486da095
push id36
push userdburns@mozilla.com
push dateMon, 10 Nov 2014 15:14:02 +0000
reviewersm_kato
bugs1083067
milestone36.0a1
Bug 1083067 part.10 nsGtkIMModule should use NS_INLINE_DECL_REFCOUNTING r=m_kato
widget/gtk/nsGtkIMModule.h
--- a/widget/gtk/nsGtkIMModule.h
+++ b/widget/gtk/nsGtkIMModule.h
@@ -22,45 +22,22 @@ class nsWindow;
 
 class nsGtkIMModule
 {
 protected:
     typedef mozilla::widget::InputContext InputContext;
     typedef mozilla::widget::InputContextAction InputContextAction;
 
 public:
-    nsrefcnt AddRef()
-    {
-        NS_PRECONDITION(int32_t(mRefCnt) >= 0, "mRefCnt is negative");
-        ++mRefCnt;
-        NS_LOG_ADDREF(this, mRefCnt, "nsGtkIMModule", sizeof(*this));
-        return mRefCnt;
-    }
-    nsrefcnt Release()
-    {
-        NS_PRECONDITION(mRefCnt != 0, "mRefCnt is alrady zero");
-        --mRefCnt;
-        NS_LOG_RELEASE(this, mRefCnt, "nsGtkIMModule");
-        if (mRefCnt == 0) {
-            mRefCnt = 1; /* stabilize */
-            delete this;
-            return 0;
-        }
-        return mRefCnt;
-    }
-
-protected:
-    nsAutoRefCnt mRefCnt;
-
-public:
     // aOwnerWindow is a pointer of the owner window.  When aOwnerWindow is
     // destroyed, the related IME contexts are released (i.e., IME cannot be
     // used with the instance after that).
     explicit nsGtkIMModule(nsWindow* aOwnerWindow);
-    ~nsGtkIMModule();
+
+    NS_INLINE_DECL_REFCOUNTING(nsGtkIMModule)
 
     // "Enabled" means the users can use all IMEs.
     // I.e., the focus is in the normal editors.
     bool IsEnabled() const;
 
     // OnFocusWindow is a notification that aWindow is going to be focused.
     void OnFocusWindow(nsWindow* aWindow);
     // OnBlurWindow is a notification that aWindow is going to be unfocused.
@@ -85,16 +62,18 @@ public:
     nsresult EndIMEComposition(nsWindow* aCaller);
     void SetInputContext(nsWindow* aCaller,
                          const InputContext* aContext,
                          const InputContextAction* aAction);
     InputContext GetInputContext();
     void OnUpdateComposition();
 
 protected:
+    ~nsGtkIMModule();
+
     // Owner of an instance of this class. This should be top level window.
     // The owner window must release the contexts when it's destroyed because
     // the IME contexts need the native window.  If OnDestroyWindow() is called
     // with the owner window, it'll release IME contexts.  Otherwise, it'll
     // just clean up any existing composition if it's related to the destroying
     // child window.
     nsWindow* mOwnerWindow;