Bug 1294161 - Add operator== overloads for comparing HandlRefPtrs to their raw Handles. r=bholley a=ritu
authorCameron McCormack <cam@mcc.id.au>
Fri, 26 Aug 2016 14:02:45 +0800
changeset 332956 aaa878146a67eb7af1d07652e79f913a92339971
parent 332955 7034b14c71ba4cfa4ffa1e4160d449e0e816d734
child 332957 d46712bc4455eb064447f7a2835b7452772c878f
push id9959
push userkwierso@gmail.com
push dateTue, 30 Aug 2016 17:44:34 +0000
treeherdermozilla-aurora@5ed3f227fe0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, ritu
bugs1294161
milestone50.0a2
Bug 1294161 - Add operator== overloads for comparing HandlRefPtrs to their raw Handles. r=bholley a=ritu MozReview-Commit-ID: jTQZXyNbqM
layout/style/HandleRefPtr.h
--- a/layout/style/HandleRefPtr.h
+++ b/layout/style/HandleRefPtr.h
@@ -59,26 +59,16 @@ public:
   ~HandleRefPtr() { assign(nullptr); }
 
   explicit operator bool() const { return !!mHandle; }
   bool operator!() const { return !mHandle; }
 
   operator T() const { return mHandle; }
   T operator->() const { return mHandle; }
 
-  bool operator==(const HandleRefPtr<T>& aOther) const
-  {
-    return mHandle == aOther.mHandle;
-  }
-
-  bool operator!=(const HandleRefPtr<T>& aOther) const
-  {
-    return !(*this == aOther);
-  }
-
   void swap(HandleRefPtr<T>& aOther)
   {
     std::swap(mHandle, aOther.mHandle);
   }
 
 private:
   void assign(T aPtr)
   {
@@ -97,11 +87,47 @@ private:
     if (aPtr) {
       aPtr->Release();
     }
   }
 
   T mHandle;
 };
 
+template<typename T>
+inline bool operator==(const HandleRefPtr<T>& aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return static_cast<T>(aLHS) == static_cast<T>(aRHS);
+}
+
+template<typename T>
+inline bool operator==(const HandleRefPtr<T>& aLHS, T aRHS)
+{
+  return static_cast<T>(aLHS) == aRHS;
+}
+
+template<typename T>
+inline bool operator==(T aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return aLHS == static_cast<T>(aRHS);
+}
+
+template<typename T>
+inline bool operator!=(const HandleRefPtr<T>& aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+template<typename T>
+inline bool operator!=(const HandleRefPtr<T>& aLHS, T aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
+template<typename T>
+inline bool operator!=(T aLHS, const HandleRefPtr<T>& aRHS)
+{
+  return !(aLHS == aRHS);
+}
+
 } // namespace mozilla
 
 #endif // mozilla_HandleRefPtr_h