Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / base / NodeUbiReporting.h
blobbe1c4e19c98f53dcf7b03bc57bd1ff6bc36f2e35
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 dom_NodeUbiReporting_h
8 #define dom_NodeUbiReporting_h
10 #include "Attr.h"
11 #include "Document.h"
12 #include "nsIContent.h"
13 #include "nsIContentInlines.h"
14 #include "nsINode.h"
15 #include "js/UbiNode.h"
18 * This file defines specializations of JS::ubi::Concrete for DOM nodes
19 * so that the JS memory tools, which operate on the UbiNode graph, can
20 * define subclasses of JS::ubi::Base that represent DOM nodes and
21 * yield the outgoing edges in a DOM node graph for reporting.
24 namespace JS::ubi {
26 // The DOM node base class.
27 // This is an abstract class and therefore does not require a concreteTypeName.
28 template <>
29 class Concrete<nsINode> : public Base {
30 protected:
31 explicit Concrete(nsINode* ptr) : Base(ptr) {}
33 public:
34 static void construct(void* storage, nsINode* ptr);
35 Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
36 js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override;
38 nsINode& get() const { return *static_cast<nsINode*>(ptr); }
39 CoarseType coarseType() const final { return CoarseType::DOMNode; }
40 const char16_t* descriptiveTypeName() const override;
43 template <>
44 class Concrete<nsIContent> : public Concrete<nsINode> {
45 protected:
46 explicit Concrete(nsIContent* ptr) : Concrete<nsINode>(ptr) {}
48 public:
49 static void construct(void* storage, nsIContent* ptr) {
50 new (storage) Concrete(ptr);
52 const char16_t* typeName() const override { return concreteTypeName; };
53 static const char16_t concreteTypeName[];
56 template <>
57 class Concrete<mozilla::dom::Document> : public Concrete<nsINode> {
58 protected:
59 explicit Concrete(mozilla::dom::Document* ptr) : Concrete<nsINode>(ptr) {}
61 public:
62 static void construct(void* storage, mozilla::dom::Document* ptr) {
63 new (storage) Concrete(ptr);
65 Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
67 mozilla::dom::Document& getDoc() const {
68 return *static_cast<mozilla::dom::Document*>(ptr);
70 const char16_t* typeName() const override { return concreteTypeName; };
71 static const char16_t concreteTypeName[];
74 template <>
75 class Concrete<mozilla::dom::Attr> : public Concrete<nsINode> {
76 protected:
77 explicit Concrete(mozilla::dom::Attr* ptr) : Concrete<nsINode>(ptr) {}
79 public:
80 static void construct(void* storage, mozilla::dom::Attr* ptr) {
81 new (storage) Concrete(ptr);
83 const char16_t* typeName() const override { return concreteTypeName; };
84 static const char16_t concreteTypeName[];
87 } // namespace JS::ubi
89 #endif