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