Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/TextTrackCueListBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM TextTrackCueList.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "TextTrackCueListBinding.h"
4
#include "WrapperFactory.h"
5
#include "mozilla/OwningNonNull.h"
6
#include "mozilla/dom/BindingUtils.h"
7
#include "mozilla/dom/DOMJSClass.h"
8
#include "mozilla/dom/DOMJSProxyHandler.h"
9
#include "mozilla/dom/NonRefcountedDOMObject.h"
10
#include "mozilla/dom/Nullable.h"
11
#include "mozilla/dom/PrimitiveConversions.h"
12
#include "mozilla/dom/TextTrackCue.h"
13
#include "mozilla/dom/TextTrackCueList.h"
14
#include "mozilla/dom/XrayExpandoClass.h"
15
16
namespace mozilla {
17
namespace dom {
18
19
namespace binding_detail {}; // Just to make sure it's known as a namespace
20
using namespace mozilla::dom::binding_detail;
21
22
23
namespace TextTrackCueList_Binding {
24
25
MOZ_CAN_RUN_SCRIPT static bool
26
get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCueList* self, JSJitGetterCallArgs args)
27
0
{
28
0
  AUTO_PROFILER_LABEL_FAST("get TextTrackCueList.length", DOM, cx);
29
0
30
0
  uint32_t result(self->Length());
31
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
32
0
  args.rval().setNumber(result);
33
0
  return true;
34
0
}
35
36
static const JSJitInfo length_getterinfo = {
37
  { (JSJitGetterOp)get_length },
38
  { prototypes::id::TextTrackCueList },
39
  { PrototypeTraits<prototypes::id::TextTrackCueList>::Depth },
40
  JSJitInfo::Getter,
41
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
42
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
43
  true,  /* isInfallible. False in setters. */
44
  false,  /* isMovable.  Not relevant for setters. */
45
  false, /* isEliminatable.  Not relevant for setters. */
46
  false, /* isAlwaysInSlot.  Only relevant for getters. */
47
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
48
  false,  /* isTypedMethod.  Only relevant for methods. */
49
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
50
};
51
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
52
static_assert(0 < 1, "There is no slot for us");
53
54
MOZ_CAN_RUN_SCRIPT static bool
55
getCueById(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TextTrackCueList* self, const JSJitMethodCallArgs& args)
56
0
{
57
0
  AUTO_PROFILER_LABEL_FAST("TextTrackCueList.getCueById", DOM, cx);
58
0
59
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
60
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TextTrackCueList.getCueById");
61
0
  }
62
0
  binding_detail::FakeString arg0;
63
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
64
0
    return false;
65
0
  }
66
0
  auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(self->GetCueById(NonNullHelper(Constify(arg0)))));
67
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
68
0
  if (!result) {
69
0
    args.rval().setNull();
70
0
    return true;
71
0
  }
72
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
73
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
74
0
    return false;
75
0
  }
76
0
  return true;
77
0
}
78
79
static const JSJitInfo getCueById_methodinfo = {
80
  { (JSJitGetterOp)getCueById },
81
  { prototypes::id::TextTrackCueList },
82
  { PrototypeTraits<prototypes::id::TextTrackCueList>::Depth },
83
  JSJitInfo::Method,
84
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
85
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
86
  false,  /* isInfallible. False in setters. */
87
  false,  /* isMovable.  Not relevant for setters. */
88
  false, /* isEliminatable.  Not relevant for setters. */
89
  false, /* isAlwaysInSlot.  Only relevant for getters. */
90
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
91
  false,  /* isTypedMethod.  Only relevant for methods. */
92
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
93
};
94
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
95
static_assert(0 < 1, "There is no slot for us");
96
97
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
98
#if defined(__clang__)
99
#pragma clang diagnostic push
100
#pragma clang diagnostic ignored "-Wmissing-braces"
101
#endif
102
static const JSFunctionSpec sMethods_specs[] = {
103
  JS_FNSPEC("getCueById", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getCueById_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
104
  JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
105
  JS_FS_END
106
};
107
#if defined(__clang__)
108
#pragma clang diagnostic pop
109
#endif
110
111
112
static const Prefable<const JSFunctionSpec> sMethods[] = {
113
  { nullptr, &sMethods_specs[0] },
114
  { nullptr, nullptr }
115
};
116
117
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
118
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
119
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
120
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
121
122
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
123
#if defined(__clang__)
124
#pragma clang diagnostic push
125
#pragma clang diagnostic ignored "-Wmissing-braces"
126
#endif
127
static const JSPropertySpec sAttributes_specs[] = {
128
  { "length", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &length_getterinfo, nullptr, nullptr },
129
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
130
};
131
#if defined(__clang__)
132
#pragma clang diagnostic pop
133
#endif
134
135
136
static const Prefable<const JSPropertySpec> sAttributes[] = {
137
  { nullptr, &sAttributes_specs[0] },
138
  { nullptr, nullptr }
139
};
140
141
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
142
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
143
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
144
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
145
146
147
static uint16_t sNativeProperties_sortedPropertyIndices[3];
148
static PropertyInfo sNativeProperties_propertyInfos[3];
149
150
static const NativePropertiesN<2> sNativeProperties = {
151
  false, 0,
152
  false, 0,
153
  true,  0 /* sMethods */,
154
  true,  1 /* sAttributes */,
155
  false, 0,
156
  false, 0,
157
  false, 0,
158
  -1,
159
  3,
160
  sNativeProperties_sortedPropertyIndices,
161
  {
162
    { sMethods, &sNativeProperties_propertyInfos[0] },
163
    { sAttributes, &sNativeProperties_propertyInfos[2] }
164
  }
165
};
166
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
167
    "We have a property info count that is oversized");
