Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/VTTCueBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM VTTCue.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "TextTrackCueBinding.h"
4
#include "VTTCueBinding.h"
5
#include "WrapperFactory.h"
6
#include "jsapi.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/Preferences.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/DocumentFragment.h"
13
#include "mozilla/dom/HTMLDivElement.h"
14
#include "mozilla/dom/NonRefcountedDOMObject.h"
15
#include "mozilla/dom/Nullable.h"
16
#include "mozilla/dom/PrimitiveConversions.h"
17
#include "mozilla/dom/TextTrackCue.h"
18
#include "mozilla/dom/TextTrackRegion.h"
19
#include "mozilla/dom/UnionConversions.h"
20
#include "mozilla/dom/XrayExpandoClass.h"
21
#include "nsContentUtils.h"
22
23
namespace mozilla {
24
namespace dom {
25
26
namespace binding_detail {}; // Just to make sure it's known as a namespace
27
using namespace mozilla::dom::binding_detail;
28
29
30
namespace AutoKeywordValues {
31
extern const EnumEntry strings[2] = {
32
  {"auto", 4},
33
  { nullptr, 0 }
34
};
35
} // namespace AutoKeywordValues
36
37
bool
38
ToJSValue(JSContext* aCx, AutoKeyword aArgument, JS::MutableHandle<JS::Value> aValue)
39
0
{
40
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(AutoKeywordValues::strings));
41
0
  JSString* resultStr =
42
0
    JS_NewStringCopyN(aCx, AutoKeywordValues::strings[uint32_t(aArgument)].value,
43
0
                      AutoKeywordValues::strings[uint32_t(aArgument)].length);
44
0
  if (!resultStr) {
45
0
    return false;
46
0
  }
47
0
  aValue.setString(resultStr);
48
0
  return true;
49
0
}
50
51
52
namespace LineAlignSettingValues {
53
extern const EnumEntry strings[4] = {
54
  {"start", 5},
55
  {"center", 6},
56
  {"end", 3},
57
  { nullptr, 0 }
58
};
59
} // namespace LineAlignSettingValues
60
61
bool
62
ToJSValue(JSContext* aCx, LineAlignSetting aArgument, JS::MutableHandle<JS::Value> aValue)
63
0
{
64
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(LineAlignSettingValues::strings));
65
0
  JSString* resultStr =
66
0
    JS_NewStringCopyN(aCx, LineAlignSettingValues::strings[uint32_t(aArgument)].value,
67
0
                      LineAlignSettingValues::strings[uint32_t(aArgument)].length);
68
0
  if (!resultStr) {
69
0
    return false;
70
0
  }
71
0
  aValue.setString(resultStr);
72
0
  return true;
73
0
}
74
75
76
namespace PositionAlignSettingValues {
77
extern const EnumEntry strings[5] = {
78
  {"line-left", 9},
79
  {"center", 6},
80
  {"line-right", 10},
81
  {"auto", 4},
82
  { nullptr, 0 }
83
};
84
} // namespace PositionAlignSettingValues
85
86
bool
87
ToJSValue(JSContext* aCx, PositionAlignSetting aArgument, JS::MutableHandle<JS::Value> aValue)
88
0
{
89
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PositionAlignSettingValues::strings));
90
0
  JSString* resultStr =
91
0
    JS_NewStringCopyN(aCx, PositionAlignSettingValues::strings[uint32_t(aArgument)].value,
92
0
                      PositionAlignSettingValues::strings[uint32_t(aArgument)].length);
93
0
  if (!resultStr) {
94
0
    return false;
95
0
  }
96
0
  aValue.setString(resultStr);
97
0
  return true;
98
0
}
99
100
101
namespace AlignSettingValues {
102
extern const EnumEntry strings[6] = {
103
  {"start", 5},
104
  {"center", 6},
105
  {"end", 3},
106
  {"left", 4},
107
  {"right", 5},
108
  { nullptr, 0 }
109
};
110
} // namespace AlignSettingValues
111
112
bool
113
ToJSValue(JSContext* aCx, AlignSetting aArgument, JS::MutableHandle<JS::Value> aValue)
114
0
{
115
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(AlignSettingValues::strings));
116
0
  JSString* resultStr =
117
0
    JS_NewStringCopyN(aCx, AlignSettingValues::strings[uint32_t(aArgument)].value,
118
0
                      AlignSettingValues::strings[uint32_t(aArgument)].length);
119
0
  if (!resultStr) {
120
0
    return false;
121
0
  }
122
0
  aValue.setString(resultStr);
123
0
  return true;
124
0
}
125
126
127
namespace DirectionSettingValues {
128
extern const EnumEntry strings[4] = {
129
  {"", 0},
130
  {"rl", 2},
131
  {"lr", 2},
132
  { nullptr, 0 }
133
};
134
} // namespace DirectionSettingValues
135
136
bool
137
ToJSValue(JSContext* aCx, DirectionSetting aArgument, JS::MutableHandle<JS::Value> aValue)
138
0
{
139
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(DirectionSettingValues::strings));
140
0
  JSString* resultStr =
141
0
    JS_NewStringCopyN(aCx, DirectionSettingValues::strings[uint32_t(aArgument)].value,
142
0
                      DirectionSettingValues::strings[uint32_t(aArgument)].length);
143
0
  if (!resultStr) {
144
0
    return false;
145
0
  }
146
0
  aValue.setString(resultStr);
147
0
  return true;
148
0
}
149
150
151
bool
152
DoubleOrAutoKeyword::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
153
0
{
154
0
  switch (mType) {
155
0
    case eUninitialized: {
156
0
      return false;
157
0
      break;
158
0
    }
159
0
    case eDouble: {
160
0
      rval.set(JS_NumberValue(double(mValue.mDouble.Value())));
161
0
      return true;
162
0
      break;
163
0
    }
164
0
    case eAutoKeyword: {
165
0
      if (!ToJSValue(cx, mValue.mAutoKeyword.Value(), rval)) {
166
0
        return false;
167
0
      }
168
0
      return true;
169
0
      break;
170
0
    }
171
0
    default: {
172
0
      return false;
173
0
      break;
174
0
    }
175
0
  }
176
0
177
0
  return false;
178
0
}
179
180
181
double&
182
OwningDoubleOrAutoKeyword::RawSetAsDouble()
183
0
{
184
0
  if (mType == eDouble) {
185
0
    return mValue.mDouble.Value();
186
0
  }
187
0
  MOZ_ASSERT(mType == eUninitialized);
188
0
  mType = eDouble;
189
0
  return mValue.mDouble.SetValue();
190
0
}
191
192
double&
193
OwningDoubleOrAutoKeyword::SetAsDouble()
194
0
{
195
0
  if (mType == eDouble) {
196
0
    return mValue.mDouble.Value();
197
0
  }
198
0
  Uninit();
199
0
  mType = eDouble;
200
0
  return mValue.mDouble.SetValue();
201
0
}
202
203
bool
204
OwningDoubleOrAutoKeyword::TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
205
0
{
206
0
  tryNext = false;
207
0
  { // scope for memberSlot
208
0
    double& memberSlot = RawSetAsDouble();
209
0
    if (!ValueToPrimitive<double, eDefault>(cx, value, &memberSlot)) {
210
0
      return false;
211
0
    } else if (!mozilla::IsFinite(memberSlot)) {
212
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "Member of DoubleOrAutoKeyword");
213
0
      return false;
214
0
    }
215
0
  }
216
0
  return true;
