Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/HTMLTrackElementBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM HTMLTrackElement.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "HTMLElementBinding.h"
4
#include "HTMLTrackElementBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/dom/BindingUtils.h"
8
#include "mozilla/dom/CustomElementRegistry.h"
9
#include "mozilla/dom/DOMJSClass.h"
10
#include "mozilla/dom/DocGroup.h"
11
#include "mozilla/dom/HTMLTrackElement.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/PrimitiveConversions.h"
15
#include "mozilla/dom/TextTrack.h"
16
#include "mozilla/dom/XrayExpandoClass.h"
17
18
namespace mozilla {
19
namespace dom {
20
21
namespace binding_detail {}; // Just to make sure it's known as a namespace
22
using namespace mozilla::dom::binding_detail;
23
24
25
namespace HTMLTrackElement_Binding {
26
27
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElement_Binding::NativeType>::value,
28
              "Can't inherit from an interface with a different ownership model.");
29
30
MOZ_CAN_RUN_SCRIPT static bool
31
get_kind(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
32
0
{
33
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.kind", DOM, cx);
34
0
35
0
  DOMString result;
36
0
  self->GetKind(result);
37
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
38
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
39
0
    return false;
40
0
  }
41
0
  return true;
42
0
}
43
44
MOZ_CAN_RUN_SCRIPT static bool
45
set_kind(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitSetterCallArgs args)
46
0
{
47
0
  AUTO_PROFILER_LABEL_FAST("set HTMLTrackElement.kind", DOM, cx);
48
0
49
0
  binding_detail::FakeString arg0;
50
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
51
0
    return false;
52
0
  }
53
0
  Maybe<AutoCEReaction> ceReaction;
54
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
55
0
    DocGroup* docGroup = self->GetDocGroup();
56
0
    if (docGroup) {
57
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
58
0
    }
59
0
  }
60
0
  FastErrorResult rv;
61
0
  self->SetKind(NonNullHelper(Constify(arg0)), rv);
62
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
63
0
    return false;
64
0
  }
65
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
66
0
67
0
  return true;
68
0
}
69
70
static const JSJitInfo kind_getterinfo = {
71
  { (JSJitGetterOp)get_kind },
72
  { prototypes::id::HTMLTrackElement },
73
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
74
  JSJitInfo::Getter,
75
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
76
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
77
  false,  /* isInfallible. False in setters. */
78
  true,  /* isMovable.  Not relevant for setters. */
79
  true, /* isEliminatable.  Not relevant for setters. */
80
  false, /* isAlwaysInSlot.  Only relevant for getters. */
81
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
82
  false,  /* isTypedMethod.  Only relevant for methods. */
83
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
84
};
85
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
86
static_assert(0 < 1, "There is no slot for us");
87
static const JSJitInfo kind_setterinfo = {
88
  { (JSJitGetterOp)set_kind },
89
  { prototypes::id::HTMLTrackElement },
90
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
91
  JSJitInfo::Setter,
92
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
93
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
94
  false,  /* isInfallible. False in setters. */
95
  false,  /* isMovable.  Not relevant for setters. */
96
  false, /* isEliminatable.  Not relevant for setters. */
97
  false, /* isAlwaysInSlot.  Only relevant for getters. */
98
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
99
  false,  /* isTypedMethod.  Only relevant for methods. */
100
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
101
};
102
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
103
static_assert(0 < 1, "There is no slot for us");
104
105
MOZ_CAN_RUN_SCRIPT static bool
106
get_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
107
0
{
108
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.src", DOM, cx);
109
0
110
0
  DOMString result;
111
0
  self->GetSrc(result);
112
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
113
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
114
0
    return false;
115
0
  }
116
0
  return true;
117
0
}
118
119
MOZ_CAN_RUN_SCRIPT static bool
120
set_src(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitSetterCallArgs args)
121
0
{
122
0
  AUTO_PROFILER_LABEL_FAST("set HTMLTrackElement.src", DOM, cx);
123
0
124
0
  binding_detail::FakeString arg0;
125
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
126
0
    return false;
127
0
  }
128
0
  Maybe<AutoCEReaction> ceReaction;
