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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_RootedDictionary_h__
8 #define mozilla_dom_RootedDictionary_h__
10 #include "mozilla/dom/Nullable.h"
13 namespace mozilla::dom
{
16 class MOZ_RAII RootedDictionary final
: public T
, private JS::CustomAutoRooter
{
18 template <typename CX
>
19 explicit RootedDictionary(const CX
& cx
) : T(), JS::CustomAutoRooter(cx
) {}
21 virtual void trace(JSTracer
* trc
) override
{ this->TraceDictionary(trc
); }
25 class MOZ_RAII NullableRootedDictionary final
: public Nullable
<T
>,
26 private JS::CustomAutoRooter
{
28 template <typename CX
>
29 explicit NullableRootedDictionary(const CX
& cx
)
30 : Nullable
<T
>(), JS::CustomAutoRooter(cx
) {}
32 virtual void trace(JSTracer
* trc
) override
{
33 if (!this->IsNull()) {
34 this->Value().TraceDictionary(trc
);
39 } // namespace mozilla::dom
41 #endif /* mozilla_dom_RootedDictionary_h__ */