217
0
}
218
219
void
220
OwningDoubleOrAutoKeyword::DestroyDouble()
221
0
{
222
0
  MOZ_ASSERT(IsDouble(), "Wrong type!");
223
0
  mValue.mDouble.Destroy();
224
0
  mType = eUninitialized;
225
0
}
226
227
228
229
230
AutoKeyword&
231
OwningDoubleOrAutoKeyword::RawSetAsAutoKeyword()
232
0
{
233
0
  if (mType == eAutoKeyword) {
234
0
    return mValue.mAutoKeyword.Value();
235
0
  }
236
0
  MOZ_ASSERT(mType == eUninitialized);
237
0
  mType = eAutoKeyword;
238
0
  return mValue.mAutoKeyword.SetValue();
239
0
}
240
241
AutoKeyword&
242
OwningDoubleOrAutoKeyword::SetAsAutoKeyword()
243
0
{
244
0
  if (mType == eAutoKeyword) {
245
0
    return mValue.mAutoKeyword.Value();
246
0
  }
247
0
  Uninit();
248
0
  mType = eAutoKeyword;
249
0
  return mValue.mAutoKeyword.SetValue();
250
0
}
251
252
bool
253
OwningDoubleOrAutoKeyword::TrySetToAutoKeyword(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
254
0
{
255
0
  tryNext = false;
256
0
  { // scope for memberSlot
257
0
    AutoKeyword& memberSlot = RawSetAsAutoKeyword();
258
0
    {
259
0
      int index;
260
0
      if (!FindEnumStringIndex<true>(cx, value, AutoKeywordValues::strings, "AutoKeyword", "Member of DoubleOrAutoKeyword", &index)) {
261
0
        return false;
262
0
      }
263
0
      MOZ_ASSERT(index >= 0);
264
0
      memberSlot = static_cast<AutoKeyword>(index);
265
0
    }
266
0
  }
267
0
  return true;
268
0
}
269
270
void
271
OwningDoubleOrAutoKeyword::DestroyAutoKeyword()
272
0
{
273
0
  MOZ_ASSERT(IsAutoKeyword(), "Wrong type!");
274
0
  mValue.mAutoKeyword.Destroy();
275
0
  mType = eUninitialized;
276
0
}
277
278
279
280
281
void
282
OwningDoubleOrAutoKeyword::Uninit()
283
{
284
  switch (mType) {
285
    case eUninitialized: {
286
      break;
287
    }
288
    case eDouble: {
289
      DestroyDouble();
290
      break;
291
    }
292
    case eAutoKeyword: {
293
      DestroyAutoKeyword();
294
      break;
295
    }
296
  }
297
}
298
299
bool
300
OwningDoubleOrAutoKeyword::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
301
0
{
302
0
  switch (mType) {
303
0
    case eUninitialized: {
304
0
      return false;
305
0
      break;
306
0
    }
307
0
    case eDouble: {
308
0
      rval.set(JS_NumberValue(double(mValue.mDouble.Value())));
309
0
      return true;
310
0
      break;
311
0
    }
312
0
    case eAutoKeyword: {
313
0
      if (!ToJSValue(cx, mValue.mAutoKeyword.Value(), rval)) {
314
0
        return false;
315
0
      }
316
0
      return true;
317
0
      break;
318
0
    }
319
0
    default: {
320
0
      return false;
321
0
      break;
322
0
    }
323
0
  }
324
0
325
0
  return false;
326
0
}
327
328
void
329
OwningDoubleOrAutoKeyword::TraceUnion(JSTracer* trc)
330
0
{
331
0
}
332
333
OwningDoubleOrAutoKeyword&
334
OwningDoubleOrAutoKeyword::operator=(const OwningDoubleOrAutoKeyword& aOther)
335
0
{
336
0
  switch (aOther.mType) {
337
0
    case eUninitialized: {
338
0
      MOZ_ASSERT(mType == eUninitialized,
339
0
                 "We need to destroy ourselves?");
340
0
      break;
341
0
    }
342
0
    case eDouble: {
343
0
      SetAsDouble() = aOther.GetAsDouble();
344
0
      break;
345
0
    }
346
0
    case eAutoKeyword: {
347
0
      SetAsAutoKeyword() = aOther.GetAsAutoKeyword();
348
0
      break;
349
0
    }
350
0
  }
351
0
  return *this;
352
0
}
353
354
355
namespace VTTCue_Binding {
356
357
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<TextTrackCue_Binding::NativeType>::value,
358
              "Can't inherit from an interface with a different ownership model.");
359
360
MOZ_CAN_RUN_SCRIPT static bool
361
get_region(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
362
0
{
363
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.region", DOM, cx);
364
0
365
0
  auto result(StrongOrRawPtr<mozilla::dom::TextTrackRegion>(self->GetRegion()));
366
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
367
0
  if (!result) {
368
0
    args.rval().setNull();
369
0
    return true;
370
0
  }
371
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
372
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
373
0
    return false;
374
0
  }
375
0
  return true;
376
0
}
377
378
MOZ_CAN_RUN_SCRIPT static bool
379
set_region(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
380
0
{
381
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.region", DOM, cx);
382
0
383
0
  mozilla::dom::TextTrackRegion* arg0;
384
0
  if (args[0].isObject()) {
385
0
    {
386
0
      nsresult rv = UnwrapObject<prototypes::id::VTTRegion, mozilla::dom::TextTrackRegion>(args[0], arg0);
387
0
      if (NS_FAILED(rv)) {
388
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to VTTCue.region", "VTTRegion");
389
0
        return false;
390
0
      }
391
0
    }
392
0
  } else if (args[0].isNullOrUndefined()) {
393
0
    arg0 = nullptr;
394
0
  } else {
395
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to VTTCue.region");
396
0
    return false;
397
0
  }
398
0
  self->SetRegion(MOZ_KnownLive(Constify(arg0)));
399
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
400
0
401
0
  return true;
402
0
}
403
404
static const JSJitInfo region_getterinfo = {
405
  { (JSJitGetterOp)get_region },
406
  { prototypes::id::VTTCue },
407
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
408
  JSJitInfo::Getter,
409
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
410
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
411
  false,  /* isInfallible. False in setters. */
412
  false,  /* isMovable.  Not relevant for setters. */
413
  false, /* isEliminatable.  Not relevant for setters. */
414
  false, /* isAlwaysInSlot.  Only relevant for getters. */
415
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
416
  false,  /* isTypedMethod.  Only relevant for methods. */
417
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
418
};
419
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
420
static_assert(0 < 1, "There is no slot for us");
421
static const JSJitInfo region_setterinfo = {
422
  { (JSJitGetterOp)set_region },
423
  { prototypes::id::VTTCue },
424
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
425
  JSJitInfo::Setter,
426
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
427
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
428
  false,  /* isInfallible. False in setters. */
429
  false,  /* isMovable.  Not relevant for setters. */
430
  false, /* isEliminatable.  Not relevant for setters. */
431
  false, /* isAlwaysInSlot.  Only relevant for getters. */
432
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
433
  false,  /* isTypedMethod.  Only relevant for methods. */
434
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
435
};
436
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
437
static_assert(0 < 1, "There is no slot for us");
438
439
MOZ_CAN_RUN_SCRIPT static bool
440
get_vertical(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
441
0
{
442
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.vertical", DOM, cx);
443
0
444
0
  DirectionSetting result(self->Vertical());
445
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
446
0
  if (!ToJSValue(cx, result, args.rval())) {
447
0
    return false;
448
0
  }
449
0
  return true;
450
0
}
451
452
MOZ_CAN_RUN_SCRIPT static bool
453
set_vertical(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
454
0
{
455
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.vertical", DOM, cx);
456
0
457
0
  DirectionSetting arg0;
458
0
  {
459
0
    int index;
460
0
    if (!FindEnumStringIndex<false>(cx, args[0], DirectionSettingValues::strings, "DirectionSetting", "Value being assigned to VTTCue.vertical", &index)) {
461
0
      return false;
462
0
    }
463
0
    if (index < 0) {
464
0
      return true;
465
0
    }
466
0
    arg0 = static_cast<DirectionSetting>(index);
467
0
  }
468
0
  self->SetVertical(arg0);
469
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
470
0
471
0
  return true;
472
0
}
473
474
static const JSJitInfo vertical_getterinfo = {
475
  { (JSJitGetterOp)get_vertical },
476
  { prototypes::id::VTTCue },
477
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
478
  JSJitInfo::Getter,
479
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
480
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
481
  false,  /* isInfallible. False in setters. */
482
  false,  /* isMovable.  Not relevant for setters. */
483
  false, /* isEliminatable.  Not relevant for setters. */
484
  false, /* isAlwaysInSlot.  Only relevant for getters. */
485
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
486
  false,  /* isTypedMethod.  Only relevant for methods. */
487
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
488
};
489
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
490
static_assert(0 < 1, "There is no slot for us");
491
static const JSJitInfo vertical_setterinfo = {
492
  { (JSJitGetterOp)set_vertical },
493
  { prototypes::id::VTTCue },
494
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
495
  JSJitInfo::Setter,
496
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
497
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
498
  false,  /* isInfallible. False in setters. */
499
  false,  /* isMovable.  Not relevant for setters. */
500
  false, /* isEliminatable.  Not relevant for setters. */
501
  false, /* isAlwaysInSlot.  Only relevant for getters. */
502
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
503
  false,  /* isTypedMethod.  Only relevant for methods. */
504
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
505
};
506
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
507
static_assert(0 < 1, "There is no slot for us");
508
509
MOZ_CAN_RUN_SCRIPT static bool
510
get_snapToLines(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
511
0
{
512
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.snapToLines", DOM, cx);
513
0
514
0
  bool result(self->SnapToLines());
515
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
516
0
  args.rval().setBoolean(result);
517
0
  return true;
518
0
}
519
520
MOZ_CAN_RUN_SCRIPT static bool
521
set_snapToLines(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
522
0
{
523
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.snapToLines", DOM, cx);
524
0
525
0
  bool arg0;
526
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
527
0
    return false;
528
0
  }
529
0
  self->SetSnapToLines(arg0);
530
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
531
0
532
0
  return true;
533
0
}
534
535
static const JSJitInfo snapToLines_getterinfo = {
536
  { (JSJitGetterOp)get_snapToLines },
537
  { prototypes::id::VTTCue },
538
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
539
  JSJitInfo::Getter,
540
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
541
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
542
  true,  /* isInfallible. False in setters. */
543
  false,  /* isMovable.  Not relevant for setters. */
544
  false, /* isEliminatable.  Not relevant for setters. */
545
  false, /* isAlwaysInSlot.  Only relevant for getters. */
546
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
547
  false,  /* isTypedMethod.  Only relevant for methods. */
548
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
549
};
550
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
551
static_assert(0 < 1, "There is no slot for us");
552
static const JSJitInfo snapToLines_setterinfo = {
553
  { (JSJitGetterOp)set_snapToLines },
554
  { prototypes::id::VTTCue },
555
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
556
  JSJitInfo::Setter,
557
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
558
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
559
  false,  /* isInfallible. False in setters. */
560
  false,  /* isMovable.  Not relevant for setters. */
561
  false, /* isEliminatable.  Not relevant for setters. */
562
  false, /* isAlwaysInSlot.  Only relevant for getters. */
563
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
564
  false,  /* isTypedMethod.  Only relevant for methods. */
565
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
566
};
567
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
568
static_assert(0 < 1, "There is no slot for us");
569
570
MOZ_CAN_RUN_SCRIPT static bool
571
get_line(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
572
0
{
573
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.line", DOM, cx);
574
0
575
0
  OwningDoubleOrAutoKeyword result;
576
0
  self->GetLine(result);
577
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
578
0
  if (!result.ToJSVal(cx, obj, args.rval())) {
579
0
    return false;
580
0
  }
581
0
  return true;
582
0
}
583
584
MOZ_CAN_RUN_SCRIPT static bool
585
set_line(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
586
0
{
587
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.line", DOM, cx);
588
0
589
0
  DoubleOrAutoKeyword arg0;
590
0
  DoubleOrAutoKeywordArgument arg0_holder(arg0);
591
0
  {
592
0
    bool done = false, failed = false, tryNext;
593
0
    do {
594
0
      if (args[0].isNumber()) {
595
0
        done = (failed = !arg0_holder.TrySetToDouble(cx, args[0], tryNext)) || !tryNext;
596
0
        break;
597
0
      }
598
0
      done = (failed = !arg0_holder.TrySetToAutoKeyword(cx, args[0], tryNext)) || !tryNext;
599
0
      break;
600
0
    } while (false);
601
0
    if (failed) {
602
0
      return false;
603
0
    }
604
0
    if (!done) {
605
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to VTTCue.line", "");
606
0
      return false;
607
0
    }
608
0
  }
609
0
  self->SetLine(Constify(arg0));
610
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
611
0
612
0
  return true;
613
0
}
614
615
static const JSJitInfo line_getterinfo = {
616
  { (JSJitGetterOp)get_line },
617
  { prototypes::id::VTTCue },
618
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
619
  JSJitInfo::Getter,
620
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
621
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
622
  false,  /* isInfallible. False in setters. */
623
  false,  /* isMovable.  Not relevant for setters. */
624
  false, /* isEliminatable.  Not relevant for setters. */
625
  false, /* isAlwaysInSlot.  Only relevant for getters. */
626
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
627
  false,  /* isTypedMethod.  Only relevant for methods. */
628
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
629
};
630
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
631
static_assert(0 < 1, "There is no slot for us");
632
static const JSJitInfo line_setterinfo = {
633
  { (JSJitGetterOp)set_line },
634
  { prototypes::id::VTTCue },
635
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
636
  JSJitInfo::Setter,
637
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
638
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
639
  false,  /* isInfallible. False in setters. */
640
  false,  /* isMovable.  Not relevant for setters. */
641
  false, /* isEliminatable.  Not relevant for setters. */
642
  false, /* isAlwaysInSlot.  Only relevant for getters. */
643
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
644
  false,  /* isTypedMethod.  Only relevant for methods. */
645
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
646
};
647
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
648
static_assert(0 < 1, "There is no slot for us");
649
650
MOZ_CAN_RUN_SCRIPT static bool
651
get_lineAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
652
0
{
653
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.lineAlign", DOM, cx);
654
0
655
0
  LineAlignSetting result(self->LineAlign());
656
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
657
0
  if (!ToJSValue(cx, result, args.rval())) {
658
0
    return false;
659
0
  }
660
0
  return true;
661
0
}
662
663
MOZ_CAN_RUN_SCRIPT static bool
664
set_lineAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
665
0
{
666
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.lineAlign", DOM, cx);
667
0
668
0
  LineAlignSetting arg0;
669
0
  {
670
0
    int index;
671
0
    if (!FindEnumStringIndex<false>(cx, args[0], LineAlignSettingValues::strings, "LineAlignSetting", "Value being assigned to VTTCue.lineAlign", &index)) {
672
0
      return false;
673
0
    }
674
0
    if (index < 0) {
675
0
      return true;
676
0
    }
677
0
    arg0 = static_cast<LineAlignSetting>(index);
678
0
  }
679
0
  FastErrorResult rv;
680
0
  self->SetLineAlign(arg0, rv);
681
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
682
0
    return false;
683
0
  }
684
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
685
0
686
0
  return true;
687
0
}
688
689
static const JSJitInfo lineAlign_getterinfo = {
690
  { (JSJitGetterOp)get_lineAlign },
691
  { prototypes::id::VTTCue },
692
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
693
  JSJitInfo::Getter,
694
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
695
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
696
  false,  /* isInfallible. False in setters. */
697
  false,  /* isMovable.  Not relevant for setters. */
698
  false, /* isEliminatable.  Not relevant for setters. */
699
  false, /* isAlwaysInSlot.  Only relevant for getters. */
700
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
701
  false,  /* isTypedMethod.  Only relevant for methods. */
702
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
703
};
704
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
705
static_assert(0 < 1, "There is no slot for us");
706
static const JSJitInfo lineAlign_setterinfo = {
707
  { (JSJitGetterOp)set_lineAlign },
708
  { prototypes::id::VTTCue },
709
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
710
  JSJitInfo::Setter,
711
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
712
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
713
  false,  /* isInfallible. False in setters. */
714
  false,  /* isMovable.  Not relevant for setters. */
715
  false, /* isEliminatable.  Not relevant for setters. */
716
  false, /* isAlwaysInSlot.  Only relevant for getters. */
717
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
718
  false,  /* isTypedMethod.  Only relevant for methods. */
719
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
720
};
721
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
722
static_assert(0 < 1, "There is no slot for us");
723
724
MOZ_CAN_RUN_SCRIPT static bool
725
get_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
726
0
{
727
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.position", DOM, cx);
728
0
729
0
  OwningDoubleOrAutoKeyword result;
730
0
  self->GetPosition(result);
731
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
732
0
  if (!result.ToJSVal(cx, obj, args.rval())) {
733
0
    return false;
734
0
  }
735
0
  return true;
736
0
}
737
738
MOZ_CAN_RUN_SCRIPT static bool
739
set_position(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
740
0
{
741
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.position", DOM, cx);
742
0
743
0
  DoubleOrAutoKeyword arg0;
744
0
  DoubleOrAutoKeywordArgument arg0_holder(arg0);
745
0
  {
746
0
    bool done = false, failed = false, tryNext;
747
0
    do {
748
0
      if (args[0].isNumber()) {
749
0
        done = (failed = !arg0_holder.TrySetToDouble(cx, args[0], tryNext)) || !tryNext;
750
0
        break;
751
0
      }
752
0
      done = (failed = !arg0_holder.TrySetToAutoKeyword(cx, args[0], tryNext)) || !tryNext;
753
0
      break;
754
0
    } while (false);
755
0
    if (failed) {
756
0
      return false;
757
0
    }
758
0
    if (!done) {
759
0
      ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to VTTCue.position", "");
760
0
      return false;
761
0
    }
762
0
  }
763
0
  FastErrorResult rv;
764
0
  self->SetPosition(Constify(arg0), rv);
765
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
766
0
    return false;
767
0
  }
768
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
769
0
770
0
  return true;
771
0
}
772
773
static const JSJitInfo position_getterinfo = {
774
  { (JSJitGetterOp)get_position },
775
  { prototypes::id::VTTCue },
776
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
777
  JSJitInfo::Getter,
778
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
779
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
780
  false,  /* isInfallible. False in setters. */
781
  false,  /* isMovable.  Not relevant for setters. */
782
  false, /* isEliminatable.  Not relevant for setters. */
783
  false, /* isAlwaysInSlot.  Only relevant for getters. */
784
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
785
  false,  /* isTypedMethod.  Only relevant for methods. */
786
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
787
};
788
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
789
static_assert(0 < 1, "There is no slot for us");
790
static const JSJitInfo position_setterinfo = {
791
  { (JSJitGetterOp)set_position },
792
  { prototypes::id::VTTCue },
793
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
794
  JSJitInfo::Setter,
795
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
796
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
797
  false,  /* isInfallible. False in setters. */
798
  false,  /* isMovable.  Not relevant for setters. */
799
  false, /* isEliminatable.  Not relevant for setters. */
800
  false, /* isAlwaysInSlot.  Only relevant for getters. */
801
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
802
  false,  /* isTypedMethod.  Only relevant for methods. */
803
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
804
};
805
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
806
static_assert(0 < 1, "There is no slot for us");
807
808
MOZ_CAN_RUN_SCRIPT static bool
809
get_positionAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
810
0
{
811
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.positionAlign", DOM, cx);
812
0
813
0
  PositionAlignSetting result(self->PositionAlign());
814
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
815
0
  if (!ToJSValue(cx, result, args.rval())) {
816
0
    return false;
817
0
  }
818
0
  return true;
819
0
}
820
821
MOZ_CAN_RUN_SCRIPT static bool
822
set_positionAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
823
0
{
824
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.positionAlign", DOM, cx);
825
0
826
0
  PositionAlignSetting arg0;
827
0
  {
828
0
    int index;
829
0
    if (!FindEnumStringIndex<false>(cx, args[0], PositionAlignSettingValues::strings, "PositionAlignSetting", "Value being assigned to VTTCue.positionAlign", &index)) {
830
0
      return false;
831
0
    }
832
0
    if (index < 0) {
833
0
      return true;
834
0
    }
835
0
    arg0 = static_cast<PositionAlignSetting>(index);
836
0
  }
837
0
  FastErrorResult rv;
838
0
  self->SetPositionAlign(arg0, rv);
839
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
840
0
    return false;
841
0
  }
842
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
843
0
844
0
  return true;
845
0
}
846
847
static const JSJitInfo positionAlign_getterinfo = {
848
  { (JSJitGetterOp)get_positionAlign },
849
  { prototypes::id::VTTCue },
850
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
851
  JSJitInfo::Getter,
852
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
853
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
854
  false,  /* isInfallible. False in setters. */
855
  false,  /* isMovable.  Not relevant for setters. */
856
  false, /* isEliminatable.  Not relevant for setters. */
857
  false, /* isAlwaysInSlot.  Only relevant for getters. */
858
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
859
  false,  /* isTypedMethod.  Only relevant for methods. */
860
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
861
};
862
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
863
static_assert(0 < 1, "There is no slot for us");
864
static const JSJitInfo positionAlign_setterinfo = {
865
  { (JSJitGetterOp)set_positionAlign },
866
  { prototypes::id::VTTCue },
867
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
868
  JSJitInfo::Setter,
869
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
870
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
871
  false,  /* isInfallible. False in setters. */
872
  false,  /* isMovable.  Not relevant for setters. */
873
  false, /* isEliminatable.  Not relevant for setters. */
874
  false, /* isAlwaysInSlot.  Only relevant for getters. */
875
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
876
  false,  /* isTypedMethod.  Only relevant for methods. */
877
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
878
};
879
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
880
static_assert(0 < 1, "There is no slot for us");
881
882
MOZ_CAN_RUN_SCRIPT static bool
883
get_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
884
0
{
885
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.size", DOM, cx);
886
0
887
0
  double result(self->Size());
888
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
889
0
  args.rval().set(JS_NumberValue(double(result)));
890
0
  return true;
891
0
}
892
893
MOZ_CAN_RUN_SCRIPT static bool
894
set_size(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
895
0
{
896
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.size", DOM, cx);
897
0
898
0
  double arg0;
899
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
900
0
    return false;
901
0
  } else if (!mozilla::IsFinite(arg0)) {
902
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to VTTCue.size");
903
0
    return false;
904
0
  }
905
0
  FastErrorResult rv;
906
0
  self->SetSize(arg0, rv);
907
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
908
0
    return false;
909
0
  }
910
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
911
0
912
0
  return true;
913
0
}
914
915
static const JSJitInfo size_getterinfo = {
916
  { (JSJitGetterOp)get_size },
917
  { prototypes::id::VTTCue },
918
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
919
  JSJitInfo::Getter,
920
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
921
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
922
  true,  /* isInfallible. False in setters. */
923
  false,  /* isMovable.  Not relevant for setters. */
924
  false, /* isEliminatable.  Not relevant for setters. */
925
  false, /* isAlwaysInSlot.  Only relevant for getters. */
926
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
927
  false,  /* isTypedMethod.  Only relevant for methods. */
928
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
929
};
930
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
931
static_assert(0 < 1, "There is no slot for us");
932
static const JSJitInfo size_setterinfo = {
933
  { (JSJitGetterOp)set_size },
934
  { prototypes::id::VTTCue },
935
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
936
  JSJitInfo::Setter,
937
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
938
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
939
  false,  /* isInfallible. False in setters. */
940
  false,  /* isMovable.  Not relevant for setters. */
941
  false, /* isEliminatable.  Not relevant for setters. */
942
  false, /* isAlwaysInSlot.  Only relevant for getters. */
943
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
944
  false,  /* isTypedMethod.  Only relevant for methods. */
945
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
946
};
947
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
948
static_assert(0 < 1, "There is no slot for us");
949
950
MOZ_CAN_RUN_SCRIPT static bool
951
get_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
952
0
{
953
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.align", DOM, cx);
954
0
955
0
  AlignSetting result(self->Align());
956
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
957
0
  if (!ToJSValue(cx, result, args.rval())) {
958
0
    return false;
959
0
  }
960
0
  return true;
961
0
}
962
963
MOZ_CAN_RUN_SCRIPT static bool
964
set_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
965
0
{
966
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.align", DOM, cx);
967
0
968
0
  AlignSetting arg0;
969
0
  {
970
0
    int index;
971
0
    if (!FindEnumStringIndex<false>(cx, args[0], AlignSettingValues::strings, "AlignSetting", "Value being assigned to VTTCue.align", &index)) {
972
0
      return false;
973
0
    }
974
0
    if (index < 0) {
975
0
      return true;
976
0
    }
977
0
    arg0 = static_cast<AlignSetting>(index);
978
0
  }
979
0
  self->SetAlign(arg0);
980
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
981
0
982
0
  return true;
983
0
}
984
985
static const JSJitInfo align_getterinfo = {
986
  { (JSJitGetterOp)get_align },
987
  { prototypes::id::VTTCue },
988
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
989
  JSJitInfo::Getter,
990
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
991
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
992
  false,  /* isInfallible. False in setters. */
993
  false,  /* isMovable.  Not relevant for setters. */
994
  false, /* isEliminatable.  Not relevant for setters. */
995
  false, /* isAlwaysInSlot.  Only relevant for getters. */
996
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
997
  false,  /* isTypedMethod.  Only relevant for methods. */
998
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
999
};
1000
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1001
static_assert(0 < 1, "There is no slot for us");
1002
static const JSJitInfo align_setterinfo = {
1003
  { (JSJitGetterOp)set_align },
1004
  { prototypes::id::VTTCue },
1005
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1006
  JSJitInfo::Setter,
1007
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1008
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1009
  false,  /* isInfallible. False in setters. */
1010
  false,  /* isMovable.  Not relevant for setters. */
1011
  false, /* isEliminatable.  Not relevant for setters. */
1012
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1013
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1014
  false,  /* isTypedMethod.  Only relevant for methods. */
1015
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1016
};
1017
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1018
static_assert(0 < 1, "There is no slot for us");
1019
1020
MOZ_CAN_RUN_SCRIPT static bool
1021
get_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1022
0
{
1023
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.text", DOM, cx);
1024
0
1025
0
  DOMString result;
1026
0
  self->GetText(result);
1027
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1028
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
1029
0
    return false;
1030
0
  }
1031
0
  return true;
1032
0
}
1033
1034
MOZ_CAN_RUN_SCRIPT static bool
1035
set_text(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
1036
0
{
1037
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.text", DOM, cx);
1038
0
1039
0
  binding_detail::FakeString arg0;
1040
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
1041
0
    return false;
1042
0
  }
1043
0
  self->SetText(NonNullHelper(Constify(arg0)));
1044
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1045
0
1046
0
  return true;
1047
0
}
1048
1049
static const JSJitInfo text_getterinfo = {
1050
  { (JSJitGetterOp)get_text },
1051
  { prototypes::id::VTTCue },
1052
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1053
  JSJitInfo::Getter,
1054
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1055
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1056
  false,  /* isInfallible. False in setters. */
1057
  false,  /* isMovable.  Not relevant for setters. */
1058
  false, /* isEliminatable.  Not relevant for setters. */
1059
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1060
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1061
  false,  /* isTypedMethod.  Only relevant for methods. */
1062
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1063
};
1064
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1065
static_assert(0 < 1, "There is no slot for us");
1066
static const JSJitInfo text_setterinfo = {
1067
  { (JSJitGetterOp)set_text },
1068
  { prototypes::id::VTTCue },
1069
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1070
  JSJitInfo::Setter,
1071
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1072
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1073
  false,  /* isInfallible. False in setters. */
1074
  false,  /* isMovable.  Not relevant for setters. */
1075
  false, /* isEliminatable.  Not relevant for setters. */
1076
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1077
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1078
  false,  /* isTypedMethod.  Only relevant for methods. */
1079
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1080
};
1081
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1082
static_assert(0 < 1, "There is no slot for us");
1083
1084
MOZ_CAN_RUN_SCRIPT static bool
1085
getCueAsHTML(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, const JSJitMethodCallArgs& args)
1086
0
{
1087
0
  AUTO_PROFILER_LABEL_FAST("VTTCue.getCueAsHTML", DOM, cx);
1088
0
1089
0
  auto result(StrongOrRawPtr<mozilla::dom::DocumentFragment>(self->GetCueAsHTML()));
1090
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1091
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1092
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1093
0
    return false;
1094
0
  }
1095
0
  return true;
1096
0
}
1097
1098
static const JSJitInfo getCueAsHTML_methodinfo = {
1099
  { (JSJitGetterOp)getCueAsHTML },
1100
  { prototypes::id::VTTCue },
1101
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1102
  JSJitInfo::Method,
1103
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1104
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1105
  false,  /* isInfallible. False in setters. */
1106
  false,  /* isMovable.  Not relevant for setters. */
1107
  false, /* isEliminatable.  Not relevant for setters. */
1108
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1109
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1110
  false,  /* isTypedMethod.  Only relevant for methods. */
1111
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1112
};
1113
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1114
static_assert(0 < 1, "There is no slot for us");
1115
1116
MOZ_CAN_RUN_SCRIPT static bool
1117
get_displayState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1118
0
{
1119
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.displayState", DOM, cx);
1120
0
1121
0
  auto result(StrongOrRawPtr<mozilla::dom::HTMLDivElement>(self->GetDisplayState()));
1122
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1123
0
  if (!result) {
1124
0
    args.rval().setNull();
1125
0
    return true;
1126
0
  }
1127
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1128
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1129
0
    return false;
1130
0
  }
1131
0
  return true;
1132
0
}
1133
1134
MOZ_CAN_RUN_SCRIPT static bool
1135
set_displayState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitSetterCallArgs args)
1136
0
{
1137
0
  AUTO_PROFILER_LABEL_FAST("set VTTCue.displayState", DOM, cx);
1138
0
1139
0
  mozilla::dom::HTMLDivElement* arg0;
1140
0
  if (args[0].isObject()) {
1141
0
    {
1142
0
      nsresult rv = UnwrapObject<prototypes::id::HTMLDivElement, mozilla::dom::HTMLDivElement>(args[0], arg0);
1143
0
      if (NS_FAILED(rv)) {
1144
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to VTTCue.displayState", "HTMLDivElement");
1145
0
        return false;
1146
0
      }
1147
0
    }
1148
0
  } else if (args[0].isNullOrUndefined()) {
1149
0
    arg0 = nullptr;
1150
0
  } else {
1151
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to VTTCue.displayState");
1152
0
    return false;
1153
0
  }
1154
0
  self->SetDisplayState(MOZ_KnownLive(Constify(arg0)));
1155
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1156
0
1157
0
  return true;
1158
0
}
1159
1160
static const JSJitInfo displayState_getterinfo = {
1161
  { (JSJitGetterOp)get_displayState },
1162
  { prototypes::id::VTTCue },
1163
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1164
  JSJitInfo::Getter,
1165
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1166
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
1167
  false,  /* isInfallible. False in setters. */
1168
  false,  /* isMovable.  Not relevant for setters. */
1169
  false, /* isEliminatable.  Not relevant for setters. */
1170
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1171
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1172
  false,  /* isTypedMethod.  Only relevant for methods. */
1173
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1174
};
1175
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1176
static_assert(0 < 1, "There is no slot for us");
1177
static const JSJitInfo displayState_setterinfo = {
1178
  { (JSJitGetterOp)set_displayState },
1179
  { prototypes::id::VTTCue },
1180
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1181
  JSJitInfo::Setter,
1182
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1183
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1184
  false,  /* isInfallible. False in setters. */
1185
  false,  /* isMovable.  Not relevant for setters. */
1186
  false, /* isEliminatable.  Not relevant for setters. */
1187
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1188
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1189
  false,  /* isTypedMethod.  Only relevant for methods. */
1190
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1191
};
1192
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1193
static_assert(0 < 1, "There is no slot for us");
1194
1195
MOZ_CAN_RUN_SCRIPT static bool
1196
get_hasBeenReset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1197
0
{
1198
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.hasBeenReset", DOM, cx);
1199
0
1200
0
  bool result(self->HasBeenReset());
1201
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1202
0
  args.rval().setBoolean(result);
1203
0
  return true;
1204
0
}
1205
1206
static const JSJitInfo hasBeenReset_getterinfo = {
1207
  { (JSJitGetterOp)get_hasBeenReset },
1208
  { prototypes::id::VTTCue },
1209
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1210
  JSJitInfo::Getter,
1211
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1212
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1213
  true,  /* isInfallible. False in setters. */
1214
  false,  /* isMovable.  Not relevant for setters. */
1215
  false, /* isEliminatable.  Not relevant for setters. */
1216
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1217
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1218
  false,  /* isTypedMethod.  Only relevant for methods. */
1219
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1220
};
1221
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1222
static_assert(0 < 1, "There is no slot for us");
1223
1224
MOZ_CAN_RUN_SCRIPT static bool
1225
get_computedLine(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1226
0
{
1227
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.computedLine", DOM, cx);
1228
0
1229
0
  double result(self->ComputedLine());
1230
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1231
0
  args.rval().set(JS_NumberValue(double(result)));
1232
0
  return true;
1233
0
}
1234
1235
static const JSJitInfo computedLine_getterinfo = {
1236
  { (JSJitGetterOp)get_computedLine },
1237
  { prototypes::id::VTTCue },
1238
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1239
  JSJitInfo::Getter,
1240
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1241
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1242
  true,  /* isInfallible. False in setters. */
1243
  false,  /* isMovable.  Not relevant for setters. */
1244
  false, /* isEliminatable.  Not relevant for setters. */
1245
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1246
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1247
  false,  /* isTypedMethod.  Only relevant for methods. */
1248
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1249
};
1250
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1251
static_assert(0 < 1, "There is no slot for us");
1252
1253
MOZ_CAN_RUN_SCRIPT static bool
1254
get_computedPosition(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1255
0
{
1256
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.computedPosition", DOM, cx);
1257
0
1258
0
  double result(self->ComputedPosition());
1259
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1260
0
  args.rval().set(JS_NumberValue(double(result)));
1261
0
  return true;
1262
0
}
1263
1264
static const JSJitInfo computedPosition_getterinfo = {
1265
  { (JSJitGetterOp)get_computedPosition },
1266
  { prototypes::id::VTTCue },
1267
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1268
  JSJitInfo::Getter,
1269
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1270
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
1271
  true,  /* isInfallible. False in setters. */
1272
  false,  /* isMovable.  Not relevant for setters. */
1273
  false, /* isEliminatable.  Not relevant for setters. */
1274
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1275
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1276
  false,  /* isTypedMethod.  Only relevant for methods. */
1277
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1278
};
1279
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1280
static_assert(0 < 1, "There is no slot for us");
1281
1282
MOZ_CAN_RUN_SCRIPT static bool
1283
get_computedPositionAlign(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1284
0
{
1285
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.computedPositionAlign", DOM, cx);
1286
0
1287
0
  PositionAlignSetting result(self->ComputedPositionAlign());
1288
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1289
0
  if (!ToJSValue(cx, result, args.rval())) {
1290
0
    return false;
1291
0
  }
1292
0
  return true;
1293
0
}
1294
1295
static const JSJitInfo computedPositionAlign_getterinfo = {
1296
  { (JSJitGetterOp)get_computedPositionAlign },
1297
  { prototypes::id::VTTCue },
1298
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1299
  JSJitInfo::Getter,
1300
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1301
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
1302
  false,  /* isInfallible. False in setters. */
1303
  false,  /* isMovable.  Not relevant for setters. */
1304
  false, /* isEliminatable.  Not relevant for setters. */
1305
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1306
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1307
  false,  /* isTypedMethod.  Only relevant for methods. */
1308
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1309
};
1310
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1311
static_assert(0 < 1, "There is no slot for us");
1312
1313
MOZ_CAN_RUN_SCRIPT static bool
1314
get_getActive(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCue* self, JSJitGetterCallArgs args)
1315
0
{
1316
0
  AUTO_PROFILER_LABEL_FAST("get VTTCue.getActive", DOM, cx);
1317
0
1318
0
  bool result(self->GetActive());
1319
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1320
0
  args.rval().setBoolean(result);
1321
0
  return true;
1322
0
}
1323
1324
static const JSJitInfo getActive_getterinfo = {
1325
  { (JSJitGetterOp)get_getActive },
1326
  { prototypes::id::VTTCue },
1327
  { PrototypeTraits<prototypes::id::VTTCue>::Depth },
1328
  JSJitInfo::Getter,
1329
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1330
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1331
  true,  /* isInfallible. False in setters. */
1332
  false,  /* isMovable.  Not relevant for setters. */
1333
  false, /* isEliminatable.  Not relevant for setters. */
1334
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1335
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1336
  false,  /* isTypedMethod.  Only relevant for methods. */
1337
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1338
};
1339
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1340
static_assert(0 < 1, "There is no slot for us");
1341
1342
static bool
1343
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1344
0
{
1345
0
  mozilla::dom::TextTrackCue* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextTrackCue>(obj);
1346
0
  // We don't want to preserve if we don't have a wrapper, and we
1347
0
  // obviously can't preserve if we're not initialized.
1348
0
  if (self && self->GetWrapperPreserveColor()) {
1349
0
    PreserveWrapper(self);
1350
0
  }
1351
0
  return true;
1352
0
}
1353
1354
static void
1355
_finalize(js::FreeOp* fop, JSObject* obj)
1356
0
{
1357
0
  mozilla::dom::TextTrackCue* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextTrackCue>(obj);
1358
0
  if (self) {
1359
0
    ClearWrapper(self, self, obj);
1360
0
    AddForDeferredFinalization<mozilla::dom::TextTrackCue>(self);
1361
0
  }
1362
0
}
1363
1364
static size_t
1365
_objectMoved(JSObject* obj, JSObject* old)
1366
0
{
1367
0
  mozilla::dom::TextTrackCue* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextTrackCue>(obj);
1368
0
  if (self) {
1369
0
    UpdateWrapper(self, self, obj, old);
1370
0
  }
1371
0
1372
0
  return 0;
1373
0
}
1374
1375
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1376
#if defined(__clang__)
1377
#pragma clang diagnostic push
1378
#pragma clang diagnostic ignored "-Wmissing-braces"
1379
#endif
1380
static const JSFunctionSpec sMethods_specs[] = {
1381
  JS_FNSPEC("getCueAsHTML", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getCueAsHTML_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1382
  JS_FS_END
1383
};
1384
#if defined(__clang__)
1385
#pragma clang diagnostic pop
1386
#endif
1387
1388
1389
static const Prefable<const JSFunctionSpec> sMethods[] = {
1390
  { nullptr, &sMethods_specs[0] },
1391
  { nullptr, nullptr }
1392
};
1393
1394
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1395
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1396
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1397
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1398
1399
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1400
#if defined(__clang__)
1401
#pragma clang diagnostic push
1402
#pragma clang diagnostic ignored "-Wmissing-braces"
1403
#endif
1404
static const JSPropertySpec sAttributes_specs[] = {
1405
  { "region", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &region_getterinfo, GenericSetter<NormalThisPolicy>, &region_setterinfo },
1406
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1407
  { "vertical", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &vertical_getterinfo, GenericSetter<NormalThisPolicy>, &vertical_setterinfo },
1408
  { "snapToLines", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &snapToLines_getterinfo, GenericSetter<NormalThisPolicy>, &snapToLines_setterinfo },
1409
  { "line", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &line_getterinfo, GenericSetter<NormalThisPolicy>, &line_setterinfo },
1410
  { "lineAlign", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &lineAlign_getterinfo, GenericSetter<NormalThisPolicy>, &lineAlign_setterinfo },
1411
  { "position", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &position_getterinfo, GenericSetter<NormalThisPolicy>, &position_setterinfo },
1412
  { "positionAlign", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &positionAlign_getterinfo, GenericSetter<NormalThisPolicy>, &positionAlign_setterinfo },
1413
  { "size", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &size_getterinfo, GenericSetter<NormalThisPolicy>, &size_setterinfo },
1414
  { "align", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &align_getterinfo, GenericSetter<NormalThisPolicy>, &align_setterinfo },
1415
  { "text", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &text_getterinfo, GenericSetter<NormalThisPolicy>, &text_setterinfo },
1416
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1417
};
1418
#if defined(__clang__)
1419
#pragma clang diagnostic pop
1420
#endif
1421
1422
// Can't be const because the pref-enabled boolean needs to be writable
1423
static PrefableDisablers sAttributes_disablers0 = {
1424
  true, false, 0, nullptr
1425
};
1426
1427
static const Prefable<const JSPropertySpec> sAttributes[] = {
1428
  { &sAttributes_disablers0, &sAttributes_specs[0] },
1429
  { nullptr, &sAttributes_specs[2] },
1430
  { nullptr, nullptr }
1431
};
1432
1433
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1434
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1435
static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1436
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1437
1438
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1439
#if defined(__clang__)
1440
#pragma clang diagnostic push
1441
#pragma clang diagnostic ignored "-Wmissing-braces"
1442
#endif
1443
static const JSPropertySpec sChromeAttributes_specs[] = {
1444
  { "displayState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &displayState_getterinfo, GenericSetter<NormalThisPolicy>, &displayState_setterinfo },
1445
  { "hasBeenReset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &hasBeenReset_getterinfo, nullptr, nullptr },
1446
  { "computedLine", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &computedLine_getterinfo, nullptr, nullptr },
1447
  { "computedPosition", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &computedPosition_getterinfo, nullptr, nullptr },
1448
  { "computedPositionAlign", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &computedPositionAlign_getterinfo, nullptr, nullptr },
1449
  { "getActive", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &getActive_getterinfo, nullptr, nullptr },
1450
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1451
};
1452
#if defined(__clang__)
1453
#pragma clang diagnostic pop
1454
#endif
1455
1456
1457
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
1458
  { nullptr, &sChromeAttributes_specs[0] },
1459
  { nullptr, nullptr }
1460
};
1461
1462
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1463
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1464
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1465
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1466
1467
1468
static uint16_t sNativeProperties_sortedPropertyIndices[11];
1469
static PropertyInfo sNativeProperties_propertyInfos[11];
1470
1471
static const NativePropertiesN<2> sNativeProperties = {
1472
  false, 0,
1473
  false, 0,
1474
  true,  0 /* sMethods */,
1475
  true,  1 /* sAttributes */,
1476
  false, 0,
1477
  false, 0,
1478
  false, 0,
1479
  -1,
1480
  11,
1481
  sNativeProperties_sortedPropertyIndices,
1482
  {
1483
    { sMethods, &sNativeProperties_propertyInfos[0] },
1484
    { sAttributes, &sNativeProperties_propertyInfos[1] }
1485
  }
1486
};
1487
static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1488
    "We have a property info count that is oversized");
1489
1490
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[6];
1491
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[6];
1492
1493
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1494
  false, 0,
1495
  false, 0,
1496
  false, 0,
1497
  true,  0 /* sChromeAttributes */,
1498
  false, 0,
1499
  false, 0,
1500
  false, 0,
1501
  -1,
1502
  6,
1503
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1504
  {
1505
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
1506
  }
1507
};
1508
static_assert(6 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1509
    "We have a property info count that is oversized");
1510
1511
static bool
1512
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1513
0
{
1514
0
  AUTO_PROFILER_LABEL_FAST("VTTCue constructor", DOM, cx);
1515
0
1516
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1517
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1518
0
  if (!args.isConstructing()) {
1519
0
    // XXXbz wish I could get the name from the callee instead of
1520
0
    // Adding more relocations
1521
0
    return ThrowConstructorWithoutNew(cx, "VTTCue");
1522
0
  }
1523
0
1524
0
  JS::Rooted<JSObject*> desiredProto(cx);
1525
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1526
0
    return false;
1527
0
  }
1528
0
1529
0
  if (MOZ_UNLIKELY(args.length() < 3)) {
1530
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "VTTCue");
1531
0
  }
1532
0
  GlobalObject global(cx, obj);
1533
0
  if (global.Failed()) {
1534
0
    return false;
1535
0
  }
1536
0
1537
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1538
0
  double arg0;
1539
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
1540
0
    return false;
1541
0
  } else if (!mozilla::IsFinite(arg0)) {
1542
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of VTTCue.constructor");
1543
0
    return false;
1544
0
  }
1545
0
  double arg1;
1546
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
1547
0
    return false;
1548
0
  } else if (!mozilla::IsFinite(arg1)) {
1549
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of VTTCue.constructor");
1550
0
    return false;
1551
0
  }