129
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
130
0
    DocGroup* docGroup = self->GetDocGroup();
131
0
    if (docGroup) {
132
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
133
0
    }
134
0
  }
135
0
  FastErrorResult rv;
136
0
  self->SetSrc(NonNullHelper(Constify(arg0)), rv);
137
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
138
0
    return false;
139
0
  }
140
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
141
0
142
0
  return true;
143
0
}
144
145
static const JSJitInfo src_getterinfo = {
146
  { (JSJitGetterOp)get_src },
147
  { prototypes::id::HTMLTrackElement },
148
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
149
  JSJitInfo::Getter,
150
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
151
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
152
  false,  /* isInfallible. False in setters. */
153
  true,  /* isMovable.  Not relevant for setters. */
154
  true, /* isEliminatable.  Not relevant for setters. */
155
  false, /* isAlwaysInSlot.  Only relevant for getters. */
156
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
157
  false,  /* isTypedMethod.  Only relevant for methods. */
158
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
159
};
160
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
161
static_assert(0 < 1, "There is no slot for us");
162
static const JSJitInfo src_setterinfo = {
163
  { (JSJitGetterOp)set_src },
164
  { prototypes::id::HTMLTrackElement },
165
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
166
  JSJitInfo::Setter,
167
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
168
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
169
  false,  /* isInfallible. False in setters. */
170
  false,  /* isMovable.  Not relevant for setters. */
171
  false, /* isEliminatable.  Not relevant for setters. */
172
  false, /* isAlwaysInSlot.  Only relevant for getters. */
173
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
174
  false,  /* isTypedMethod.  Only relevant for methods. */
175
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
176
};
177
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
178
static_assert(0 < 1, "There is no slot for us");
179
180
MOZ_CAN_RUN_SCRIPT static bool
181
get_srclang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
182
0
{
183
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.srclang", DOM, cx);
184
0
185
0
  DOMString result;
186
0
  self->GetSrclang(result);
187
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
188
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
189
0
    return false;
190
0
  }
191
0
  return true;
192
0
}
193
194
MOZ_CAN_RUN_SCRIPT static bool
195
set_srclang(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitSetterCallArgs args)
196
0
{
197
0
  AUTO_PROFILER_LABEL_FAST("set HTMLTrackElement.srclang", DOM, cx);
198
0
199
0
  binding_detail::FakeString arg0;
200
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
201
0
    return false;
202
0
  }
203
0
  Maybe<AutoCEReaction> ceReaction;
204
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
205
0
    DocGroup* docGroup = self->GetDocGroup();
206
0
    if (docGroup) {
207
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
208
0
    }
209
0
  }
210
0
  FastErrorResult rv;
211
0
  self->SetSrclang(NonNullHelper(Constify(arg0)), rv);
212
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
213
0
    return false;
214
0
  }
215
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
216
0
217
0
  return true;
218
0
}
219
220
static const JSJitInfo srclang_getterinfo = {
221
  { (JSJitGetterOp)get_srclang },
222
  { prototypes::id::HTMLTrackElement },
223
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
224
  JSJitInfo::Getter,
225
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
226
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
227
  false,  /* isInfallible. False in setters. */
228
  true,  /* isMovable.  Not relevant for setters. */
229
  true, /* isEliminatable.  Not relevant for setters. */
230
  false, /* isAlwaysInSlot.  Only relevant for getters. */
231
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
232
  false,  /* isTypedMethod.  Only relevant for methods. */
233
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
234
};
235
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
236
static_assert(0 < 1, "There is no slot for us");
237
static const JSJitInfo srclang_setterinfo = {
238
  { (JSJitGetterOp)set_srclang },
239
  { prototypes::id::HTMLTrackElement },
240
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
241
  JSJitInfo::Setter,
242
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
243
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
244
  false,  /* isInfallible. False in setters. */
245
  false,  /* isMovable.  Not relevant for setters. */
246
  false, /* isEliminatable.  Not relevant for setters. */
247
  false, /* isAlwaysInSlot.  Only relevant for getters. */
248
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
249
  false,  /* isTypedMethod.  Only relevant for methods. */
250
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
251
};
252
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
253
static_assert(0 < 1, "There is no slot for us");
254
255
MOZ_CAN_RUN_SCRIPT static bool
256
get_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
257
0
{
258
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.label", DOM, cx);
259
0
260
0
  DOMString result;
261
0
  self->GetLabel(result);
262
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
263
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
264
0
    return false;
265
0
  }