168
169
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
170
  {
171
    "Function",
172
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
173
    &sBoringInterfaceObjectClassClassOps,
174
    JS_NULL_CLASS_SPEC,
175
    JS_NULL_CLASS_EXT,
176
    &sInterfaceObjectClassObjectOps
177
  },
178
  eInterface,
179
  true,
180
  prototypes::id::TextTrackCueList,
181
  PrototypeTraits<prototypes::id::TextTrackCueList>::Depth,
182
  sNativePropertyHooks,
183
  "function TextTrackCueList() {\n    [native code]\n}",
184
  JS::GetRealmFunctionPrototype
185
};
186
187
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
188
  {
189
    "TextTrackCueListPrototype",
190
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
191
    JS_NULL_CLASS_OPS,
192
    JS_NULL_CLASS_SPEC,
193
    JS_NULL_CLASS_EXT,
194
    JS_NULL_OBJECT_OPS
195
  },
196
  eInterfacePrototype,
197
  false,
198
  prototypes::id::TextTrackCueList,
199
  PrototypeTraits<prototypes::id::TextTrackCueList>::Depth,
200
  sNativePropertyHooks,
201
  "[object TextTrackCueListPrototype]",
202
  JS::GetRealmObjectPrototype
203
};
204
205
static_assert(IsBaseOf<nsISupports, mozilla::dom::TextTrackCueList >::value,
206
                  "We don't support non-nsISupports native classes for "
207
                  "proxy-based bindings yet");
208
209
210
class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
211
{
212
public:
213
  explicit constexpr DOMProxyHandler()
214
0
  {
215
0
  }
216
217
  virtual bool
218
  getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
219
220
  virtual bool
221
  defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
222
223
  using mozilla::dom::DOMProxyHandler::defineProperty;
224
225
  virtual bool
226
  ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
227
228
  virtual bool
229
  hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
230
231
  virtual bool
232
  get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
233
234
  virtual const char*
235
  className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
236
237
  virtual bool
238
  finalizeInBackground(const JS::Value& priv) const override;
239
240
  virtual void
241
  finalize(JSFreeOp* fop, JSObject* proxy) const override;
242
243
  static const DOMProxyHandler*
244
  getInstance();
245
246
  virtual bool
247
  delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
248
249
  virtual bool
250
  getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
251
252
  virtual size_t
253
  objectMoved(JSObject* obj, JSObject* old) const override;
254
};
255
256
MOZ_ALWAYS_INLINE bool
257
IsProxy(JSObject* obj)
258
0
{
259
0
  return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
260
0
}
261
262
MOZ_ALWAYS_INLINE mozilla::dom::TextTrackCueList*
263
UnwrapProxy(JSObject* obj)
264
0
{
265
0
  MOZ_ASSERT(js::IsProxy(obj));
266
0
  if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
267
0
    MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
268
0
    obj = js::UncheckedUnwrap(obj);
269
0
  }
270
0
  MOZ_ASSERT(IsProxy(obj));