1552
0
  binding_detail::FakeString arg2;
1553
0
  if (!ConvertJSValueToString(cx, args[2], eStringify, eStringify, arg2)) {
1554
0
    return false;
1555
0
  }
1556
0
  Maybe<JSAutoRealm> ar;
1557
0
  if (objIsXray) {
1558
0
    obj = js::CheckedUnwrap(obj);
1559
0
    if (!obj) {
1560
0
      return false;
1561
0
    }
1562
0
    ar.emplace(cx, obj);
1563
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1564
0
      return false;
1565
0
    }
1566
0
  }
1567
0
  FastErrorResult rv;
1568
0
  auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(mozilla::dom::TextTrackCue::Constructor(global, arg0, arg1, NonNullHelper(Constify(arg2)), rv)));
1569
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1570
0
    return false;
1571
0
  }
1572
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1573
0
  static_assert(!IsPointer<decltype(result)>::value,
1574
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1575
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1576
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1577
0
    return false;
1578
0
  }
1579
0
  return true;
1580
0
}
1581
1582
static const js::ClassOps sInterfaceObjectClassOps = {
1583
    nullptr,               /* addProperty */
1584
    nullptr,               /* delProperty */
1585
    nullptr,               /* enumerate */
1586
    nullptr,               /* newEnumerate */
1587
    nullptr,               /* resolve */
1588
    nullptr,               /* mayResolve */
1589
    nullptr,               /* finalize */
1590
    _constructor, /* call */
1591
    nullptr,               /* hasInstance */
1592
    _constructor, /* construct */
1593
    nullptr,               /* trace */
1594
};
1595
1596
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1597
  {
1598
    "Function",
1599
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1600
    &sInterfaceObjectClassOps,
1601
    JS_NULL_CLASS_SPEC,
1602
    JS_NULL_CLASS_EXT,
1603
    &sInterfaceObjectClassObjectOps
1604
  },
