mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1253476 - Add DefaultHasher implementation for OwningAnimationTarget; r=njn
Later in this patch series we will add a HashSet<OwningAnimationTarget> member to EffectCompositor. This patch provides the necessary definitions to support that. Differential Revision: https://phabricator.services.mozilla.com/D30320 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
25c05a66db
commit
c7c4f6d875
@ -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<OwningAnimationTarget>& aTarget) {
|
||||
}
|
||||
}
|
||||
|
||||
// A DefaultHasher specialization for OwningAnimationTarget.
|
||||
template <>
|
||||
struct DefaultHasher<OwningAnimationTarget> {
|
||||
using Key = OwningAnimationTarget;
|
||||
using Lookup = OwningAnimationTarget;
|
||||
using PtrHasher = PointerHasher<dom::Element*>;
|
||||
|
||||
static HashNumber hash(const Lookup& aLookup) {
|
||||
return AddToHash(PtrHasher::hash(aLookup.mElement.get()),
|
||||
static_cast<uint8_t>(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
|
||||
|
Loading…
Reference in New Issue
Block a user