Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM NodeFilter.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_NodeFilterBinding_h
4 : #define mozilla_dom_NodeFilterBinding_h
5 :
6 : #include "js/RootingAPI.h"
7 : #include "jspubtd.h"
8 : #include "mozilla/ErrorResult.h"
9 : #include "mozilla/dom/BindingDeclarations.h"
10 : #include "mozilla/dom/CallbackInterface.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/ToJSValue.h"
13 :
14 : class nsINode;
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : struct NativePropertyHooks;
20 : class NodeFilter;
21 : struct NodeFilterAtoms;
22 : class ProtoAndIfaceCache;
23 :
24 : } // namespace dom
25 : } // namespace mozilla
26 :
27 : namespace mozilla {
28 : namespace dom {
29 :
30 : namespace NodeFilterBinding {
31 :
32 : typedef mozilla::dom::NodeFilter NativeType;
33 :
34 : JSObject*
35 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
36 :
37 : // We declare this as an array so that retrieving a pointer to this
38 : // binding's property hooks only requires compile/link-time resolvable
39 : // address arithmetic. Declaring it as a pointer instead would require
40 : // doing a run-time load to fetch a pointer to this binding's property
41 : // hooks. And then structures which embedded a pointer to this structure
42 : // would require a run-time load for proper initialization, which would
43 : // then induce static constructors. Lots of static constructors.
44 : extern const NativePropertyHooks sNativePropertyHooks[];
45 :
46 : void
47 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
48 :
49 : JS::Handle<JSObject*>
50 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
51 :
52 : JSObject*
53 : GetConstructorObject(JSContext* aCx);
54 :
55 : } // namespace NodeFilterBinding
56 :
57 :
58 :
59 0 : class NodeFilter : public CallbackInterface
60 : {
61 : public:
62 : explicit inline NodeFilter(JSContext* aCx, JS::Handle<JSObject*> aCallback, nsIGlobalObject* aIncumbentGlobal)
63 : : CallbackInterface(aCx, aCallback, aIncumbentGlobal)
64 : {
65 : }
66 :
67 0 : explicit inline NodeFilter(JS::Handle<JSObject*> aCallback, const FastCallbackConstructor& )
68 0 : : CallbackInterface(aCallback, FastCallbackConstructor())
69 : {
70 0 : }
71 :
72 : explicit inline NodeFilter(JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
73 : : CallbackInterface(aCallback, aAsyncStack, aIncumbentGlobal)
74 : {
75 : }
76 :
77 : template <typename T>
78 : inline uint16_t
79 : AcceptNode(const T& thisVal, nsINode& node, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
80 : {
81 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
82 : if (!aExecutionReason) {
83 : aExecutionReason = "NodeFilter.acceptNode";
84 : }
85 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
86 : if (!s.GetContext()) {
87 : MOZ_ASSERT(aRv.Failed());
88 : return uint16_t(0);
89 : }
90 : JS::Rooted<JS::Value> thisValJS(s.GetContext());
91 : if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
92 : aRv.Throw(NS_ERROR_FAILURE);
93 : return uint16_t(0);
94 : }
95 : return AcceptNode(s.GetContext(), thisValJS, node, aRv);
96 : }
97 :
98 : inline uint16_t
99 0 : AcceptNode(nsINode& node, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JSCompartment* aCompartment = nullptr)
100 : {
101 0 : MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
102 0 : if (!aExecutionReason) {
103 0 : aExecutionReason = "NodeFilter.acceptNode";
104 : }
105 0 : CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aCompartment);
106 0 : if (!s.GetContext()) {
107 0 : MOZ_ASSERT(aRv.Failed());
108 0 : return uint16_t(0);
109 : }
110 0 : return AcceptNode(s.GetContext(), JS::UndefinedHandleValue, node, aRv);
111 : }
112 :
113 : template <typename T>
114 : inline uint16_t
115 : AcceptNode(const T& thisVal, nsINode& node, const char* aExecutionReason = nullptr)
116 : {
117 : IgnoredErrorResult rv;
118 : return AcceptNode(thisVal, node, rv, aExecutionReason);
119 : }
120 :
121 : inline uint16_t
122 : AcceptNode(nsINode& node, const char* aExecutionReason = nullptr)
123 : {
124 : IgnoredErrorResult rv;
125 : return AcceptNode(node, rv, aExecutionReason, eReportExceptions, nullptr);
126 : }
127 :
128 : inline bool
129 : operator==(const NodeFilter& aOther) const
130 : {
131 : return CallbackInterface::operator==(aOther);
132 : }
133 :
134 : private:
135 : uint16_t AcceptNode(JSContext* cx, JS::Handle<JS::Value> aThisVal, nsINode& node, ErrorResult& aRv);
136 :
137 : static bool
138 : InitIds(JSContext* cx, NodeFilterAtoms* atomsCache);
139 : };
140 :
141 :
142 : namespace binding_detail {
143 0 : class FastNodeFilter : public NodeFilter
144 : {
145 : public:
146 0 : explicit inline FastNodeFilter(JS::Handle<JSObject*> aCallback)
147 0 : : NodeFilter(aCallback, FastCallbackConstructor())
148 : {
149 0 : }
150 :
151 : inline void
152 0 : Trace(JSTracer* aTracer)
153 : {
154 0 : NodeFilter::Trace(aTracer);
155 0 : }
156 :
157 : inline void
158 0 : FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
159 : {
160 0 : NodeFilter::FinishSlowJSInitIfMoreThanOneOwner(aCx);
161 0 : }
162 : };
163 : } // namespace binding_detail
164 :
165 :
166 : } // namespace dom
167 : } // namespace mozilla
168 :
169 : #endif // mozilla_dom_NodeFilterBinding_h
|