diff --git a/dom/animation/AnimationTarget.h b/dom/animation/AnimationTarget.h index 4e99d63a4d31..e921f25c3a14 100644 --- a/dom/animation/AnimationTarget.h +++ b/dom/animation/AnimationTarget.h @@ -7,7 +7,9 @@ #ifndef mozilla_AnimationTarget_h #define mozilla_AnimationTarget_h -#include "mozilla/Attributes.h" // For MOZ_NON_OWNING_REF +#include "mozilla/Attributes.h" // For MOZ_NON_OWNING_REF +#include "mozilla/HashFunctions.h" // For HashNumber, AddToHash +#include "mozilla/HashTable.h" // For DefaultHasher, PointerHasher #include "mozilla/Maybe.h" #include "mozilla/RefPtr.h" #include "nsCSSPseudoElements.h" @@ -69,6 +71,26 @@ inline void ImplCycleCollectionUnlink(Maybe& aTarget) { } } +// A DefaultHasher specialization for OwningAnimationTarget. +template <> +struct DefaultHasher { + using Key = OwningAnimationTarget; + using Lookup = OwningAnimationTarget; + using PtrHasher = PointerHasher; + + static HashNumber hash(const Lookup& aLookup) { + return AddToHash(PtrHasher::hash(aLookup.mElement.get()), + static_cast(aLookup.mPseudoType)); + } + + static bool match(const Key& aKey, const Lookup& aLookup) { + return PtrHasher::match(aKey.mElement.get(), aLookup.mElement.get()) && + aKey.mPseudoType == aLookup.mPseudoType; + } + + static void rekey(Key& aKey, Key&& aNewKey) { aKey = std::move(aNewKey); } +}; + } // namespace mozilla #endif // mozilla_AnimationTarget_h