1605
  eInterface,
1606
  true,
1607
  prototypes::id::VTTCue,
1608
  PrototypeTraits<prototypes::id::VTTCue>::Depth,
1609
  sNativePropertyHooks,
1610
  "function VTTCue() {\n    [native code]\n}",
1611
  TextTrackCue_Binding::GetConstructorObject
1612
};
1613
1614
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1615
  {
1616
    "VTTCuePrototype",
1617
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1618
    JS_NULL_CLASS_OPS,
1619
    JS_NULL_CLASS_SPEC,
1620
    JS_NULL_CLASS_EXT,
1621
    JS_NULL_OBJECT_OPS
1622
  },
1623
  eInterfacePrototype,
1624
  false,
1625
  prototypes::id::VTTCue,
1626
  PrototypeTraits<prototypes::id::VTTCue>::Depth,
1627
  sNativePropertyHooks,
1628
  "[object VTTCuePrototype]",
1629
  TextTrackCue_Binding::GetProtoObject
1630
};
1631
1632
static const js::ClassOps sClassOps = {
1633
  _addProperty, /* addProperty */
1634
  nullptr,               /* delProperty */
1635
  nullptr,               /* enumerate */
1636
  nullptr, /* newEnumerate */
1637
  nullptr, /* resolve */
1638
  nullptr, /* mayResolve */
1639
  _finalize, /* finalize */
1640
  nullptr, /* call */
1641
  nullptr,               /* hasInstance */
1642
  nullptr,               /* construct */
1643
  nullptr, /* trace */
1644
};
1645
1646
static const js::ClassExtension sClassExtension = {
1647
  nullptr, /* weakmapKeyDelegateOp */
1648
  _objectMoved /* objectMovedOp */
1649
};
1650
1651
static const DOMJSClass sClass = {
1652
  { "VTTCue",
1653
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1654
    &sClassOps,
1655
    JS_NULL_CLASS_SPEC,
1656
    &sClassExtension,
1657
    JS_NULL_OBJECT_OPS
1658
  },
1659
  { prototypes::id::EventTarget, prototypes::id::TextTrackCue, prototypes::id::VTTCue, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1660
  IsBaseOf<nsISupports, mozilla::dom::TextTrackCue >::value,
1661
  sNativePropertyHooks,
1662
  FindAssociatedGlobalForNative<mozilla::dom::TextTrackCue>::Get,
1663
  GetProtoObjectHandle,
1664
  GetCCParticipant<mozilla::dom::TextTrackCue>::Get()
1665
};
1666
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1667
              "Must have the right minimal number of reserved slots.");
