Bug 1885602 - Part 2: Add a MozillaAccountMenuButton composable for the menu redesign...
[gecko.git] / dom / animation / PseudoElementHashEntry.h
blobb532d86105942dd3773423e07e9f528a92525bec
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_PseudoElementHashEntry_h
8 #define mozilla_PseudoElementHashEntry_h
10 #include "mozilla/dom/Element.h"
11 #include "mozilla/AnimationTarget.h"
12 #include "mozilla/HashFunctions.h"
13 #include "PLDHashTable.h"
15 namespace mozilla {
17 // A hash entry that uses a RefPtr<dom::Element>, PseudoStyleType pair
18 class PseudoElementHashEntry : public PLDHashEntryHdr {
19 public:
20 typedef NonOwningAnimationTarget KeyType;
21 typedef const NonOwningAnimationTarget* KeyTypePointer;
23 explicit PseudoElementHashEntry(KeyTypePointer aKey)
24 : mElement(aKey->mElement), mPseudoType(aKey->mPseudoType) {}
25 PseudoElementHashEntry(PseudoElementHashEntry&& aOther) = default;
27 ~PseudoElementHashEntry() = default;
29 KeyType GetKey() const { return {mElement, mPseudoType}; }
30 bool KeyEquals(KeyTypePointer aKey) const {
31 return mElement == aKey->mElement && mPseudoType == aKey->mPseudoType;
34 static KeyTypePointer KeyToPointer(KeyType& aKey) { return &aKey; }
35 static PLDHashNumber HashKey(KeyTypePointer aKey) {
36 if (!aKey) return 0;
38 // Convert the scoped enum into an integer while adding it to hash.
39 static_assert(sizeof(PseudoStyleType) == sizeof(uint8_t), "");
40 return mozilla::HashGeneric(aKey->mElement,
41 static_cast<uint8_t>(aKey->mPseudoType));
43 enum { ALLOW_MEMMOVE = true };
45 RefPtr<dom::Element> mElement;
46 PseudoStyleType mPseudoType;
49 } // namespace mozilla
51 #endif // mozilla_PseudoElementHashEntry_h