266
0
  return true;
267
0
}
268
269
MOZ_CAN_RUN_SCRIPT static bool
270
set_label(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitSetterCallArgs args)
271
0
{
272
0
  AUTO_PROFILER_LABEL_FAST("set HTMLTrackElement.label", DOM, cx);
273
0
274
0
  binding_detail::FakeString arg0;
275
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
276
0
    return false;
277
0
  }
278
0
  Maybe<AutoCEReaction> ceReaction;
279
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
280
0
    DocGroup* docGroup = self->GetDocGroup();
281
0
    if (docGroup) {
282
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
283
0
    }
284
0
  }
285
0
  FastErrorResult rv;
286
0
  self->SetLabel(NonNullHelper(Constify(arg0)), rv);
287
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
288
0
    return false;
289
0
  }
290
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
291
0
292
0
  return true;
293
0
}
294
295
static const JSJitInfo label_getterinfo = {
296
  { (JSJitGetterOp)get_label },
297
  { prototypes::id::HTMLTrackElement },
298
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
299
  JSJitInfo::Getter,
300
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
301
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
302
  false,  /* isInfallible. False in setters. */
303
  true,  /* isMovable.  Not relevant for setters. */
304
  true, /* isEliminatable.  Not relevant for setters. */
305
  false, /* isAlwaysInSlot.  Only relevant for getters. */
306
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
307
  false,  /* isTypedMethod.  Only relevant for methods. */
308
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
309
};
310
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
311
static_assert(0 < 1, "There is no slot for us");
312
static const JSJitInfo label_setterinfo = {
313
  { (JSJitGetterOp)set_label },
314
  { prototypes::id::HTMLTrackElement },
315
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
316
  JSJitInfo::Setter,
317
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
318
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
319
  false,  /* isInfallible. False in setters. */
320
  false,  /* isMovable.  Not relevant for setters. */
321
  false, /* isEliminatable.  Not relevant for setters. */
322
  false, /* isAlwaysInSlot.  Only relevant for getters. */
323
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
324
  false,  /* isTypedMethod.  Only relevant for methods. */
325
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
326
};
327
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
328
static_assert(0 < 1, "There is no slot for us");
329
330
MOZ_CAN_RUN_SCRIPT static bool
331
get_default(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
332
0
{
333
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.default", DOM, cx);
334
0
335
0
  bool result(self->Default());
336
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
337
0
  args.rval().setBoolean(result);
338
0
  return true;
339
0
}
340
341
MOZ_CAN_RUN_SCRIPT static bool
342
set_default(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitSetterCallArgs args)
343
0
{
344
0
  AUTO_PROFILER_LABEL_FAST("set HTMLTrackElement.default", DOM, cx);
345
0
346
0
  bool arg0;
347
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
348
0
    return false;
349
0
  }
350
0
  Maybe<AutoCEReaction> ceReaction;
351
0
  if (CustomElementRegistry::IsCustomElementEnabled(cx, obj)) {
352
0
    DocGroup* docGroup = self->GetDocGroup();
353
0
    if (docGroup) {
354
0
      ceReaction.emplace(docGroup->CustomElementReactionsStack(), cx);
355
0
    }
356
0
  }
357
0
  FastErrorResult rv;
358
0
  self->SetDefault(arg0, rv);
359
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
360
0
    return false;
361
0
  }
362
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
363
0
364
0
  return true;