1668
static_assert(1 >= 1,
1669
              "Must have enough reserved slots.");
1670
1671
const JSClass*
1672
GetJSClass()
1673
0
{
1674
0
  return sClass.ToJSClass();
1675
0
}
1676
1677
bool
1678
Wrap(JSContext* aCx, mozilla::dom::TextTrackCue* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1679
0
{
1680
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::TextTrackCue>::value,
1681
0
                "Shouldn't have wrappercached things that are not refcounted.");
1682
0
  MOZ_ASSERT(static_cast<mozilla::dom::TextTrackCue*>(aObject) ==
1683
0
             reinterpret_cast<mozilla::dom::TextTrackCue*>(aObject),
1684
0
             "Multiple inheritance for mozilla::dom::TextTrackCue is broken.");
1685
0
  MOZ_ASSERT(static_cast<mozilla::dom::TextTrackCue*>(aObject) ==
1686
0
             reinterpret_cast<mozilla::dom::TextTrackCue*>(aObject),
1687
0
             "Multiple inheritance for mozilla::dom::TextTrackCue is broken.");
1688
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1689
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1690
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1691
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1692
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1693
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1694
0
             "You should probably not be using Wrap() directly; use "
1695
0
             "GetOrCreateDOMReflector instead");
1696
0
1697
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1698
0
             "nsISupports must be on our primary inheritance chain");