271
0
  return static_cast<mozilla::dom::TextTrackCueList*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
272
0
}
273
274
bool
275
DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
276
0
{
277
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
278
0
  uint32_t index = GetArrayIndexFromId(cx, id);
279
0
  if (IsArrayIndex(index)) {
280
0
    mozilla::dom::TextTrackCueList* self = UnwrapProxy(proxy);
281
0
    bool found = false;
282
0
    auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(self->IndexedGetter(index, found)));
283
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
284
0
285
0
    if (found) {
286
0
      if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
287
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
288
0
        return false;
289
0
      }
290
0
      FillPropertyDescriptor(desc, proxy, true);
291
0
      return true;
292
0
    }
293
0
  }
294
0
295
0
  JS::Rooted<JSObject*> expando(cx);
296
0
  if (!isXray && (expando = GetExpandoObject(proxy))) {
297
0
    if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
298
0
      return false;
299
0
    }
300
0
    if (desc.object()) {
301
0
      // Pretend the property lives on the wrapper.
302
0
      desc.object().set(proxy);
303
0
      return true;
304
0
    }
305
0
  }
306
0
307
0
  desc.object().set(nullptr);
308
0
  return true;
309
0
}
310
311
bool
312
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
313
0
{
314
0
  if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
315
0
    *defined = true;
316
0
    return opresult.failNoIndexedSetter();
317
0
  }
318
0
  return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
319
0
}
320
321
322
bool
323
DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
324
0
{
325
0
  bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
326
0
327
0
  uint32_t length = UnwrapProxy(proxy)->Length();
328
0
  MOZ_ASSERT(int32_t(length) >= 0);
329
0
  for (int32_t i = 0; i < int32_t(length); ++i) {
330
0
    if (!props.append(INT_TO_JSID(i))) {
331
0
      return false;
332
0
    }
333
0
  }
334
0
335
0
  JS::Rooted<JSObject*> expando(cx);
336
0
  if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
337
0
      !js::GetPropertyKeys(cx, expando, flags, &props)) {
338
0
    return false;
339
0
  }
340
0
341
0
  return true;
342
0
}
343
344
bool
345
DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
346
0
{
347
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
348
0
            "Should not have a XrayWrapper here");
349
0
350
0
  uint32_t index = GetArrayIndexFromId(cx, id);
351
0
  if (IsArrayIndex(index)) {
352
0
    bool found = false;
353
0
    mozilla::dom::TextTrackCueList* self = UnwrapProxy(proxy);
354
0
    auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(self->IndexedGetter(index, found)));
355
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
356
0
    (void)result;
357
0
358
0
    *bp = found;
359
0
    return true;
360
0
  }
361
0
362
0
363
0
  JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
364
0
  if (expando) {
365
0
    bool b = true;
366
0
    bool ok = JS_HasPropertyById(cx, expando, id, &b);
367
0
    *bp = !!b;
368
0
    if (!ok || *bp) {
369
0
      return ok;
370
0
    }
371
0
  }
372
0
373
0
  *bp = false;
374
0
  return true;
375
0
}
376
377
bool
378
DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
379
0
{
380
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
381
0
              "Should not have a XrayWrapper here");
382
0
383
0
  uint32_t index = GetArrayIndexFromId(cx, id);
384
0
  if (IsArrayIndex(index)) {
385
0
    mozilla::dom::TextTrackCueList* self = UnwrapProxy(proxy);
386
0
    bool found = false;
387
0
    auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(self->IndexedGetter(index, found)));
388
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
389
0
390
0
    if (found) {
391
0
      if (!GetOrCreateDOMReflector(cx, result, vp)) {
392
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
393
0
        return false;
394
0
      }
395
0
      return true;
396
0
    }
397
0
    // Even if we don't have this index, we don't forward the
398
0
    // get on to our expando object.
399
0
  } else {
400
0
    { // Scope for expando
401
0
      JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
402
0
      if (expando) {
403
0
        bool hasProp;
404
0
        if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
405
0
          return false;
406
0
        }
407
0
408
0
        if (hasProp) {
409
0
          // Forward the get to the expando object, but our receiver is whatever our
410
0
          // receiver is.
411
0
          return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
412
0
        }
413
0
      }
414
0
    }
415
0
  }
416
0
417
0
  bool foundOnPrototype;
418
0
  if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
419
0
    return false;
420
0
  }