365
0
}
366
367
static const JSJitInfo default_getterinfo = {
368
  { (JSJitGetterOp)get_default },
369
  { prototypes::id::HTMLTrackElement },
370
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
371
  JSJitInfo::Getter,
372
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
373
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
374
  true,  /* isInfallible. False in setters. */
375
  true,  /* isMovable.  Not relevant for setters. */
376
  true, /* isEliminatable.  Not relevant for setters. */
377
  false, /* isAlwaysInSlot.  Only relevant for getters. */
378
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
379
  false,  /* isTypedMethod.  Only relevant for methods. */
380
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
381
};
382
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
383
static_assert(0 < 1, "There is no slot for us");
384
static const JSJitInfo default_setterinfo = {
385
  { (JSJitGetterOp)set_default },
386
  { prototypes::id::HTMLTrackElement },
387
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
388
  JSJitInfo::Setter,
389
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
390
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
391
  false,  /* isInfallible. False in setters. */
392
  false,  /* isMovable.  Not relevant for setters. */
393
  false, /* isEliminatable.  Not relevant for setters. */
394
  false, /* isAlwaysInSlot.  Only relevant for getters. */
395
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
396
  false,  /* isTypedMethod.  Only relevant for methods. */
397
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
398
};
399
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
400
static_assert(0 < 1, "There is no slot for us");
401
402
MOZ_CAN_RUN_SCRIPT static bool
403
get_readyState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
404
0
{
405
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.readyState", DOM, cx);
406
0
407
0
  uint16_t result(self->ReadyState());
408
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
409
0
  args.rval().setInt32(int32_t(result));
410
0
  return true;
411
0
}
412
413
static const JSJitInfo readyState_getterinfo = {
414
  { (JSJitGetterOp)get_readyState },
415
  { prototypes::id::HTMLTrackElement },
416
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
417
  JSJitInfo::Getter,
418
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
419
  JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
420
  true,  /* isInfallible. False in setters. */
421
  false,  /* isMovable.  Not relevant for setters. */
422
  false, /* isEliminatable.  Not relevant for setters. */
423
  false, /* isAlwaysInSlot.  Only relevant for getters. */
424
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
425
  false,  /* isTypedMethod.  Only relevant for methods. */
426
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
427
};
428
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
429
static_assert(0 < 1, "There is no slot for us");
430
431
MOZ_CAN_RUN_SCRIPT static bool
432
get_track(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLTrackElement* self, JSJitGetterCallArgs args)
433
0
{
434
0
  AUTO_PROFILER_LABEL_FAST("get HTMLTrackElement.track", DOM, cx);
435
0
436
0
  auto result(StrongOrRawPtr<mozilla::dom::TextTrack>(self->GetTrack()));
437
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
438
0
  if (!result) {
439
0
    args.rval().setNull();
440
0
    return true;
441
0
  }
442
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
443
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
444
0
    return false;
445
0
  }
446
0
  return true;