1699
0
1700
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1701
0
  if (!global) {
1702
0
    return false;
1703
0
  }
1704
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1705
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1706
0
1707
0
  // That might have ended up wrapping us already, due to the wonders
1708
0
  // of XBL.  Check for that, and bail out as needed.
1709
0
  aReflector.set(aCache->GetWrapper());
1710
0
  if (aReflector) {
1711
#ifdef DEBUG
1712
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1713
#endif // DEBUG
1714
    return true;
1715
0
  }
1716
0
1717
0
  JSAutoRealm ar(aCx, global);
1718
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1719
0
  if (!canonicalProto) {
1720
0
    return false;
1721
0
  }
1722
0
  JS::Rooted<JSObject*> proto(aCx);
1723
0
  if (aGivenProto) {
1724
0
    proto = aGivenProto;
1725
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1726
0
    // coming in, we changed compartments to that of "parent" so may need
1727
0
    // to wrap the proto here.
1728
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1729
0
      if (!JS_WrapObject(aCx, &proto)) {
1730
0
        return false;
1731
0
      }
1732
0
    }
1733
0
  } else {
1734
0
    proto = canonicalProto;
1735
0
  }
1736
0
1737
0
  BindingJSObjectCreator<mozilla::dom::TextTrackCue> creator(aCx);
