Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM EventTarget.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_EventTargetBinding_h
4 : #define mozilla_dom_EventTargetBinding_h
5 :
6 : #include "EventTargetBinding.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/UnionMember.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : struct AddEventListenerOptionsAtoms;
19 : struct EventListenerOptionsAtoms;
20 : class EventTarget;
21 : struct EventTargetAtoms;
22 : struct NativePropertyHooks;
23 : class ProtoAndIfaceCache;
24 :
25 : } // namespace dom
26 : } // namespace mozilla
27 :
28 : namespace mozilla {
29 : namespace dom {
30 :
31 : struct EventListenerOptions : public DictionaryBase
32 : {
33 : MOZ_INIT_OUTSIDE_CTOR bool mCapture;
34 : MOZ_INIT_OUTSIDE_CTOR bool mMozSystemGroup;
35 :
36 : EventListenerOptions();
37 :
38 191 : explicit inline EventListenerOptions(const FastDictionaryInitializer& )
39 191 : {
40 : // Do nothing here; this is used by our "Fast" subclass
41 191 : }
42 :
43 : explicit inline EventListenerOptions(const EventListenerOptions& aOther)
44 : {
45 : *this = aOther;
46 : }
47 :
48 : bool
49 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
50 :
51 : bool
52 : Init(const nsAString& aJSON);
53 :
54 : bool
55 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
56 :
57 : bool
58 : ToJSON(nsAString& aJSON) const;
59 :
60 : void
61 : TraceDictionary(JSTracer* trc);
62 :
63 : EventListenerOptions&
64 : operator=(const EventListenerOptions& aOther);
65 :
66 : private:
67 : static bool
68 : InitIds(JSContext* cx, EventListenerOptionsAtoms* atomsCache);
69 : };
70 :
71 : namespace binding_detail {
72 : struct FastEventListenerOptions : public EventListenerOptions
73 : {
74 15 : inline FastEventListenerOptions()
75 15 : : EventListenerOptions(FastDictionaryInitializer())
76 : {
77 : // Doesn't matter what int we pass to the parent constructor
78 15 : }
79 : };
80 : } // namespace binding_detail
81 :
82 :
83 : struct AddEventListenerOptions : public EventListenerOptions
84 : {
85 : MOZ_INIT_OUTSIDE_CTOR bool mOnce;
86 : MOZ_INIT_OUTSIDE_CTOR bool mPassive;
87 :
88 : AddEventListenerOptions();
89 :
90 176 : explicit inline AddEventListenerOptions(const FastDictionaryInitializer& )
91 176 : : EventListenerOptions(FastDictionaryInitializer())
92 : {
93 : // Do nothing here; this is used by our "Fast" subclass
94 176 : }
95 :
96 : explicit inline AddEventListenerOptions(const AddEventListenerOptions& aOther)
97 : {
98 : *this = aOther;
99 : }
100 :
101 : bool
102 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
103 :
104 : bool
105 : Init(const nsAString& aJSON);
106 :
107 : bool
108 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
109 :
110 : bool
111 : ToJSON(nsAString& aJSON) const;
112 :
113 : void
114 : TraceDictionary(JSTracer* trc);
115 :
116 : AddEventListenerOptions&
117 : operator=(const AddEventListenerOptions& aOther);
118 :
119 : private:
120 : static bool
121 : InitIds(JSContext* cx, AddEventListenerOptionsAtoms* atomsCache);
122 : };
123 :
124 : namespace binding_detail {
125 : struct FastAddEventListenerOptions : public AddEventListenerOptions
126 : {
127 176 : inline FastAddEventListenerOptions()
128 176 : : AddEventListenerOptions(FastDictionaryInitializer())
129 : {
130 : // Doesn't matter what int we pass to the parent constructor
131 176 : }
132 : };
133 : } // namespace binding_detail
134 :
135 :
136 : class EventListenerOptionsOrBoolean
137 : {
138 : friend class EventListenerOptionsOrBooleanArgument;
139 : enum Type
140 : {
141 : eUninitialized,
142 : eEventListenerOptions,
143 : eBoolean
144 : };
145 :
146 15 : union Value
147 : {
148 : UnionMember<binding_detail::FastEventListenerOptions > mEventListenerOptions;
149 : UnionMember<bool > mBoolean;
150 :
151 : };
152 :
153 : Type mType;
154 : Value mValue;
155 :
156 : EventListenerOptionsOrBoolean(const EventListenerOptionsOrBoolean&) = delete;
157 : EventListenerOptionsOrBoolean& operator=(const EventListenerOptionsOrBoolean&) = delete;
158 : public:
159 15 : explicit inline EventListenerOptionsOrBoolean()
160 15 : : mType(eUninitialized)
161 : {
162 15 : }
163 :
164 15 : inline ~EventListenerOptionsOrBoolean()
165 15 : {
166 15 : Uninit();
167 15 : }
168 :
169 : inline binding_detail::FastEventListenerOptions&
170 8 : RawSetAsEventListenerOptions()
171 : {
172 8 : if (mType == eEventListenerOptions) {
173 0 : return mValue.mEventListenerOptions.Value();
174 : }
175 8 : MOZ_ASSERT(mType == eUninitialized);
176 8 : mType = eEventListenerOptions;
177 8 : return mValue.mEventListenerOptions.SetValue();
178 : }
179 :
180 : inline binding_detail::FastEventListenerOptions&
181 : SetAsEventListenerOptions()
182 : {
183 : if (mType == eEventListenerOptions) {
184 : return mValue.mEventListenerOptions.Value();
185 : }
186 : Uninit();
187 : mType = eEventListenerOptions;
188 : return mValue.mEventListenerOptions.SetValue();
189 : }
190 :
191 : inline bool
192 23 : IsEventListenerOptions() const
193 : {
194 23 : return mType == eEventListenerOptions;
195 : }
196 :
197 : inline binding_detail::FastEventListenerOptions&
198 : GetAsEventListenerOptions()
199 : {
200 : MOZ_ASSERT(IsEventListenerOptions(), "Wrong type!");
201 : return mValue.mEventListenerOptions.Value();
202 : }
203 :
204 : inline const EventListenerOptions&
205 8 : GetAsEventListenerOptions() const
206 : {
207 8 : MOZ_ASSERT(IsEventListenerOptions(), "Wrong type!");
208 8 : return mValue.mEventListenerOptions.Value();
209 : }
210 :
211 : inline bool&
212 : RawSetAsBoolean()
213 : {
214 : if (mType == eBoolean) {
215 : return mValue.mBoolean.Value();
216 : }
217 : MOZ_ASSERT(mType == eUninitialized);
218 : mType = eBoolean;
219 : return mValue.mBoolean.SetValue();
220 : }
221 :
222 : inline bool&
223 0 : SetAsBoolean()
224 : {
225 0 : if (mType == eBoolean) {
226 0 : return mValue.mBoolean.Value();
227 : }
228 0 : Uninit();
229 0 : mType = eBoolean;
230 0 : return mValue.mBoolean.SetValue();
231 : }
232 :
233 : inline bool
234 29 : IsBoolean() const
235 : {
236 29 : return mType == eBoolean;
237 : }
238 :
239 : inline bool&
240 : GetAsBoolean()
241 : {
242 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
243 : return mValue.mBoolean.Value();
244 : }
245 :
246 : inline bool
247 7 : GetAsBoolean() const
248 : {
249 7 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
250 7 : return mValue.mBoolean.Value();
251 : }
252 :
253 : inline void
254 15 : Uninit()
255 : {
256 15 : switch (mType) {
257 : case eUninitialized: {
258 0 : break;
259 : }
260 : case eEventListenerOptions: {
261 8 : DestroyEventListenerOptions();
262 8 : break;
263 : }
264 : case eBoolean: {
265 7 : DestroyBoolean();
266 7 : break;
267 : }
268 : }
269 15 : }
270 :
271 : bool
272 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
273 :
274 : private:
275 : inline void
276 15 : DestroyEventListenerOptions()
277 : {
278 15 : MOZ_ASSERT(IsEventListenerOptions(), "Wrong type!");
279 15 : mValue.mEventListenerOptions.Destroy();
280 15 : mType = eUninitialized;
281 15 : }
282 :
283 : inline void
284 7 : DestroyBoolean()
285 : {
286 7 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
287 7 : mValue.mBoolean.Destroy();
288 7 : mType = eUninitialized;
289 7 : }
290 : };
291 :
292 :
293 : class OwningEventListenerOptionsOrBoolean : public AllOwningUnionBase
294 : {
295 : friend void ImplCycleCollectionUnlink(OwningEventListenerOptionsOrBoolean& aUnion);
296 : enum Type
297 : {
298 : eUninitialized,
299 : eEventListenerOptions,
300 : eBoolean
301 : };
302 :
303 : union Value
304 : {
305 : UnionMember<EventListenerOptions > mEventListenerOptions;
306 : UnionMember<bool > mBoolean;
307 :
308 : };
309 :
310 : Type mType;
311 : Value mValue;
312 :
313 : public:
314 : explicit inline OwningEventListenerOptionsOrBoolean()
315 : : mType(eUninitialized)
316 : {
317 : }
318 :
319 : explicit inline OwningEventListenerOptionsOrBoolean(const OwningEventListenerOptionsOrBoolean& aOther)
320 : : mType(eUninitialized)
321 : {
322 : *this = aOther;
323 : }
324 :
325 : inline ~OwningEventListenerOptionsOrBoolean()
326 : {
327 : Uninit();
328 : }
329 :
330 : EventListenerOptions&
331 : RawSetAsEventListenerOptions();
332 :
333 : EventListenerOptions&
334 : SetAsEventListenerOptions();
335 :
336 : bool
337 : TrySetToEventListenerOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
338 :
339 : inline bool
340 0 : IsEventListenerOptions() const
341 : {
342 0 : return mType == eEventListenerOptions;
343 : }
344 :
345 : inline EventListenerOptions&
346 : GetAsEventListenerOptions()
347 : {
348 : MOZ_ASSERT(IsEventListenerOptions(), "Wrong type!");
349 : return mValue.mEventListenerOptions.Value();
350 : }
351 :
352 : inline EventListenerOptions const &
353 0 : GetAsEventListenerOptions() const
354 : {
355 0 : MOZ_ASSERT(IsEventListenerOptions(), "Wrong type!");
356 0 : return mValue.mEventListenerOptions.Value();
357 : }
358 :
359 : bool&
360 : RawSetAsBoolean();
361 :
362 : bool&
363 : SetAsBoolean();
364 :
365 : bool
366 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
367 :
368 : inline bool
369 0 : IsBoolean() const
370 : {
371 0 : return mType == eBoolean;
372 : }
373 :
374 : inline bool&
375 : GetAsBoolean()
376 : {
377 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
378 : return mValue.mBoolean.Value();
379 : }
380 :
381 : inline bool const &
382 0 : GetAsBoolean() const
383 : {
384 0 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
385 0 : return mValue.mBoolean.Value();
386 : }
387 :
388 : void
389 : Uninit();
390 :
391 : bool
392 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
393 :
394 : void
395 : TraceUnion(JSTracer* trc);
396 :
397 : OwningEventListenerOptionsOrBoolean&
398 : operator=(const OwningEventListenerOptionsOrBoolean& aOther);
399 :
400 : private:
401 : void
402 : DestroyEventListenerOptions();
403 :
404 : void
405 : DestroyBoolean();
406 : };
407 :
408 :
409 : class AddEventListenerOptionsOrBoolean
410 : {
411 : friend class AddEventListenerOptionsOrBooleanArgument;
412 : enum Type
413 : {
414 : eUninitialized,
415 : eAddEventListenerOptions,
416 : eBoolean
417 : };
418 :
419 177 : union Value
420 : {
421 : UnionMember<binding_detail::FastAddEventListenerOptions > mAddEventListenerOptions;
422 : UnionMember<bool > mBoolean;
423 :
424 : };
425 :
426 : Type mType;
427 : Value mValue;
428 :
429 : AddEventListenerOptionsOrBoolean(const AddEventListenerOptionsOrBoolean&) = delete;
430 : AddEventListenerOptionsOrBoolean& operator=(const AddEventListenerOptionsOrBoolean&) = delete;
431 : public:
432 177 : explicit inline AddEventListenerOptionsOrBoolean()
433 177 : : mType(eUninitialized)
434 : {
435 177 : }
436 :
437 177 : inline ~AddEventListenerOptionsOrBoolean()
438 177 : {
439 177 : Uninit();
440 177 : }
441 :
442 : inline binding_detail::FastAddEventListenerOptions&
443 129 : RawSetAsAddEventListenerOptions()
444 : {
445 129 : if (mType == eAddEventListenerOptions) {
446 0 : return mValue.mAddEventListenerOptions.Value();
447 : }
448 129 : MOZ_ASSERT(mType == eUninitialized);
449 129 : mType = eAddEventListenerOptions;
450 129 : return mValue.mAddEventListenerOptions.SetValue();
451 : }
452 :
453 : inline binding_detail::FastAddEventListenerOptions&
454 : SetAsAddEventListenerOptions()
455 : {
456 : if (mType == eAddEventListenerOptions) {
457 : return mValue.mAddEventListenerOptions.Value();
458 : }
459 : Uninit();
460 : mType = eAddEventListenerOptions;
461 : return mValue.mAddEventListenerOptions.SetValue();
462 : }
463 :
464 : inline bool
465 311 : IsAddEventListenerOptions() const
466 : {
467 311 : return mType == eAddEventListenerOptions;
468 : }
469 :
470 : inline binding_detail::FastAddEventListenerOptions&
471 : GetAsAddEventListenerOptions()
472 : {
473 : MOZ_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
474 : return mValue.mAddEventListenerOptions.Value();
475 : }
476 :
477 : inline const AddEventListenerOptions&
478 135 : GetAsAddEventListenerOptions() const
479 : {
480 135 : MOZ_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
481 135 : return mValue.mAddEventListenerOptions.Value();
482 : }
483 :
484 : inline bool&
485 : RawSetAsBoolean()
486 : {
487 : if (mType == eBoolean) {
488 : return mValue.mBoolean.Value();
489 : }
490 : MOZ_ASSERT(mType == eUninitialized);
491 : mType = eBoolean;
492 : return mValue.mBoolean.SetValue();
493 : }
494 :
495 : inline bool&
496 1 : SetAsBoolean()
497 : {
498 1 : if (mType == eBoolean) {
499 0 : return mValue.mBoolean.Value();
500 : }
501 1 : Uninit();
502 1 : mType = eBoolean;
503 1 : return mValue.mBoolean.SetValue();
504 : }
505 :
506 : inline bool
507 261 : IsBoolean() const
508 : {
509 261 : return mType == eBoolean;
510 : }
511 :
512 : inline bool&
513 : GetAsBoolean()
514 : {
515 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
516 : return mValue.mBoolean.Value();
517 : }
518 :
519 : inline bool
520 42 : GetAsBoolean() const
521 : {
522 42 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
523 42 : return mValue.mBoolean.Value();
524 : }
525 :
526 : inline void
527 178 : Uninit()
528 : {
529 178 : switch (mType) {
530 : case eUninitialized: {
531 1 : break;
532 : }
533 : case eAddEventListenerOptions: {
534 135 : DestroyAddEventListenerOptions();
535 135 : break;
536 : }
537 : case eBoolean: {
538 42 : DestroyBoolean();
539 42 : break;
540 : }
541 : }
542 178 : }
543 :
544 : bool
545 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
546 :
547 : private:
548 : inline void
549 176 : DestroyAddEventListenerOptions()
550 : {
551 176 : MOZ_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
552 176 : mValue.mAddEventListenerOptions.Destroy();
553 176 : mType = eUninitialized;
554 176 : }
555 :
556 : inline void
557 42 : DestroyBoolean()
558 : {
559 42 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
560 42 : mValue.mBoolean.Destroy();
561 42 : mType = eUninitialized;
562 42 : }
563 : };
564 :
565 :
566 : class OwningAddEventListenerOptionsOrBoolean : public AllOwningUnionBase
567 : {
568 : friend void ImplCycleCollectionUnlink(OwningAddEventListenerOptionsOrBoolean& aUnion);
569 : enum Type
570 : {
571 : eUninitialized,
572 : eAddEventListenerOptions,
573 : eBoolean
574 : };
575 :
576 : union Value
577 : {
578 : UnionMember<AddEventListenerOptions > mAddEventListenerOptions;
579 : UnionMember<bool > mBoolean;
580 :
581 : };
582 :
583 : Type mType;
584 : Value mValue;
585 :
586 : public:
587 : explicit inline OwningAddEventListenerOptionsOrBoolean()
588 : : mType(eUninitialized)
589 : {
590 : }
591 :
592 : explicit inline OwningAddEventListenerOptionsOrBoolean(const OwningAddEventListenerOptionsOrBoolean& aOther)
593 : : mType(eUninitialized)
594 : {
595 : *this = aOther;
596 : }
597 :
598 : inline ~OwningAddEventListenerOptionsOrBoolean()
599 : {
600 : Uninit();
601 : }
602 :
603 : AddEventListenerOptions&
604 : RawSetAsAddEventListenerOptions();
605 :
606 : AddEventListenerOptions&
607 : SetAsAddEventListenerOptions();
608 :
609 : bool
610 : TrySetToAddEventListenerOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
611 :
612 : inline bool
613 0 : IsAddEventListenerOptions() const
614 : {
615 0 : return mType == eAddEventListenerOptions;
616 : }
617 :
618 : inline AddEventListenerOptions&
619 : GetAsAddEventListenerOptions()
620 : {
621 : MOZ_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
622 : return mValue.mAddEventListenerOptions.Value();
623 : }
624 :
625 : inline AddEventListenerOptions const &
626 0 : GetAsAddEventListenerOptions() const
627 : {
628 0 : MOZ_ASSERT(IsAddEventListenerOptions(), "Wrong type!");
629 0 : return mValue.mAddEventListenerOptions.Value();
630 : }
631 :
632 : bool&
633 : RawSetAsBoolean();
634 :
635 : bool&
636 : SetAsBoolean();
637 :
638 : bool
639 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
640 :
641 : inline bool
642 0 : IsBoolean() const
643 : {
644 0 : return mType == eBoolean;
645 : }
646 :
647 : inline bool&
648 : GetAsBoolean()
649 : {
650 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
651 : return mValue.mBoolean.Value();
652 : }
653 :
654 : inline bool const &
655 0 : GetAsBoolean() const
656 : {
657 0 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
658 0 : return mValue.mBoolean.Value();
659 : }
660 :
661 : void
662 : Uninit();
663 :
664 : bool
665 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
666 :
667 : void
668 : TraceUnion(JSTracer* trc);
669 :
670 : OwningAddEventListenerOptionsOrBoolean&
671 : operator=(const OwningAddEventListenerOptionsOrBoolean& aOther);
672 :
673 : private:
674 : void
675 : DestroyAddEventListenerOptions();
676 :
677 : void
678 : DestroyBoolean();
679 : };
680 :
681 :
682 : namespace EventTargetBinding {
683 :
684 : typedef mozilla::dom::EventTarget NativeType;
685 :
686 : JSObject*
687 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
688 :
689 : // We declare this as an array so that retrieving a pointer to this
690 : // binding's property hooks only requires compile/link-time resolvable
691 : // address arithmetic. Declaring it as a pointer instead would require
692 : // doing a run-time load to fetch a pointer to this binding's property
693 : // hooks. And then structures which embedded a pointer to this structure
694 : // would require a run-time load for proper initialization, which would
695 : // then induce static constructors. Lots of static constructors.
696 : extern const NativePropertyHooks sNativePropertyHooks[];
697 :
698 : void
699 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
700 :
701 : JS::Handle<JSObject*>
702 : GetProtoObjectHandle(JSContext* aCx);
703 :
704 : JSObject*
705 : GetProtoObject(JSContext* aCx);
706 :
707 : JS::Handle<JSObject*>
708 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
709 :
710 : JSObject*
711 : GetConstructorObject(JSContext* aCx);
712 :
713 : } // namespace EventTargetBinding
714 :
715 :
716 :
717 : } // namespace dom
718 : } // namespace mozilla
719 :
720 : #endif // mozilla_dom_EventTargetBinding_h
|