Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / ShadowParts.h
blobfe153054617c184c0517f8f41fe51566617c50cb
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_ShadowParts_h
8 #define mozilla_ShadowParts_h
10 #include "nsAtomHashKeys.h"
11 #include "nsTHashtable.h"
12 #include "nsClassHashtable.h"
13 #include "nsRefPtrHashtable.h"
14 #include "nsStringFwd.h"
16 namespace mozilla {
18 class ShadowParts final {
19 public:
20 ShadowParts(ShadowParts&&) = default;
21 ShadowParts(const ShadowParts&) = delete;
22 static ShadowParts Parse(const nsAString&);
24 using PartList = AutoTArray<RefPtr<nsAtom>, 1>;
26 PartList* Get(nsAtom* aName) const { return mMappings.Get(aName); }
28 nsAtom* GetReverse(nsAtom* aName) const {
29 return mReverseMappings.GetWeak(aName);
32 #ifdef DEBUG
33 void Dump() const;
34 #endif
36 private:
37 ShadowParts() = default;
39 // TODO(emilio): If the two hashtables take a lot of memory we should consider
40 // just using an nsTArray<Pair<>> or something.
41 nsClassHashtable<nsAtomHashKey, PartList> mMappings;
42 nsRefPtrHashtable<nsAtomHashKey, nsAtom> mReverseMappings;
45 } // namespace mozilla
47 #endif // mozilla_ShadowParts_h