Bug 1842773 - Part 18: Update TypedArray length, byteLength, and byteOffset accesses...
[gecko.git] / dom / bindings / RootedDictionary.h
blob24fb859ae39b00c41eef083ab26745790e820837
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"
11 #include "jsapi.h"
13 namespace mozilla::dom {
15 template <typename T>
16 class MOZ_RAII RootedDictionary final : public T, private JS::CustomAutoRooter {
17 public:
18 template <typename CX>
19 explicit RootedDictionary(const CX& cx) : T(), JS::CustomAutoRooter(cx) {}
21 virtual void trace(JSTracer* trc) override { this->TraceDictionary(trc); }
24 template <typename T>
25 class MOZ_RAII NullableRootedDictionary final : public Nullable<T>,
26 private JS::CustomAutoRooter {
27 public:
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__ */