1738
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1739
0
  if (!aReflector) {
1740
0
    return false;
1741
0
  }
1742
0
1743
0
  aCache->SetWrapper(aReflector);
1744
0
  creator.InitializationSucceeded();
1745
0
1746
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1747
0
             aCache->GetWrapperPreserveColor() == aReflector);
1748
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1749
0
  // otherwise we won't be able to properly recreate it later, since
1750
0
  // we won't know what proto to use.  Note that we don't check
1751
0
  // aGivenProto here, since it's entirely possible (and even
1752
0
  // somewhat common) to have a non-null aGivenProto which is the
1753
0
  // same as canonicalProto.
1754
0
  if (proto != canonicalProto) {
1755
0
    PreserveWrapper(aObject);
1756
0
  }
1757
0
1758
0
  return true;
1759
0
}
1760
1761
const NativePropertyHooks sNativePropertyHooks[] = { {
1762
  nullptr,
1763
  nullptr,
1764
  nullptr,
1765
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1766
  prototypes::id::VTTCue,
1767
  constructors::id::VTTCue,
1768
  TextTrackCue_Binding::sNativePropertyHooks,
1769
  &DefaultXrayExpandoObjectClass
1770
} };
1771
1772
void
1773
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1774
0
{
1775
0
  JS::Handle<JSObject*> parentProto(TextTrackCue_Binding::GetProtoObjectHandle(aCx));
1776
0
  if (!parentProto) {
1777
0
    return;
1778
0
  }
1779
0
1780
0
  JS::Handle<JSObject*> constructorProto(TextTrackCue_Binding::GetConstructorObjectHandle(aCx));
1781
0
  if (!constructorProto) {
1782
0
    return;
1783
0
  }
1784
0
1785
0
  static bool sIdsInited = false;
1786
0
  if (!sIdsInited && NS_IsMainThread()) {
1787
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1788
0
      return;
1789
0
    }
1790
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1791
0
      return;
1792
0
    }
