/src/mozilla-central/dom/base/NodeUbiReporting.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 | | * vim: set ts=8 sts=4 et sw=4 tw=99: |
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/. */ |
6 | | |
7 | | #ifndef dom_NodeUbiReporting_h |
8 | | #define dom_NodeUbiReporting_h |
9 | | |
10 | | #include "nsINode.h" |
11 | | #include "js/UbiNode.h" |
12 | | |
13 | | /* |
14 | | * This file defines specializations of JS::ubi::Concrete for DOM nodes |
15 | | * so that the JS memory tools, which operate on the UbiNode graph, can |
16 | | * define subclasses of JS::ubi::Base that represent DOM nodes and |
17 | | * yield the outgoing edges in a DOM node graph for reporting. |
18 | | */ |
19 | | |
20 | | using mozilla::dom::Attr; |
21 | | |
22 | | namespace JS { |
23 | | namespace ubi { |
24 | | |
25 | | // The DOM node base class. |
26 | | // This is an abstract class and therefore does not require a concreteTypeName. |
27 | | template<> |
28 | | class Concrete<nsINode> : public Base |
29 | | { |
30 | | protected: |
31 | 0 | explicit Concrete(nsINode *ptr) : Base(ptr) { } |
32 | | |
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; |
37 | | |
38 | 0 | nsINode& get() const { return *static_cast<nsINode*>(ptr); } |
39 | 0 | CoarseType coarseType() const final { return CoarseType::DOMNode; } |
40 | | const char16_t* descriptiveTypeName() const override; |
41 | | }; |
42 | | |
43 | | template<> |
44 | | class Concrete<nsIContent> : public Concrete<nsINode> |
45 | | { |
46 | | protected: |
47 | 0 | explicit Concrete(nsIContent *ptr) : Concrete<nsINode>(ptr) { } |
48 | | |
49 | | public: |
50 | 0 | static void construct(void *storage, nsIContent *ptr) { new (storage) Concrete(ptr); } |
51 | 0 | const char16_t* typeName() const override { return concreteTypeName; }; |
52 | | static const char16_t concreteTypeName[]; |
53 | | }; |
54 | | |
55 | | template<> |
56 | | class Concrete<nsIDocument> : public Concrete<nsINode> |
57 | | { |
58 | | protected: |
59 | 0 | explicit Concrete(nsIDocument *ptr) : Concrete<nsINode>(ptr) { } |
60 | | |
61 | | public: |
62 | 0 | static void construct(void *storage, nsIDocument *ptr) { new (storage) Concrete(ptr); } |
63 | | Size size(mozilla::MallocSizeOf mallocSizeOf) const override; |
64 | | |
65 | 0 | nsIDocument& getDoc() const { return *static_cast<nsIDocument*>(ptr); } |
66 | 0 | const char16_t* typeName() const override { return concreteTypeName; }; |
67 | | static const char16_t concreteTypeName[]; |
68 | | }; |
69 | | |
70 | | template<> |
71 | | class Concrete<Attr> : public Concrete<nsINode> |
72 | | { |
73 | | protected: |
74 | 0 | explicit Concrete(Attr *ptr) : Concrete<nsINode>(ptr) { } |
75 | | |
76 | | public: |
77 | 0 | static void construct(void *storage, Attr *ptr) { new (storage) Concrete(ptr); } |
78 | 0 | const char16_t* typeName() const override { return concreteTypeName; }; |
79 | | static const char16_t concreteTypeName[]; |
80 | | }; |
81 | | |
82 | | } //namespace ubi |
83 | | } //namespace JS |
84 | | |
85 | | #endif |