447
0
}
448
449
static const JSJitInfo track_getterinfo = {
450
  { (JSJitGetterOp)get_track },
451
  { prototypes::id::HTMLTrackElement },
452
  { PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth },
453
  JSJitInfo::Getter,
454
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
455
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
456
  false,  /* isInfallible. False in setters. */
457
  false,  /* isMovable.  Not relevant for setters. */
458
  false, /* isEliminatable.  Not relevant for setters. */
459
  false, /* isAlwaysInSlot.  Only relevant for getters. */
460
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
461
  false,  /* isTypedMethod.  Only relevant for methods. */
462
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
463
};
464
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
465
static_assert(0 < 1, "There is no slot for us");
466
467
static bool
468
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
469
0
{
470
0
  mozilla::dom::HTMLTrackElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTrackElement>(obj);
471
0
  // We don't want to preserve if we don't have a wrapper, and we
472
0
  // obviously can't preserve if we're not initialized.
473
0
  if (self && self->GetWrapperPreserveColor()) {
474
0
    PreserveWrapper(self);
475
0
  }
476
0
  return true;
477
0
}
478
479
static void
480
_finalize(js::FreeOp* fop, JSObject* obj)
481
0
{
482
0
  mozilla::dom::HTMLTrackElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTrackElement>(obj);
483
0
  if (self) {
484
0
    ClearWrapper(self, self, obj);
485
0
    AddForDeferredFinalization<mozilla::dom::HTMLTrackElement>(self);
486
0
  }
487
0
}
488
489
static size_t
490
_objectMoved(JSObject* obj, JSObject* old)
491
0
{
492
0
  mozilla::dom::HTMLTrackElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLTrackElement>(obj);
493
0
  if (self) {
494
0
    UpdateWrapper(self, self, obj, old);
495
0
  }
496
0
497
0
  return 0;
498
0
}
499
500
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
501
#if defined(__clang__)
502
#pragma clang diagnostic push
503
#pragma clang diagnostic ignored "-Wmissing-braces"
504
#endif
505
static const JSPropertySpec sAttributes_specs[] = {
506
  { "kind", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &kind_getterinfo, GenericSetter<NormalThisPolicy>, &kind_setterinfo },
507
  { "src", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &src_getterinfo, GenericSetter<NormalThisPolicy>, &src_setterinfo },
508
  { "srclang", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &srclang_getterinfo, GenericSetter<NormalThisPolicy>, &srclang_setterinfo },
509
  { "label", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &label_getterinfo, GenericSetter<NormalThisPolicy>, &label_setterinfo },
510
  { "default", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &default_getterinfo, GenericSetter<NormalThisPolicy>, &default_setterinfo },
511
  { "readyState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &readyState_getterinfo, nullptr, nullptr },
512
  { "track", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &track_getterinfo, nullptr, nullptr },
513
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
514
};
515
#if defined(__clang__)
516
#pragma clang diagnostic pop
517
#endif
518
519
520
static const Prefable<const JSPropertySpec> sAttributes[] = {
521
  { nullptr, &sAttributes_specs[0] },
522
  { nullptr, nullptr }
523
};
524
525
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
526
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
527
static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
528
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
529
530
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
531
#if defined(__clang__)
532
#pragma clang diagnostic push
533
#pragma clang diagnostic ignored "-Wmissing-braces"
534
#endif
535
static const ConstantSpec sConstants_specs[] = {
536
  { "NONE", JS::Int32Value(0) },
537
  { "LOADING", JS::Int32Value(1) },
538
  { "LOADED", JS::Int32Value(2) },
539
  { "ERROR", JS::Int32Value(3) },
540
  { 0, JS::UndefinedValue() }
541
};
542
#if defined(__clang__)
543
#pragma clang diagnostic pop
544
#endif
545
546
547
static const Prefable<const ConstantSpec> sConstants[] = {
548
  { nullptr, &sConstants_specs[0] },
549
  { nullptr, nullptr }
550
};
551
552
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
553
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
554
static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
555
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
556
557
558
static uint16_t sNativeProperties_sortedPropertyIndices[11];
559
static PropertyInfo sNativeProperties_propertyInfos[11];
560
561
static const NativePropertiesN<2> sNativeProperties = {
562
  false, 0,
563
  false, 0,
564
  false, 0,
565
  true,  0 /* sAttributes */,
566
  false, 0,
567
  false, 0,
568
  true,  1 /* sConstants */,
569
  -1,
570
  11,
571
  sNativeProperties_sortedPropertyIndices,
572
  {
573
    { sAttributes, &sNativeProperties_propertyInfos[0] },
574
    { sConstants, &sNativeProperties_propertyInfos[7] }
575
  }
576
};
577
static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
578
    "We have a property info count that is oversized");
579
580
static bool
581
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
582
0
{
583
0
  AUTO_PROFILER_LABEL_FAST("HTMLTrackElement constructor", DOM, cx);
584
0
585
0
  return HTMLConstructor(cx, argc, vp,
586
0
                         constructors::id::HTMLTrackElement,
587
0
                         prototypes::id::HTMLTrackElement,
588
0
                         CreateInterfaceObjects);
589
0
}
590
591
static const js::ClassOps sInterfaceObjectClassOps = {
592
    nullptr,               /* addProperty */
593
    nullptr,               /* delProperty */
594
    nullptr,               /* enumerate */
595
    nullptr,               /* newEnumerate */
596
    nullptr,               /* resolve */
597
    nullptr,               /* mayResolve */
598
    nullptr,               /* finalize */
599
    _constructor, /* call */
600
    nullptr,               /* hasInstance */
601
    _constructor, /* construct */
602
    nullptr,               /* trace */
603
};
604
605
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
606
  {
607
    "Function",
608
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
609
    &sInterfaceObjectClassOps,
610
    JS_NULL_CLASS_SPEC,
611
    JS_NULL_CLASS_EXT,
612
    &sInterfaceObjectClassObjectOps
613
  },