421
0
422
0
  if (foundOnPrototype) {
423
0
    return true;
424
0
  }
425
0
426
0
  vp.setUndefined();
427
0
  return true;
428
0
}
429
430
const char*
431
DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
432
0
{
433
0
  return "TextTrackCueList";
434
0
}
435
436
bool
437
DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
438
0
{
439
0
  return false;
440
0
}
441
442
void
443
DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
444
0
{
445
0
  mozilla::dom::TextTrackCueList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextTrackCueList>(proxy);
446
0
  if (self) {
447
0
    ClearWrapper(self, self, proxy);
448
0
    AddForDeferredFinalization<mozilla::dom::TextTrackCueList>(self);
449
0
  }
450
0
}
451
452
const DOMProxyHandler*
453
DOMProxyHandler::getInstance()
454
0
{
455
0
  static const DOMProxyHandler instance;
456
0
  return &instance;
457
0
}
458
459
bool
460
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
461
0
{
462
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
463
0
            "Should not have a XrayWrapper here");
464
0
465
0
  uint32_t index = GetArrayIndexFromId(cx, id);
466
0
  if (IsArrayIndex(index)) {
467
0
    bool deleteSucceeded;
468
0
    bool found = false;
469
0
    mozilla::dom::TextTrackCueList* self = UnwrapProxy(proxy);
470
0
    auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(self->IndexedGetter(index, found)));
471
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
472
0
    (void)result;
473
0
    deleteSucceeded = !found;
474
0
    return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
475
0
  }
476
0
477
0
  return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
478
0
}
479
480
bool
481
DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
482
0
{
483
0
  JS::Rooted<JS::Value> temp(cx);
484
0
  MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
485
0
             "Should not have a XrayWrapper here");
486
0
487
0
  mozilla::dom::TextTrackCueList* self = UnwrapProxy(proxy);
488
0
  uint32_t length = self->Length();
489
0
  // Compute the end of the indices we'll get ourselves
490
0
  uint32_t ourEnd = std::max(begin, std::min(end, length));
491
0
492
0
  for (uint32_t index = begin; index < ourEnd; ++index) {
493
0
    bool found = false;
494
0
    auto result(StrongOrRawPtr<mozilla::dom::TextTrackCue>(self->IndexedGetter(index, found)));
495
0
    MOZ_ASSERT(!JS_IsExceptionPending(cx));
496
0
497
0
    MOZ_ASSERT(found);
498
0
    if (!GetOrCreateDOMReflector(cx, result, &temp)) {
499
0
      MOZ_ASSERT(JS_IsExceptionPending(cx));
500
0
      return false;
501
0
    }
502
0
    if (!adder->append(cx, temp)) return false;
503
0
    continue;
504
0
  }
505
0
506
0
  if (end > ourEnd) {
507
0
    JS::Rooted<JSObject*> proto(cx);
508
0
    if (!js::GetObjectProto(cx, proxy, &proto)) {
509
0
      return false;
510
0
    }
511
0
    return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
512
0
  }
513
0
514
0
  return true;
515
0
}
516
517
size_t
518
DOMProxyHandler::objectMoved(JSObject* obj, JSObject* old) const
519
0
{
520
0
  mozilla::dom::TextTrackCueList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TextTrackCueList>(obj);
521
0
  if (self) {
522
0
    UpdateWrapper(self, self, obj, old);
523
0
  }
524
0
525
0
  return 0;
526
0
}
527
528
static const DOMJSClass sClass = {
529
  PROXY_CLASS_DEF("TextTrackCueList",
530
                  JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1)),
531
  { prototypes::id::TextTrackCueList, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
532
  IsBaseOf<nsISupports, mozilla::dom::TextTrackCueList >::value,
533
  sNativePropertyHooks,
534
  FindAssociatedGlobalForNative<mozilla::dom::TextTrackCueList>::Get,
535
  GetProtoObjectHandle,
536
  GetCCParticipant<mozilla::dom::TextTrackCueList>::Get()
537
};
538
539
bool
540
Wrap(JSContext* aCx, mozilla::dom::TextTrackCueList* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
541
0
{
542
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::TextTrackCueList>::value,
543
0
                "Shouldn't have wrappercached things that are not refcounted.");
544
0
  MOZ_ASSERT(static_cast<mozilla::dom::TextTrackCueList*>(aObject) ==
545
0
             reinterpret_cast<mozilla::dom::TextTrackCueList*>(aObject),
546
0
             "Multiple inheritance for mozilla::dom::TextTrackCueList is broken.");
547
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
548
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
549
0
  MOZ_ASSERT(!aCache->GetWrapper(),
550
0
             "You should probably not be using Wrap() directly; use "
551
0
             "GetOrCreateDOMReflector instead");
552
0
553
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
554
0
             "nsISupports must be on our primary inheritance chain");
