/work/obj-fuzz/dist/include/mozilla/dom/HTMLAllCollectionBinding.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM HTMLAllCollection.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #ifndef mozilla_dom_HTMLAllCollectionBinding_h |
4 | | #define mozilla_dom_HTMLAllCollectionBinding_h |
5 | | |
6 | | #include "GeckoProfiler.h" |
7 | | #include "js/RootingAPI.h" |
8 | | #include "jspubtd.h" |
9 | | #include "mozilla/ErrorResult.h" |
10 | | #include "mozilla/dom/BindingDeclarations.h" |
11 | | #include "mozilla/dom/FakeString.h" |
12 | | #include "mozilla/dom/Nullable.h" |
13 | | #include "mozilla/dom/PrototypeList.h" |
14 | | #include "mozilla/dom/UnionMember.h" |
15 | | |
16 | | class nsIHTMLCollection; |
17 | | class nsINode; |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | |
22 | | class HTMLAllCollection; |
23 | | struct HTMLAllCollectionAtoms; |
24 | | struct NativePropertyHooks; |
25 | | class OwningNodeOrHTMLCollection; |
26 | | class ProtoAndIfaceCache; |
27 | | |
28 | | } // namespace dom |
29 | | } // namespace mozilla |
30 | | |
31 | | namespace mozilla { |
32 | | namespace dom { |
33 | | |
34 | | void |
35 | | ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningNodeOrHTMLCollection& aUnion, const char* aName, uint32_t aFlags = 0); |
36 | | |
37 | | |
38 | | void |
39 | | ImplCycleCollectionUnlink(OwningNodeOrHTMLCollection& aUnion); |
40 | | |
41 | | |
42 | | class NodeOrHTMLCollection |
43 | | { |
44 | | friend class NodeOrHTMLCollectionArgument; |
45 | | enum Type |
46 | | { |
47 | | eUninitialized, |
48 | | eNode, |
49 | | eHTMLCollection |
50 | | }; |
51 | | |
52 | | union Value |
53 | | { |
54 | | UnionMember<NonNull<nsINode> > mNode; |
55 | | UnionMember<NonNull<nsIHTMLCollection> > mHTMLCollection; |
56 | | |
57 | | }; |
58 | | |
59 | | Type mType; |
60 | | Value mValue; |
61 | | |
62 | | NodeOrHTMLCollection(const NodeOrHTMLCollection&) = delete; |
63 | | NodeOrHTMLCollection& operator=(const NodeOrHTMLCollection&) = delete; |
64 | | public: |
65 | | explicit inline NodeOrHTMLCollection() |
66 | | : mType(eUninitialized) |
67 | 0 | { |
68 | 0 | } |
69 | | |
70 | | inline ~NodeOrHTMLCollection() |
71 | 0 | { |
72 | 0 | Uninit(); |
73 | 0 | } |
74 | | |
75 | | inline NonNull<nsINode>& |
76 | | RawSetAsNode() |
77 | 0 | { |
78 | 0 | if (mType == eNode) { |
79 | 0 | return mValue.mNode.Value(); |
80 | 0 | } |
81 | 0 | MOZ_ASSERT(mType == eUninitialized); |
82 | 0 | mType = eNode; |
83 | 0 | return mValue.mNode.SetValue(); |
84 | 0 | } |
85 | | |
86 | | inline NonNull<nsINode>& |
87 | | SetAsNode() |
88 | 0 | { |
89 | 0 | if (mType == eNode) { |
90 | 0 | return mValue.mNode.Value(); |
91 | 0 | } |
92 | 0 | Uninit(); |
93 | 0 | mType = eNode; |
94 | 0 | return mValue.mNode.SetValue(); |
95 | 0 | } |
96 | | |
97 | | inline bool |
98 | | IsNode() const |
99 | 0 | { |
100 | 0 | return mType == eNode; |
101 | 0 | } |
102 | | |
103 | | inline NonNull<nsINode>& |
104 | | GetAsNode() |
105 | 0 | { |
106 | 0 | MOZ_ASSERT(IsNode(), "Wrong type!"); |
107 | 0 | return mValue.mNode.Value(); |
108 | 0 | } |
109 | | |
110 | | inline nsINode& |
111 | | GetAsNode() const |
112 | 0 | { |
113 | 0 | MOZ_ASSERT(IsNode(), "Wrong type!"); |
114 | 0 | return mValue.mNode.Value(); |
115 | 0 | } |
116 | | |
117 | | inline NonNull<nsIHTMLCollection>& |
118 | | RawSetAsHTMLCollection() |
119 | 0 | { |
120 | 0 | if (mType == eHTMLCollection) { |
121 | 0 | return mValue.mHTMLCollection.Value(); |
122 | 0 | } |
123 | 0 | MOZ_ASSERT(mType == eUninitialized); |
124 | 0 | mType = eHTMLCollection; |
125 | 0 | return mValue.mHTMLCollection.SetValue(); |
126 | 0 | } |
127 | | |
128 | | inline NonNull<nsIHTMLCollection>& |
129 | | SetAsHTMLCollection() |
130 | 0 | { |
131 | 0 | if (mType == eHTMLCollection) { |
132 | 0 | return mValue.mHTMLCollection.Value(); |
133 | 0 | } |
134 | 0 | Uninit(); |
135 | 0 | mType = eHTMLCollection; |
136 | 0 | return mValue.mHTMLCollection.SetValue(); |
137 | 0 | } |
138 | | |
139 | | inline bool |
140 | | IsHTMLCollection() const |
141 | 0 | { |
142 | 0 | return mType == eHTMLCollection; |
143 | 0 | } |
144 | | |
145 | | inline NonNull<nsIHTMLCollection>& |
146 | | GetAsHTMLCollection() |
147 | 0 | { |
148 | 0 | MOZ_ASSERT(IsHTMLCollection(), "Wrong type!"); |
149 | 0 | return mValue.mHTMLCollection.Value(); |
150 | 0 | } |
151 | | |
152 | | inline nsIHTMLCollection& |
153 | | GetAsHTMLCollection() const |
154 | 0 | { |
155 | 0 | MOZ_ASSERT(IsHTMLCollection(), "Wrong type!"); |
156 | 0 | return mValue.mHTMLCollection.Value(); |
157 | 0 | } |
158 | | |
159 | | inline void |
160 | | Uninit() |
161 | 0 | { |
162 | 0 | switch (mType) { |
163 | 0 | case eUninitialized: { |
164 | 0 | break; |
165 | 0 | } |
166 | 0 | case eNode: { |
167 | 0 | DestroyNode(); |
168 | 0 | break; |
169 | 0 | } |
170 | 0 | case eHTMLCollection: { |
171 | 0 | DestroyHTMLCollection(); |
172 | 0 | break; |
173 | 0 | } |
174 | 0 | } |
175 | 0 | } |
176 | | |
177 | | bool |
178 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
179 | | |
180 | | private: |
181 | | inline void |
182 | | DestroyNode() |
183 | 0 | { |
184 | 0 | MOZ_ASSERT(IsNode(), "Wrong type!"); |
185 | 0 | mValue.mNode.Destroy(); |
186 | 0 | mType = eUninitialized; |
187 | 0 | } |
188 | | |
189 | | inline void |
190 | | DestroyHTMLCollection() |
191 | 0 | { |
192 | 0 | MOZ_ASSERT(IsHTMLCollection(), "Wrong type!"); |
193 | 0 | mValue.mHTMLCollection.Destroy(); |
194 | 0 | mType = eUninitialized; |
195 | 0 | } |
196 | | }; |
197 | | |
198 | | |
199 | | class OwningNodeOrHTMLCollection : public AllOwningUnionBase |
200 | | { |
201 | | friend void ImplCycleCollectionUnlink(OwningNodeOrHTMLCollection& aUnion); |
202 | | enum Type |
203 | | { |
204 | | eUninitialized, |
205 | | eNode, |
206 | | eHTMLCollection |
207 | | }; |
208 | | |
209 | | union Value |
210 | | { |
211 | | UnionMember<OwningNonNull<nsINode> > mNode; |
212 | | UnionMember<OwningNonNull<nsIHTMLCollection> > mHTMLCollection; |
213 | | |
214 | | }; |
215 | | |
216 | | Type mType; |
217 | | Value mValue; |
218 | | |
219 | | public: |
220 | | explicit inline OwningNodeOrHTMLCollection() |
221 | | : mType(eUninitialized) |
222 | 0 | { |
223 | 0 | } |
224 | | |
225 | | explicit inline OwningNodeOrHTMLCollection(const OwningNodeOrHTMLCollection& aOther) |
226 | | : mType(eUninitialized) |
227 | 0 | { |
228 | 0 | *this = aOther; |
229 | 0 | } |
230 | | |
231 | | inline ~OwningNodeOrHTMLCollection() |
232 | 0 | { |
233 | 0 | Uninit(); |
234 | 0 | } |
235 | | |
236 | | OwningNonNull<nsINode>& |
237 | | RawSetAsNode(); |
238 | | |
239 | | OwningNonNull<nsINode>& |
240 | | SetAsNode(); |
241 | | |
242 | | bool |
243 | | TrySetToNode(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
244 | | |
245 | | inline bool |
246 | | IsNode() const |
247 | 0 | { |
248 | 0 | return mType == eNode; |
249 | 0 | } |
250 | | |
251 | | inline OwningNonNull<nsINode>& |
252 | | GetAsNode() |
253 | 0 | { |
254 | 0 | MOZ_ASSERT(IsNode(), "Wrong type!"); |
255 | 0 | return mValue.mNode.Value(); |
256 | 0 | } |
257 | | |
258 | | inline OwningNonNull<nsINode> const & |
259 | | GetAsNode() const |
260 | 0 | { |
261 | 0 | MOZ_ASSERT(IsNode(), "Wrong type!"); |
262 | 0 | return mValue.mNode.Value(); |
263 | 0 | } |
264 | | |
265 | | OwningNonNull<nsIHTMLCollection>& |
266 | | RawSetAsHTMLCollection(); |
267 | | |
268 | | OwningNonNull<nsIHTMLCollection>& |
269 | | SetAsHTMLCollection(); |
270 | | |
271 | | bool |
272 | | TrySetToHTMLCollection(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false); |
273 | | |
274 | | inline bool |
275 | | IsHTMLCollection() const |
276 | 0 | { |
277 | 0 | return mType == eHTMLCollection; |
278 | 0 | } |
279 | | |
280 | | inline OwningNonNull<nsIHTMLCollection>& |
281 | | GetAsHTMLCollection() |
282 | 0 | { |
283 | 0 | MOZ_ASSERT(IsHTMLCollection(), "Wrong type!"); |
284 | 0 | return mValue.mHTMLCollection.Value(); |
285 | 0 | } |
286 | | |
287 | | inline OwningNonNull<nsIHTMLCollection> const & |
288 | | GetAsHTMLCollection() const |
289 | 0 | { |
290 | 0 | MOZ_ASSERT(IsHTMLCollection(), "Wrong type!"); |
291 | 0 | return mValue.mHTMLCollection.Value(); |
292 | 0 | } |
293 | | |
294 | | void |
295 | | Uninit(); |
296 | | |
297 | | bool |
298 | | ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const; |
299 | | |
300 | | void |
301 | | TraceUnion(JSTracer* trc); |
302 | | |
303 | | OwningNodeOrHTMLCollection& |
304 | | operator=(const OwningNodeOrHTMLCollection& aOther); |
305 | | |
306 | | private: |
307 | | void |
308 | | DestroyNode(); |
309 | | |
310 | | void |
311 | | DestroyHTMLCollection(); |
312 | | }; |
313 | | |
314 | | |
315 | | namespace HTMLAllCollection_Binding { |
316 | | |
317 | | typedef mozilla::dom::HTMLAllCollection NativeType; |
318 | | |
319 | | bool |
320 | | Wrap(JSContext* aCx, mozilla::dom::HTMLAllCollection* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector); |
321 | | |
322 | | template <class T> |
323 | | inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto) |
324 | 0 | { |
325 | 0 | JS::Rooted<JSObject*> reflector(aCx); |
326 | 0 | return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr; |
327 | 0 | } |
328 | | |
329 | | // We declare this as an array so that retrieving a pointer to this |
330 | | // binding's property hooks only requires compile/link-time resolvable |
331 | | // address arithmetic. Declaring it as a pointer instead would require |
332 | | // doing a run-time load to fetch a pointer to this binding's property |
333 | | // hooks. And then structures which embedded a pointer to this structure |
334 | | // would require a run-time load for proper initialization, which would |
335 | | // then induce static constructors. Lots of static constructors. |
336 | | extern const NativePropertyHooks sNativePropertyHooks[]; |
337 | | |
338 | | void |
339 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal); |
340 | | |
341 | | inline JS::Handle<JSObject*> GetProtoObjectHandle(JSContext* aCx) |
342 | 0 | { |
343 | 0 | /* Get the interface prototype object for this class. This will create the |
344 | 0 | object as needed. */ |
345 | 0 | return GetPerInterfaceObjectHandle(aCx, prototypes::id::HTMLAllCollection, |
346 | 0 | &CreateInterfaceObjects, |
347 | 0 | /* aDefineOnGlobal = */ true); |
348 | 0 |
|
349 | 0 | } |
350 | | |
351 | | inline JS::Handle<JSObject*> GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true) |
352 | 0 | { |
353 | 0 | /* Get the interface object for this class. This will create the object as |
354 | 0 | needed. */ |
355 | 0 |
|
356 | 0 | return GetPerInterfaceObjectHandle(aCx, constructors::id::HTMLAllCollection, |
357 | 0 | &CreateInterfaceObjects, |
358 | 0 | aDefineOnGlobal); |
359 | 0 | } |
360 | | |
361 | | JSObject* |
362 | | GetConstructorObject(JSContext* aCx); |
363 | | |
364 | | } // namespace HTMLAllCollection_Binding |
365 | | |
366 | | |
367 | | |
368 | | } // namespace dom |
369 | | } // namespace mozilla |
370 | | |
371 | | #endif // mozilla_dom_HTMLAllCollectionBinding_h |