Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM TrackEvent.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_TrackEventBinding_h
4 : #define mozilla_dom_TrackEventBinding_h
5 :
6 : #include "EventBinding.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 : class AudioTrack;
19 : struct NativePropertyHooks;
20 : class OwningVideoTrackOrAudioTrackOrTextTrack;
21 : class ProtoAndIfaceCache;
22 : class TextTrack;
23 : class TrackEvent;
24 : struct TrackEventAtoms;
25 : struct TrackEventInitAtoms;
26 : class VideoTrack;
27 : class VideoTrackOrAudioTrackOrTextTrack;
28 :
29 : } // namespace dom
30 : } // namespace mozilla
31 :
32 : namespace mozilla {
33 : namespace dom {
34 :
35 : void
36 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningVideoTrackOrAudioTrackOrTextTrack& aUnion, const char* aName, uint32_t aFlags = 0);
37 :
38 :
39 : void
40 : ImplCycleCollectionUnlink(OwningVideoTrackOrAudioTrackOrTextTrack& aUnion);
41 :
42 :
43 : class VideoTrackOrAudioTrackOrTextTrack
44 : {
45 : friend class VideoTrackOrAudioTrackOrTextTrackArgument;
46 : enum Type
47 : {
48 : eUninitialized,
49 : eVideoTrack,
50 : eAudioTrack,
51 : eTextTrack
52 : };
53 :
54 : union Value
55 : {
56 : UnionMember<NonNull<mozilla::dom::VideoTrack> > mVideoTrack;
57 : UnionMember<NonNull<mozilla::dom::AudioTrack> > mAudioTrack;
58 : UnionMember<NonNull<mozilla::dom::TextTrack> > mTextTrack;
59 :
60 : };
61 :
62 : Type mType;
63 : Value mValue;
64 :
65 : VideoTrackOrAudioTrackOrTextTrack(const VideoTrackOrAudioTrackOrTextTrack&) = delete;
66 : VideoTrackOrAudioTrackOrTextTrack& operator=(const VideoTrackOrAudioTrackOrTextTrack&) = delete;
67 : public:
68 : explicit inline VideoTrackOrAudioTrackOrTextTrack()
69 : : mType(eUninitialized)
70 : {
71 : }
72 :
73 : inline ~VideoTrackOrAudioTrackOrTextTrack()
74 : {
75 : Uninit();
76 : }
77 :
78 : inline NonNull<mozilla::dom::VideoTrack>&
79 : RawSetAsVideoTrack()
80 : {
81 : if (mType == eVideoTrack) {
82 : return mValue.mVideoTrack.Value();
83 : }
84 : MOZ_ASSERT(mType == eUninitialized);
85 : mType = eVideoTrack;
86 : return mValue.mVideoTrack.SetValue();
87 : }
88 :
89 : inline NonNull<mozilla::dom::VideoTrack>&
90 : SetAsVideoTrack()
91 : {
92 : if (mType == eVideoTrack) {
93 : return mValue.mVideoTrack.Value();
94 : }
95 : Uninit();
96 : mType = eVideoTrack;
97 : return mValue.mVideoTrack.SetValue();
98 : }
99 :
100 : inline bool
101 : IsVideoTrack() const
102 : {
103 : return mType == eVideoTrack;
104 : }
105 :
106 : inline NonNull<mozilla::dom::VideoTrack>&
107 : GetAsVideoTrack()
108 : {
109 : MOZ_ASSERT(IsVideoTrack(), "Wrong type!");
110 : return mValue.mVideoTrack.Value();
111 : }
112 :
113 : inline mozilla::dom::VideoTrack&
114 : GetAsVideoTrack() const
115 : {
116 : MOZ_ASSERT(IsVideoTrack(), "Wrong type!");
117 : return mValue.mVideoTrack.Value();
118 : }
119 :
120 : inline NonNull<mozilla::dom::AudioTrack>&
121 : RawSetAsAudioTrack()
122 : {
123 : if (mType == eAudioTrack) {
124 : return mValue.mAudioTrack.Value();
125 : }
126 : MOZ_ASSERT(mType == eUninitialized);
127 : mType = eAudioTrack;
128 : return mValue.mAudioTrack.SetValue();
129 : }
130 :
131 : inline NonNull<mozilla::dom::AudioTrack>&
132 : SetAsAudioTrack()
133 : {
134 : if (mType == eAudioTrack) {
135 : return mValue.mAudioTrack.Value();
136 : }
137 : Uninit();
138 : mType = eAudioTrack;
139 : return mValue.mAudioTrack.SetValue();
140 : }
141 :
142 : inline bool
143 : IsAudioTrack() const
144 : {
145 : return mType == eAudioTrack;
146 : }
147 :
148 : inline NonNull<mozilla::dom::AudioTrack>&
149 : GetAsAudioTrack()
150 : {
151 : MOZ_ASSERT(IsAudioTrack(), "Wrong type!");
152 : return mValue.mAudioTrack.Value();
153 : }
154 :
155 : inline mozilla::dom::AudioTrack&
156 : GetAsAudioTrack() const
157 : {
158 : MOZ_ASSERT(IsAudioTrack(), "Wrong type!");
159 : return mValue.mAudioTrack.Value();
160 : }
161 :
162 : inline NonNull<mozilla::dom::TextTrack>&
163 : RawSetAsTextTrack()
164 : {
165 : if (mType == eTextTrack) {
166 : return mValue.mTextTrack.Value();
167 : }
168 : MOZ_ASSERT(mType == eUninitialized);
169 : mType = eTextTrack;
170 : return mValue.mTextTrack.SetValue();
171 : }
172 :
173 : inline NonNull<mozilla::dom::TextTrack>&
174 : SetAsTextTrack()
175 : {
176 : if (mType == eTextTrack) {
177 : return mValue.mTextTrack.Value();
178 : }
179 : Uninit();
180 : mType = eTextTrack;
181 : return mValue.mTextTrack.SetValue();
182 : }
183 :
184 : inline bool
185 : IsTextTrack() const
186 : {
187 : return mType == eTextTrack;
188 : }
189 :
190 : inline NonNull<mozilla::dom::TextTrack>&
191 : GetAsTextTrack()
192 : {
193 : MOZ_ASSERT(IsTextTrack(), "Wrong type!");
194 : return mValue.mTextTrack.Value();
195 : }
196 :
197 : inline mozilla::dom::TextTrack&
198 : GetAsTextTrack() const
199 : {
200 : MOZ_ASSERT(IsTextTrack(), "Wrong type!");
201 : return mValue.mTextTrack.Value();
202 : }
203 :
204 : inline void
205 : Uninit()
206 : {
207 : switch (mType) {
208 : case eUninitialized: {
209 : break;
210 : }
211 : case eVideoTrack: {
212 : DestroyVideoTrack();
213 : break;
214 : }
215 : case eAudioTrack: {
216 : DestroyAudioTrack();
217 : break;
218 : }
219 : case eTextTrack: {
220 : DestroyTextTrack();
221 : break;
222 : }
223 : }
224 : }
225 :
226 : bool
227 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
228 :
229 : private:
230 : inline void
231 : DestroyVideoTrack()
232 : {
233 : MOZ_ASSERT(IsVideoTrack(), "Wrong type!");
234 : mValue.mVideoTrack.Destroy();
235 : mType = eUninitialized;
236 : }
237 :
238 : inline void
239 : DestroyAudioTrack()
240 : {
241 : MOZ_ASSERT(IsAudioTrack(), "Wrong type!");
242 : mValue.mAudioTrack.Destroy();
243 : mType = eUninitialized;
244 : }
245 :
246 : inline void
247 : DestroyTextTrack()
248 : {
249 : MOZ_ASSERT(IsTextTrack(), "Wrong type!");
250 : mValue.mTextTrack.Destroy();
251 : mType = eUninitialized;
252 : }
253 : };
254 :
255 :
256 : class OwningVideoTrackOrAudioTrackOrTextTrack : public AllOwningUnionBase
257 : {
258 : friend void ImplCycleCollectionUnlink(OwningVideoTrackOrAudioTrackOrTextTrack& aUnion);
259 : enum Type
260 : {
261 : eUninitialized,
262 : eVideoTrack,
263 : eAudioTrack,
264 : eTextTrack
265 : };
266 :
267 0 : union Value
268 : {
269 : UnionMember<OwningNonNull<mozilla::dom::VideoTrack> > mVideoTrack;
270 : UnionMember<OwningNonNull<mozilla::dom::AudioTrack> > mAudioTrack;
271 : UnionMember<OwningNonNull<mozilla::dom::TextTrack> > mTextTrack;
272 :
273 : };
274 :
275 : Type mType;
276 : Value mValue;
277 :
278 : public:
279 0 : explicit inline OwningVideoTrackOrAudioTrackOrTextTrack()
280 0 : : mType(eUninitialized)
281 : {
282 0 : }
283 :
284 0 : explicit inline OwningVideoTrackOrAudioTrackOrTextTrack(const OwningVideoTrackOrAudioTrackOrTextTrack& aOther)
285 0 : : mType(eUninitialized)
286 : {
287 0 : *this = aOther;
288 0 : }
289 :
290 0 : inline ~OwningVideoTrackOrAudioTrackOrTextTrack()
291 0 : {
292 0 : Uninit();
293 0 : }
294 :
295 : OwningNonNull<mozilla::dom::VideoTrack>&
296 : RawSetAsVideoTrack();
297 :
298 : OwningNonNull<mozilla::dom::VideoTrack>&
299 : SetAsVideoTrack();
300 :
301 : bool
302 : TrySetToVideoTrack(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
303 :
304 : inline bool
305 0 : IsVideoTrack() const
306 : {
307 0 : return mType == eVideoTrack;
308 : }
309 :
310 : inline OwningNonNull<mozilla::dom::VideoTrack>&
311 0 : GetAsVideoTrack()
312 : {
313 0 : MOZ_ASSERT(IsVideoTrack(), "Wrong type!");
314 0 : return mValue.mVideoTrack.Value();
315 : }
316 :
317 : inline OwningNonNull<mozilla::dom::VideoTrack> const &
318 0 : GetAsVideoTrack() const
319 : {
320 0 : MOZ_ASSERT(IsVideoTrack(), "Wrong type!");
321 0 : return mValue.mVideoTrack.Value();
322 : }
323 :
324 : OwningNonNull<mozilla::dom::AudioTrack>&
325 : RawSetAsAudioTrack();
326 :
327 : OwningNonNull<mozilla::dom::AudioTrack>&
328 : SetAsAudioTrack();
329 :
330 : bool
331 : TrySetToAudioTrack(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
332 :
333 : inline bool
334 0 : IsAudioTrack() const
335 : {
336 0 : return mType == eAudioTrack;
337 : }
338 :
339 : inline OwningNonNull<mozilla::dom::AudioTrack>&
340 0 : GetAsAudioTrack()
341 : {
342 0 : MOZ_ASSERT(IsAudioTrack(), "Wrong type!");
343 0 : return mValue.mAudioTrack.Value();
344 : }
345 :
346 : inline OwningNonNull<mozilla::dom::AudioTrack> const &
347 0 : GetAsAudioTrack() const
348 : {
349 0 : MOZ_ASSERT(IsAudioTrack(), "Wrong type!");
350 0 : return mValue.mAudioTrack.Value();
351 : }
352 :
353 : OwningNonNull<mozilla::dom::TextTrack>&
354 : RawSetAsTextTrack();
355 :
356 : OwningNonNull<mozilla::dom::TextTrack>&
357 : SetAsTextTrack();
358 :
359 : bool
360 : TrySetToTextTrack(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
361 :
362 : inline bool
363 0 : IsTextTrack() const
364 : {
365 0 : return mType == eTextTrack;
366 : }
367 :
368 : inline OwningNonNull<mozilla::dom::TextTrack>&
369 0 : GetAsTextTrack()
370 : {
371 0 : MOZ_ASSERT(IsTextTrack(), "Wrong type!");
372 0 : return mValue.mTextTrack.Value();
373 : }
374 :
375 : inline OwningNonNull<mozilla::dom::TextTrack> const &
376 0 : GetAsTextTrack() const
377 : {
378 0 : MOZ_ASSERT(IsTextTrack(), "Wrong type!");
379 0 : return mValue.mTextTrack.Value();
380 : }
381 :
382 : void
383 : Uninit();
384 :
385 : bool
386 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
387 :
388 : void
389 : TraceUnion(JSTracer* trc);
390 :
391 : OwningVideoTrackOrAudioTrackOrTextTrack&
392 : operator=(const OwningVideoTrackOrAudioTrackOrTextTrack& aOther);
393 :
394 : private:
395 : void
396 : DestroyVideoTrack();
397 :
398 : void
399 : DestroyAudioTrack();
400 :
401 : void
402 : DestroyTextTrack();
403 : };
404 :
405 :
406 0 : struct TrackEventInit : public EventInit
407 : {
408 : MOZ_INIT_OUTSIDE_CTOR Nullable<OwningVideoTrackOrAudioTrackOrTextTrack > mTrack;
409 :
410 : TrackEventInit();
411 :
412 0 : explicit inline TrackEventInit(const FastDictionaryInitializer& )
413 0 : : EventInit(FastDictionaryInitializer())
414 : {
415 : // Do nothing here; this is used by our "Fast" subclass
416 0 : }
417 :
418 : explicit inline TrackEventInit(const TrackEventInit& aOther)
419 : {
420 : *this = aOther;
421 : }
422 :
423 : bool
424 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
425 :
426 : bool
427 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
428 :
429 : void
430 : TraceDictionary(JSTracer* trc);
431 :
432 : TrackEventInit&
433 : operator=(const TrackEventInit& aOther);
434 :
435 : private:
436 : static bool
437 : InitIds(JSContext* cx, TrackEventInitAtoms* atomsCache);
438 : };
439 :
440 : namespace binding_detail {
441 0 : struct FastTrackEventInit : public TrackEventInit
442 : {
443 0 : inline FastTrackEventInit()
444 0 : : TrackEventInit(FastDictionaryInitializer())
445 : {
446 : // Doesn't matter what int we pass to the parent constructor
447 0 : }
448 : };
449 : } // namespace binding_detail
450 :
451 :
452 : namespace TrackEventBinding {
453 :
454 : typedef mozilla::dom::TrackEvent NativeType;
455 :
456 : JSObject*
457 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
458 :
459 : const JSClass*
460 : GetJSClass();
461 :
462 : bool
463 : Wrap(JSContext* aCx, mozilla::dom::TrackEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
464 :
465 : template <class T>
466 0 : inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
467 : {
468 0 : JS::Rooted<JSObject*> reflector(aCx);
469 0 : return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
470 : }
471 :
472 : // We declare this as an array so that retrieving a pointer to this
473 : // binding's property hooks only requires compile/link-time resolvable
474 : // address arithmetic. Declaring it as a pointer instead would require
475 : // doing a run-time load to fetch a pointer to this binding's property
476 : // hooks. And then structures which embedded a pointer to this structure
477 : // would require a run-time load for proper initialization, which would
478 : // then induce static constructors. Lots of static constructors.
479 : extern const NativePropertyHooks sNativePropertyHooks[];
480 :
481 : void
482 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
483 :
484 : JS::Handle<JSObject*>
485 : GetProtoObjectHandle(JSContext* aCx);
486 :
487 : JS::Handle<JSObject*>
488 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
489 :
490 : JSObject*
491 : GetConstructorObject(JSContext* aCx);
492 :
493 : } // namespace TrackEventBinding
494 :
495 :
496 :
497 : } // namespace dom
498 : } // namespace mozilla
499 :
500 : #endif // mozilla_dom_TrackEventBinding_h
|