1793
0
    sIdsInited = true;
1794
0
  }
1795
0
1796
0
  static bool sPrefCachesInited = false;
1797
0
  if (!sPrefCachesInited && NS_IsMainThread()) {
1798
0
    sPrefCachesInited = true;
1799
0
    Preferences::AddBoolVarCache(&sAttributes[0].disablers->enabled, "media.webvtt.regions.enabled");
1800
0
  }
1801
0
1802
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::VTTCue);
1803
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::VTTCue);
1804
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1805
0
                              &sPrototypeClass.mBase, protoCache,
1806
0
                              nullptr,
1807
0
                              constructorProto, &sInterfaceObjectClass.mBase, 3, nullptr,
1808
0
                              interfaceCache,
1809
0
                              sNativeProperties.Upcast(),
1810
0
                              sChromeOnlyNativeProperties.Upcast(),
1811
0
                              "VTTCue", aDefineOnGlobal,
1812
0
                              nullptr,
1813
0
                              false);
1814
0
}
1815
1816
JSObject*
1817
GetConstructorObject(JSContext* aCx)
1818
0
{
1819
0
  return GetConstructorObjectHandle(aCx);
1820
0
}
1821
1822
} // namespace VTTCue_Binding
1823
1824
1825
1826
} // namespace dom
1827
} // namespace mozilla