diff --git a/image/src/SurfaceCache.cpp b/image/src/SurfaceCache.cpp index 0b8f0bcc90da..d450d32326ca 100644 --- a/image/src/SurfaceCache.cpp +++ b/image/src/SurfaceCache.cpp @@ -33,32 +33,6 @@ using std::max; using std::min; using mozilla::gfx::DrawTarget; -/** - * Hashtable key class to use with objects for which Hash() and operator==() - * are defined. - * XXX(seth): This will get moved to xpcom/glue/nsHashKeys.h in a followup bug. - */ -template -class nsGenericHashKey : public PLDHashEntryHdr -{ -public: - typedef const T& KeyType; - typedef const T* KeyTypePointer; - - nsGenericHashKey(KeyTypePointer aKey) : mKey(*aKey) { } - nsGenericHashKey(const nsGenericHashKey& aOther) : mKey(aOther.mKey) { } - - KeyType GetKey() const { return mKey; } - bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mKey; } - - static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } - static PLDHashNumber HashKey(KeyTypePointer aKey) { return aKey->Hash(); } - enum { ALLOW_MEMMOVE = true }; - -private: - T mKey; -}; - namespace mozilla { namespace image { diff --git a/xpcom/glue/nsHashKeys.h b/xpcom/glue/nsHashKeys.h index 9fb2a2335525..89949558974a 100644 --- a/xpcom/glue/nsHashKeys.h +++ b/xpcom/glue/nsHashKeys.h @@ -62,6 +62,7 @@ HashString(const nsACString& aStr) * nsCharPtrHashKey * nsUnicharPtrHashKey * nsHashableHashKey + * nsGenericHashKey */ /** @@ -585,4 +586,29 @@ private: nsCOMPtr mKey; }; +/** + * Hashtable key class to use with objects for which Hash() and operator==() + * are defined. + */ +template +class nsGenericHashKey : public PLDHashEntryHdr +{ +public: + typedef const T& KeyType; + typedef const T* KeyTypePointer; + + nsGenericHashKey(KeyTypePointer aKey) : mKey(*aKey) { } + nsGenericHashKey(const nsGenericHashKey& aOther) : mKey(aOther.mKey) { } + + KeyType GetKey() const { return mKey; } + bool KeyEquals(KeyTypePointer aKey) const { return *aKey == mKey; } + + static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; } + static PLDHashNumber HashKey(KeyTypePointer aKey) { return aKey->Hash(); } + enum { ALLOW_MEMMOVE = true }; + +private: + T mKey; +}; + #endif // nsTHashKeys_h__