614
  eInterface,
615
  true,
616
  prototypes::id::HTMLTrackElement,
617
  PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth,
618
  sNativePropertyHooks,
619
  "function HTMLTrackElement() {\n    [native code]\n}",
620
  HTMLElement_Binding::GetConstructorObject
621
};
622
623
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
624
  {
625
    "HTMLTrackElementPrototype",
626
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
627
    JS_NULL_CLASS_OPS,
628
    JS_NULL_CLASS_SPEC,
629
    JS_NULL_CLASS_EXT,
630
    JS_NULL_OBJECT_OPS
631
  },
632
  eInterfacePrototype,
633
  false,
634
  prototypes::id::HTMLTrackElement,
635
  PrototypeTraits<prototypes::id::HTMLTrackElement>::Depth,
636
  sNativePropertyHooks,
637
  "[object HTMLTrackElementPrototype]",
638
  HTMLElement_Binding::GetProtoObject
639
};
640
641
static const js::ClassOps sClassOps = {
642
  _addProperty, /* addProperty */
643
  nullptr,               /* delProperty */
644
  nullptr,               /* enumerate */
645
  nullptr, /* newEnumerate */
646
  nullptr, /* resolve */
647
  nullptr, /* mayResolve */
648
  _finalize, /* finalize */
649
  nullptr, /* call */
650
  nullptr,               /* hasInstance */
651
  nullptr,               /* construct */
652
  nullptr, /* trace */
653
};
654
655
static const js::ClassExtension sClassExtension = {
656
  nullptr, /* weakmapKeyDelegateOp */
657
  _objectMoved /* objectMovedOp */
658
};
659
660
static const DOMJSClass sClass = {
661
  { "HTMLTrackElement",
662
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
663
    &sClassOps,
664
    JS_NULL_CLASS_SPEC,
665
    &sClassExtension,
666
    JS_NULL_OBJECT_OPS
667
  },
668
  { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLTrackElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
669
  IsBaseOf<nsISupports, mozilla::dom::HTMLTrackElement >::value,
670
  sNativePropertyHooks,
671
  FindAssociatedGlobalForNative<mozilla::dom::HTMLTrackElement>::Get,
672
  GetProtoObjectHandle,
673
  GetCCParticipant<mozilla::dom::HTMLTrackElement>::Get()
674
};
675
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
676
              "Must have the right minimal number of reserved slots.");
677
static_assert(1 >= 1,
678
              "Must have enough reserved slots.");
679
680
const JSClass*
681
GetJSClass()
682
0
{
683
0
  return sClass.ToJSClass();
684
0
}
685
686
bool
687
Wrap(JSContext* aCx, mozilla::dom::HTMLTrackElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
688
0
{
689
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::HTMLTrackElement>::value,
690
0
                "Shouldn't have wrappercached things that are not refcounted.");
691
0
  MOZ_ASSERT(static_cast<mozilla::dom::HTMLTrackElement*>(aObject) ==
692
0
             reinterpret_cast<mozilla::dom::HTMLTrackElement*>(aObject),
693
0
             "Multiple inheritance for mozilla::dom::HTMLTrackElement is broken.");
694
0
  MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
695
0
             reinterpret_cast<nsGenericHTMLElement*>(aObject),
696
0
             "Multiple inheritance for nsGenericHTMLElement is broken.");
697
0
  MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
698
0
             reinterpret_cast<mozilla::dom::Element*>(aObject),
699
0
             "Multiple inheritance for mozilla::dom::Element is broken.");
700
0
  MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
701
0
             reinterpret_cast<nsINode*>(aObject),
702
0
             "Multiple inheritance for nsINode is broken.");
703
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
704
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
705
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
706
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
707
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
708
0
  MOZ_ASSERT(!aCache->GetWrapper(),
709
0
             "You should probably not be using Wrap() directly; use "
710
0
             "GetOrCreateDOMReflector instead");
