Coverage Report

Created: 2018-09-25 14:53

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