555
0
556
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
557
0
  if (!global) {
558
0
    return false;
559
0
  }
560
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
561
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
562
0
563
0
  // That might have ended up wrapping us already, due to the wonders
564
0
  // of XBL.  Check for that, and bail out as needed.
565
0
  aReflector.set(aCache->GetWrapper());
566
0
  if (aReflector) {
567
#ifdef DEBUG
568
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
569
#endif // DEBUG
570
    return true;
571
0
  }
572
0
573
0
  JSAutoRealm ar(aCx, global);
574
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
575
0
  if (!canonicalProto) {
576
0
    return false;
577
0
  }
578
0
  JS::Rooted<JSObject*> proto(aCx);
579
0
  if (aGivenProto) {
580
0
    proto = aGivenProto;
581
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
582
0
    // coming in, we changed compartments to that of "parent" so may need
583
0
    // to wrap the proto here.
584
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
585
0
      if (!JS_WrapObject(aCx, &proto)) {
586
0
        return false;
587
0
      }
588
0
    }
589
0
  } else {
590
0
    proto = canonicalProto;
591
0
  }
592
0
593
0
  BindingJSObjectCreator<mozilla::dom::TextTrackCueList> creator(aCx);
594
0
  creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
595
0
                            proto, aObject, JS::UndefinedHandleValue, aReflector);
596
0
  if (!aReflector) {
597
0
    return false;
598
0
  }
599
0
600
0
  aCache->SetWrapper(aReflector);
601
0
  creator.InitializationSucceeded();
602
0
603
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
604
0
             aCache->GetWrapperPreserveColor() == aReflector);
605
0
  // If proto != canonicalProto, we have to preserve our wrapper;
606
0
  // otherwise we won't be able to properly recreate it later, since
607
0
  // we won't know what proto to use.  Note that we don't check
608
0
  // aGivenProto here, since it's entirely possible (and even
609
0
  // somewhat common) to have a non-null aGivenProto which is the
610
0
  // same as canonicalProto.
611
0
  if (proto != canonicalProto) {
612
0
    PreserveWrapper(aObject);
613
0
  }
614
0
615
0
  return true;
616
0
}
617
618
static bool
619
ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
620
0
{
621
0
  return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
622
0
}
623
624
static bool
625
EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
626
0
{
627
0
  return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
628
0
}
629
630
const NativePropertyHooks sNativePropertyHooks[] = { {
631
  ResolveOwnProperty,
632
  EnumerateOwnProperties,
633
  nullptr,
634
  { sNativeProperties.Upcast(), nullptr },
635
  prototypes::id::TextTrackCueList,
636
  constructors::id::TextTrackCueList,
637
  nullptr,
638
  &DefaultXrayExpandoObjectClass
639
} };
640
641
void
642
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
643
0
{
644
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
645
0
  if (!parentProto) {
646
0
    return;
647
0
  }
648
0
649
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
650
0
  if (!constructorProto) {
651
0
    return;
652
0
  }
653
0
654
0
  static bool sIdsInited = false;
655
0
  if (!sIdsInited && NS_IsMainThread()) {
656
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
657
0
      return;
658
0
    }
659
0
    sIdsInited = true;
660
0
  }
661
0
662
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TextTrackCueList);
663
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TextTrackCueList);
664
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
665
0
                              &sPrototypeClass.mBase, protoCache,
666
0
                              nullptr,
667
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
668
0
                              interfaceCache,
669
0
                              sNativeProperties.Upcast(),
670
0
                              nullptr,
671
0
                              "TextTrackCueList", aDefineOnGlobal,
672
0
                              nullptr,
673
0
                              false);
674
0
}
675
676
JSObject*
677
GetConstructorObject(JSContext* aCx)
678
0
{
679
0
  return GetConstructorObjectHandle(aCx);
680
0
}
681
682
} // namespace TextTrackCueList_Binding
683
684
685
686
} // namespace dom
687
} // namespace mozilla