711
0
712
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
713
0
             "nsISupports must be on our primary inheritance chain");
714
0
715
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
716
0
  if (!global) {
717
0
    return false;
718
0
  }
719
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
720
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
721
0
722
0
  // That might have ended up wrapping us already, due to the wonders
723
0
  // of XBL.  Check for that, and bail out as needed.
724
0
  aReflector.set(aCache->GetWrapper());
725
0
  if (aReflector) {
726
#ifdef DEBUG
727
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
728
#endif // DEBUG
729
    return true;
730
0
  }
731
0
732
0
  JSAutoRealm ar(aCx, global);
733
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
734
0
  if (!canonicalProto) {
735
0
    return false;
736
0
  }
737
0
  JS::Rooted<JSObject*> proto(aCx);
738
0
  if (aGivenProto) {
739
0
    proto = aGivenProto;
740
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
741
0
    // coming in, we changed compartments to that of "parent" so may need
742
0
    // to wrap the proto here.
743
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
744
0
      if (!JS_WrapObject(aCx, &proto)) {
745
0
        return false;
746
0
      }
747
0
    }
748
0
  } else {
749
0
    proto = canonicalProto;
750
0
  }
751
0
752
0
  BindingJSObjectCreator<mozilla::dom::HTMLTrackElement> creator(aCx);
753
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
754
0
  if (!aReflector) {
755
0
    return false;
756
0
  }
757
0
758
0
  aCache->SetWrapper(aReflector);
759
0
  creator.InitializationSucceeded();
760
0
761
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
762
0
             aCache->GetWrapperPreserveColor() == aReflector);
763
0
  // If proto != canonicalProto, we have to preserve our wrapper;
764
0
  // otherwise we won't be able to properly recreate it later, since
765
0
  // we won't know what proto to use.  Note that we don't check
766
0
  // aGivenProto here, since it's entirely possible (and even
767
0
  // somewhat common) to have a non-null aGivenProto which is the
768
0
  // same as canonicalProto.
769
0
  if (proto != canonicalProto) {
770
0
    PreserveWrapper(aObject);
771
0
  }
772
0
773
0
  return true;
774
0
}
775
776
const NativePropertyHooks sNativePropertyHooks[] = { {
777
  nullptr,
778
  nullptr,
779
  nullptr,
780
  { sNativeProperties.Upcast(), nullptr },
781
  prototypes::id::HTMLTrackElement,
782
  constructors::id::HTMLTrackElement,
783
  HTMLElement_Binding::sNativePropertyHooks,
784
  &DefaultXrayExpandoObjectClass
785
} };
786
787
void
788
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
789
0
{
790
0
  JS::Handle<JSObject*> parentProto(HTMLElement_Binding::GetProtoObjectHandle(aCx));
791
0
  if (!parentProto) {
792
0
    return;
793
0
  }
794
0
795
0
  JS::Handle<JSObject*> constructorProto(HTMLElement_Binding::GetConstructorObjectHandle(aCx));
796
0
  if (!constructorProto) {
797
0
    return;
798
0
  }
799
0
800
0
  static bool sIdsInited = false;
801
0
  if (!sIdsInited && NS_IsMainThread()) {
802
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
803
0
      return;
804
0
    }
805
0
    sIdsInited = true;
806
0
  }
807
0
808
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLTrackElement);
809
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLTrackElement);
810
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
811
0
                              &sPrototypeClass.mBase, protoCache,
812
0
                              nullptr,
813
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
814
0
                              interfaceCache,
815
0
                              sNativeProperties.Upcast(),
816
0
                              nullptr,
817
0
                              "HTMLTrackElement", aDefineOnGlobal,
818
0
                              nullptr,
819
0
                              false);
820
0
}
821
822
JSObject*
823
GetConstructorObject(JSContext* aCx)
824
0
{
825
0
  return GetConstructorObjectHandle(aCx);
826
0
}
827
828
} // namespace HTMLTrackElement_Binding
829
830
831
832
} // namespace dom
833
} // namespace mozilla