Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/AnimationPlaybackEventBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM AnimationPlaybackEvent.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AnimationPlaybackEventBinding.h"
4
#include "AtomList.h"
5
#include "EventBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/AnimationPlaybackEvent.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/Nullable.h"
14
#include "mozilla/dom/PrimitiveConversions.h"
15
#include "mozilla/dom/ScriptSettings.h"
16
#include "mozilla/dom/SimpleGlobalObject.h"
17
#include "mozilla/dom/XrayExpandoClass.h"
18
#include "nsDocument.h"
19
20
namespace mozilla {
21
namespace dom {
22
23
namespace binding_detail {}; // Just to make sure it's known as a namespace
24
using namespace mozilla::dom::binding_detail;
25
26
27
28
AnimationPlaybackEventInit::AnimationPlaybackEventInit()
29
  : EventInit(FastDictionaryInitializer())
30
0
{
31
0
  // Safe to pass a null context if we pass a null value
32
0
  Init(nullptr, JS::NullHandleValue);
33
0
}
34
35
36
37
bool
38
AnimationPlaybackEventInit::InitIds(JSContext* cx, AnimationPlaybackEventInitAtoms* atomsCache)
39
0
{
40
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
41
0
42
0
  // Initialize these in reverse order so that any failure leaves the first one
43
0
  // uninitialized.
44
0
  if (!atomsCache->timelineTime_id.init(cx, "timelineTime") ||
45
0
      !atomsCache->currentTime_id.init(cx, "currentTime")) {
46
0
    return false;
47
0
  }
48
0
  return true;
49
0
}
50
51
bool
52
AnimationPlaybackEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
53
0
{
54
0
  // Passing a null JSContext is OK only if we're initing from null,
55
0
  // Since in that case we will not have to do any property gets
56
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
57
0
  // checkers by static analysis tools
58
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
59
0
  AnimationPlaybackEventInitAtoms* atomsCache = nullptr;
60
0
  if (cx) {
61
0
    atomsCache = GetAtomCache<AnimationPlaybackEventInitAtoms>(cx);
62
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
63
0
      return false;
64
0
    }
65
0
  }
66
0
67
0
  // Per spec, we init the parent's members first
68
0
  if (!EventInit::Init(cx, val)) {
69
0
    return false;
70
0
  }
71
0
72
0
  bool isNull = val.isNullOrUndefined();
73
0
  // We only need these if !isNull, in which case we have |cx|.
74
0
  Maybe<JS::Rooted<JSObject *> > object;
75
0
  Maybe<JS::Rooted<JS::Value> > temp;
76
0
  if (!isNull) {
77
0
    MOZ_ASSERT(cx);
78
0
    object.emplace(cx, &val.toObject());
79
0
    temp.emplace(cx);
80
0
  }
81
0
  if (!isNull) {
82
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->currentTime_id, temp.ptr())) {
83
0
      return false;
84
0
    }
85
0
  }
86
0
  if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
87
0
    mCurrentTime.SetNull();
88
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mCurrentTime.SetValue())) {
89
0
    return false;
90
0
  } else if (!mozilla::IsFinite(mCurrentTime.Value())) {
91
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "'currentTime' member of AnimationPlaybackEventInit");
92
0
    return false;
93
0
  }
94
0
  mIsAnyMemberPresent = true;
95
0
96
0
  if (!isNull) {
97
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->timelineTime_id, temp.ptr())) {
98
0
      return false;
99
0
    }
100
0
  }
101
0
  if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
102
0
    mTimelineTime.SetNull();
103
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mTimelineTime.SetValue())) {
104
0
    return false;
105
0
  } else if (!mozilla::IsFinite(mTimelineTime.Value())) {
106
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "'timelineTime' member of AnimationPlaybackEventInit");
107
0
    return false;
108
0
  }
109
0
  mIsAnyMemberPresent = true;
110
0
  return true;
111
0
}
112
113
bool
114
AnimationPlaybackEventInit::Init(const nsAString& aJSON)
115
0
{
116
0
  AutoJSAPI jsapi;
117
0
  JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
118
0
  if (!cleanGlobal) {
119
0
    return false;
120
0
  }
121
0
  if (!jsapi.Init(cleanGlobal)) {
122
0
    return false;
123
0
  }
124
0
  JSContext* cx = jsapi.cx();
125
0
  JS::Rooted<JS::Value> json(cx);
126
0
  bool ok = ParseJSON(cx, aJSON, &json);
127
0
  NS_ENSURE_TRUE(ok, false);
128
0
  return Init(cx, json);
129
0
}
130
131
bool
132
AnimationPlaybackEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
133
0
{
134
0
  AnimationPlaybackEventInitAtoms* atomsCache = GetAtomCache<AnimationPlaybackEventInitAtoms>(cx);
135
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
136
0
    return false;
137
0
  }
138
0
139
0
  // Per spec, we define the parent's members first
140
0
  if (!EventInit::ToObjectInternal(cx, rval)) {
141
0
    return false;
142
0
  }
143
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
144
0
145
0
  do {
146
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
147
0
    JS::Rooted<JS::Value> temp(cx);
148
0
    Nullable<double> const & currentValue = mCurrentTime;
149
0
    if (currentValue.IsNull()) {
150
0
      temp.setNull();
151
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->currentTime_id, temp, JSPROP_ENUMERATE)) {
152
0
        return false;
153
0
      }
154
0
      break;
155
0
    }
156
0
    temp.set(JS_NumberValue(double(currentValue.Value())));
157
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->currentTime_id, temp, JSPROP_ENUMERATE)) {
158
0
      return false;
159
0
    }
160
0
    break;
161
0
  } while(false);
162
0
163
0
  do {
164
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
165
0
    JS::Rooted<JS::Value> temp(cx);
166
0
    Nullable<double> const & currentValue = mTimelineTime;
167
0
    if (currentValue.IsNull()) {
168
0
      temp.setNull();
169
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->timelineTime_id, temp, JSPROP_ENUMERATE)) {
170
0
        return false;
171
0
      }
172
0
      break;
173
0
    }
174
0
    temp.set(JS_NumberValue(double(currentValue.Value())));
175
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->timelineTime_id, temp, JSPROP_ENUMERATE)) {
176
0
      return false;
177
0
    }
178
0
    break;
179
0
  } while(false);
180
0
181
0
  return true;
182
0
}
183
184
bool
185
AnimationPlaybackEventInit::ToJSON(nsAString& aJSON) const
186
0
{
187
0
  AutoJSAPI jsapi;
188
0
  jsapi.Init();
189
0
  JSContext *cx = jsapi.cx();
190
0
  // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
191
0
  // because we'll only be creating objects, in ways that have no
192
0
  // side-effects, followed by a call to JS::ToJSONMaybeSafely,
193
0
  // which likewise guarantees no side-effects for the sorts of
194
0
  // things we will pass it.
195
0
  JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal());
196
0
  JS::Rooted<JS::Value> val(cx);
197
0
  if (!ToObjectInternal(cx, &val)) {
198
0
    return false;
199
0
  }
200
0
  JS::Rooted<JSObject*> obj(cx, &val.toObject());
201
0
  return StringifyToJSON(cx, obj, aJSON);
202
0
}
203
204
void
205
AnimationPlaybackEventInit::TraceDictionary(JSTracer* trc)
206
0
{
207
0
  EventInit::TraceDictionary(trc);
208
0
}
209
210
AnimationPlaybackEventInit&
211
AnimationPlaybackEventInit::operator=(const AnimationPlaybackEventInit& aOther)
212
0
{
213
0
  EventInit::operator=(aOther);
214
0
  mCurrentTime = aOther.mCurrentTime;
215
0
  mTimelineTime = aOther.mTimelineTime;
216
0
  return *this;
217
0
}
218
219
namespace binding_detail {
220
} // namespace binding_detail
221
222
223
namespace AnimationPlaybackEvent_Binding {
224
225
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<Event_Binding::NativeType>::value,
226
              "Can't inherit from an interface with a different ownership model.");
227
228
MOZ_CAN_RUN_SCRIPT static bool
229
get_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationPlaybackEvent* self, JSJitGetterCallArgs args)
230
0
{
231
0
  AUTO_PROFILER_LABEL_FAST("get AnimationPlaybackEvent.currentTime", DOM, cx);
232
0
233
0
  Nullable<double> result(self->GetCurrentTime());
234
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
235
0
  if (result.IsNull()) {
236
0
    args.rval().setNull();
237
0
    return true;
238
0
  }
239
0
  args.rval().set(JS_NumberValue(double(result.Value())));
240
0
  return true;
241
0
}
242
243
static const JSJitInfo currentTime_getterinfo = {
244
  { (JSJitGetterOp)get_currentTime },
245
  { prototypes::id::AnimationPlaybackEvent },
246
  { PrototypeTraits<prototypes::id::AnimationPlaybackEvent>::Depth },
247
  JSJitInfo::Getter,
248
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
249
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
250
  true,  /* isInfallible. False in setters. */
251
  false,  /* isMovable.  Not relevant for setters. */
252
  false, /* isEliminatable.  Not relevant for setters. */
253
  false, /* isAlwaysInSlot.  Only relevant for getters. */
254
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
255
  false,  /* isTypedMethod.  Only relevant for methods. */
256
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
257
};
258
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
259
static_assert(0 < 1, "There is no slot for us");
260
261
MOZ_CAN_RUN_SCRIPT static bool
262
get_timelineTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationPlaybackEvent* self, JSJitGetterCallArgs args)
263
0
{
264
0
  AUTO_PROFILER_LABEL_FAST("get AnimationPlaybackEvent.timelineTime", DOM, cx);
265
0
266
0
  Nullable<double> result(self->GetTimelineTime());
267
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
268
0
  if (result.IsNull()) {
269
0
    args.rval().setNull();
270
0
    return true;
271
0
  }
272
0
  args.rval().set(JS_NumberValue(double(result.Value())));
273
0
  return true;
274
0
}
275
276
static const JSJitInfo timelineTime_getterinfo = {
277
  { (JSJitGetterOp)get_timelineTime },
278
  { prototypes::id::AnimationPlaybackEvent },
279
  { PrototypeTraits<prototypes::id::AnimationPlaybackEvent>::Depth },
280
  JSJitInfo::Getter,
281
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
282
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
283
  true,  /* isInfallible. False in setters. */
284
  false,  /* isMovable.  Not relevant for setters. */
285
  false, /* isEliminatable.  Not relevant for setters. */
286
  false, /* isAlwaysInSlot.  Only relevant for getters. */
287
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
288
  false,  /* isTypedMethod.  Only relevant for methods. */
289
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
290
};
291
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
292
static_assert(0 < 1, "There is no slot for us");
293
294
MOZ_CAN_RUN_SCRIPT static bool
295
get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationPlaybackEvent* self, JSJitGetterCallArgs args)
296
0
{
297
0
  AUTO_PROFILER_LABEL_FAST("get AnimationPlaybackEvent.isTrusted", DOM, cx);
298
0
299
0
  bool result(self->IsTrusted());
300
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
301
0
  args.rval().setBoolean(result);
302
0
  return true;
303
0
}
304
305
static const JSJitInfo isTrusted_getterinfo = {
306
  { (JSJitGetterOp)get_isTrusted },
307
  { prototypes::id::AnimationPlaybackEvent },
308
  { PrototypeTraits<prototypes::id::AnimationPlaybackEvent>::Depth },
309
  JSJitInfo::Getter,
310
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
311
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
312
  true,  /* isInfallible. False in setters. */
313
  true,  /* isMovable.  Not relevant for setters. */
314
  true, /* isEliminatable.  Not relevant for setters. */
315
  false, /* isAlwaysInSlot.  Only relevant for getters. */
316
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
317
  false,  /* isTypedMethod.  Only relevant for methods. */
318
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
319
};
320
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
321
static_assert(0 < 1, "There is no slot for us");
322
323
static bool
324
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
325
0
{
326
0
  mozilla::dom::AnimationPlaybackEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationPlaybackEvent>(obj);
327
0
  // We don't want to preserve if we don't have a wrapper, and we
328
0
  // obviously can't preserve if we're not initialized.
329
0
  if (self && self->GetWrapperPreserveColor()) {
330
0
    PreserveWrapper(self);
331
0
  }
332
0
  return true;
333
0
}
334
335
static void
336
_finalize(js::FreeOp* fop, JSObject* obj)
337
0
{
338
0
  mozilla::dom::AnimationPlaybackEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationPlaybackEvent>(obj);
339
0
  if (self) {
340
0
    ClearWrapper(self, self, obj);
341
0
    AddForDeferredFinalization<mozilla::dom::AnimationPlaybackEvent>(self);
342
0
  }
343
0
}
344
345
static size_t
346
_objectMoved(JSObject* obj, JSObject* old)
347
0
{
348
0
  mozilla::dom::AnimationPlaybackEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationPlaybackEvent>(obj);
349
0
  if (self) {
350
0
    UpdateWrapper(self, self, obj, old);
351
0
  }
352
0
353
0
  return 0;
354
0
}
355
356
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
357
#if defined(__clang__)
358
#pragma clang diagnostic push
359
#pragma clang diagnostic ignored "-Wmissing-braces"
360
#endif
361
static const JSPropertySpec sAttributes_specs[] = {
362
  { "currentTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &currentTime_getterinfo, nullptr, nullptr },
363
  { "timelineTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &timelineTime_getterinfo, nullptr, nullptr },
364
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
365
};
366
#if defined(__clang__)
367
#pragma clang diagnostic pop
368
#endif
369
370
371
static const Prefable<const JSPropertySpec> sAttributes[] = {
372
  { nullptr, &sAttributes_specs[0] },
373
  { nullptr, nullptr }
374
};
375
376
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
377
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
378
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
379
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
380
381
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
382
#if defined(__clang__)
383
#pragma clang diagnostic push
384
#pragma clang diagnostic ignored "-Wmissing-braces"
385
#endif
386
static const JSPropertySpec sUnforgeableAttributes_specs[] = {
387
  { "isTrusted", JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isTrusted_getterinfo, nullptr, nullptr },
388
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
389
};
390
#if defined(__clang__)
391
#pragma clang diagnostic pop
392
#endif
393
394
395
static const Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
396
  { nullptr, &sUnforgeableAttributes_specs[0] },
397
  { nullptr, nullptr }
398
};
399
400
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
401
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
402
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
403
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
404
405
406
static uint16_t sNativeProperties_sortedPropertyIndices[3];
407
static PropertyInfo sNativeProperties_propertyInfos[3];
408
409
static const NativePropertiesN<2> sNativeProperties = {
410
  false, 0,
411
  false, 0,
412
  false, 0,
413
  true,  0 /* sAttributes */,
414
  false, 0,
415
  true,  1 /* sUnforgeableAttributes */,
416
  false, 0,
417
  -1,
418
  3,
419
  sNativeProperties_sortedPropertyIndices,
420
  {
421
    { sAttributes, &sNativeProperties_propertyInfos[0] },
422
    { sUnforgeableAttributes, &sNativeProperties_propertyInfos[2] }
423
  }
424
};
425
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
426
    "We have a property info count that is oversized");
427
428
static bool
429
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
430
0
{
431
0
  AUTO_PROFILER_LABEL_FAST("AnimationPlaybackEvent constructor", DOM, cx);
432
0
433
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
434
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
435
0
  if (!args.isConstructing()) {
436
0
    // XXXbz wish I could get the name from the callee instead of
437
0
    // Adding more relocations
438
0
    return ThrowConstructorWithoutNew(cx, "AnimationPlaybackEvent");
439
0
  }
440
0
441
0
  JS::Rooted<JSObject*> desiredProto(cx);
442
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
443
0
    return false;
444
0
  }
445
0
446
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
447
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AnimationPlaybackEvent");
448
0
  }
449
0
  GlobalObject global(cx, obj);
450
0
  if (global.Failed()) {
451
0
    return false;
452
0
  }
453
0
454
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
455
0
  binding_detail::FakeString arg0;
456
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
457
0
    return false;
458
0
  }
459
0
  binding_detail::FastAnimationPlaybackEventInit arg1;
460
0
  if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of AnimationPlaybackEvent.constructor", false)) {
461
0
    return false;
462
0
  }
463
0
  Maybe<JSAutoRealm> ar;
464
0
  if (objIsXray) {
465
0
    obj = js::CheckedUnwrap(obj);
466
0
    if (!obj) {
467
0
      return false;
468
0
    }
469
0
    ar.emplace(cx, obj);
470
0
    if (!JS_WrapObject(cx, &desiredProto)) {
471
0
      return false;
472
0
    }
473
0
  }
474
0
  FastErrorResult rv;
475
0
  auto result(StrongOrRawPtr<mozilla::dom::AnimationPlaybackEvent>(mozilla::dom::AnimationPlaybackEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
476
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
477
0
    return false;
478
0
  }
479
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
480
0
  static_assert(!IsPointer<decltype(result)>::value,
481
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
482
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
483
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
484
0
    return false;
485
0
  }
486
0
  return true;
487
0
}
488
489
static const js::ClassOps sInterfaceObjectClassOps = {
490
    nullptr,               /* addProperty */
491
    nullptr,               /* delProperty */
492
    nullptr,               /* enumerate */
493
    nullptr,               /* newEnumerate */
494
    nullptr,               /* resolve */
495
    nullptr,               /* mayResolve */
496
    nullptr,               /* finalize */
497
    _constructor, /* call */
498
    nullptr,               /* hasInstance */
499
    _constructor, /* construct */
500
    nullptr,               /* trace */
501
};
502
503
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
504
  {
505
    "Function",
506
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
507
    &sInterfaceObjectClassOps,
508
    JS_NULL_CLASS_SPEC,
509
    JS_NULL_CLASS_EXT,
510
    &sInterfaceObjectClassObjectOps
511
  },
512
  eInterface,
513
  true,
514
  prototypes::id::AnimationPlaybackEvent,
515
  PrototypeTraits<prototypes::id::AnimationPlaybackEvent>::Depth,
516
  sNativePropertyHooks,
517
  "function AnimationPlaybackEvent() {\n    [native code]\n}",
518
  Event_Binding::GetConstructorObject
519
};
520
521
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
522
  {
523
    "AnimationPlaybackEventPrototype",
524
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
525
    JS_NULL_CLASS_OPS,
526
    JS_NULL_CLASS_SPEC,
527
    JS_NULL_CLASS_EXT,
528
    JS_NULL_OBJECT_OPS
529
  },
530
  eInterfacePrototype,
531
  false,
532
  prototypes::id::AnimationPlaybackEvent,
533
  PrototypeTraits<prototypes::id::AnimationPlaybackEvent>::Depth,
534
  sNativePropertyHooks,
535
  "[object AnimationPlaybackEventPrototype]",
536
  Event_Binding::GetProtoObject
537
};
538
539
bool
540
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
541
0
{
542
0
  return nsDocument::IsWebAnimationsEnabled(aCx, aObj);
543
0
}
544
545
static const js::ClassOps sClassOps = {
546
  _addProperty, /* addProperty */
547
  nullptr,               /* delProperty */
548
  nullptr,               /* enumerate */
549
  nullptr, /* newEnumerate */
550
  nullptr, /* resolve */
551
  nullptr, /* mayResolve */
552
  _finalize, /* finalize */
553
  nullptr, /* call */
554
  nullptr,               /* hasInstance */
555
  nullptr,               /* construct */
556
  nullptr, /* trace */
557
};
558
559
static const js::ClassExtension sClassExtension = {
560
  nullptr, /* weakmapKeyDelegateOp */
561
  _objectMoved /* objectMovedOp */
562
};
563
564
static const DOMJSClass sClass = {
565
  { "AnimationPlaybackEvent",
566
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
567
    &sClassOps,
568
    JS_NULL_CLASS_SPEC,
569
    &sClassExtension,
570
    JS_NULL_OBJECT_OPS
571
  },
572
  { prototypes::id::Event, prototypes::id::AnimationPlaybackEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
573
  IsBaseOf<nsISupports, mozilla::dom::AnimationPlaybackEvent >::value,
574
  sNativePropertyHooks,
575
  FindAssociatedGlobalForNative<mozilla::dom::AnimationPlaybackEvent>::Get,
576
  GetProtoObjectHandle,
577
  GetCCParticipant<mozilla::dom::AnimationPlaybackEvent>::Get()
578
};
579
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
580
              "Must have the right minimal number of reserved slots.");
581
static_assert(1 >= 1,
582
              "Must have enough reserved slots.");
583
584
const JSClass*
585
GetJSClass()
586
0
{
587
0
  return sClass.ToJSClass();
588
0
}
589
590
bool
591
Wrap(JSContext* aCx, mozilla::dom::AnimationPlaybackEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
592
0
{
593
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AnimationPlaybackEvent>::value,
594
0
                "Shouldn't have wrappercached things that are not refcounted.");
595
0
  MOZ_ASSERT(static_cast<mozilla::dom::AnimationPlaybackEvent*>(aObject) ==
596
0
             reinterpret_cast<mozilla::dom::AnimationPlaybackEvent*>(aObject),
597
0
             "Multiple inheritance for mozilla::dom::AnimationPlaybackEvent is broken.");
598
0
  MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
599
0
             reinterpret_cast<mozilla::dom::Event*>(aObject),
600
0
             "Multiple inheritance for mozilla::dom::Event is broken.");
601
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
602
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
603
0
  MOZ_ASSERT(!aCache->GetWrapper(),
604
0
             "You should probably not be using Wrap() directly; use "
605
0
             "GetOrCreateDOMReflector instead");
606
0
607
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
608
0
             "nsISupports must be on our primary inheritance chain");
609
0
610
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
611
0
  if (!global) {
612
0
    return false;
613
0
  }
614
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
615
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
616
0
617
0
  // That might have ended up wrapping us already, due to the wonders
618
0
  // of XBL.  Check for that, and bail out as needed.
619
0
  aReflector.set(aCache->GetWrapper());
620
0
  if (aReflector) {
621
#ifdef DEBUG
622
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
623
#endif // DEBUG
624
    return true;
625
0
  }
626
0
627
0
  JSAutoRealm ar(aCx, global);
628
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
629
0
  if (!canonicalProto) {
630
0
    return false;
631
0
  }
632
0
  JS::Rooted<JSObject*> proto(aCx);
633
0
  if (aGivenProto) {
634
0
    proto = aGivenProto;
635
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
636
0
    // coming in, we changed compartments to that of "parent" so may need
637
0
    // to wrap the proto here.
638
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
639
0
      if (!JS_WrapObject(aCx, &proto)) {
640
0
        return false;
641
0
      }
642
0
    }
643
0
  } else {
644
0
    proto = canonicalProto;
645
0
  }
646
0
647
0
  BindingJSObjectCreator<mozilla::dom::AnimationPlaybackEvent> creator(aCx);
648
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
649
0
  if (!aReflector) {
650
0
    return false;
651
0
  }
652
0
653
0
  aCache->SetWrapper(aReflector);
654
0
655
0
  // Important: do unforgeable property setup after we have handed
656
0
  // over ownership of the C++ object to obj as needed, so that if
657
0
  // we fail and it ends up GCed it won't have problems in the
658
0
  // finalizer trying to drop its ownership of the C++ object.
659
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx,
660
0
    &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
661
0
  if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
662
0
    aCache->ReleaseWrapper(aObject);
663
0
    aCache->ClearWrapper();
664
0
    return false;
665
0
  }
666
0
  creator.InitializationSucceeded();
667
0
668
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
669
0
             aCache->GetWrapperPreserveColor() == aReflector);
670
0
  // If proto != canonicalProto, we have to preserve our wrapper;
671
0
  // otherwise we won't be able to properly recreate it later, since
672
0
  // we won't know what proto to use.  Note that we don't check
673
0
  // aGivenProto here, since it's entirely possible (and even
674
0
  // somewhat common) to have a non-null aGivenProto which is the
675
0
  // same as canonicalProto.
676
0
  if (proto != canonicalProto) {
677
0
    PreserveWrapper(aObject);
678
0
  }
679
0
680
0
  return true;
681
0
}
682
683
const NativePropertyHooks sNativePropertyHooks[] = { {
684
  nullptr,
685
  nullptr,
686
  nullptr,
687
  { sNativeProperties.Upcast(), nullptr },
688
  prototypes::id::AnimationPlaybackEvent,
689
  constructors::id::AnimationPlaybackEvent,
690
  Event_Binding::sNativePropertyHooks,
691
  &DefaultXrayExpandoObjectClass
692
} };
693
694
void
695
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
696
0
{
697
0
  JS::Handle<JSObject*> parentProto(Event_Binding::GetProtoObjectHandle(aCx));
698
0
  if (!parentProto) {
699
0
    return;
700
0
  }
701
0
702
0
  JS::Handle<JSObject*> constructorProto(Event_Binding::GetConstructorObjectHandle(aCx));
703
0
  if (!constructorProto) {
704
0
    return;
705
0
  }
706
0
707
0
  static bool sIdsInited = false;
708
0
  if (!sIdsInited && NS_IsMainThread()) {
709
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
710
0
      return;
711
0
    }
712
0
    sIdsInited = true;
713
0
  }
714
0
715
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnimationPlaybackEvent);
716
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnimationPlaybackEvent);
717
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
718
0
                              &sPrototypeClass.mBase, protoCache,
719
0
                              nullptr,
720
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
721
0
                              interfaceCache,
722
0
                              sNativeProperties.Upcast(),
723
0
                              nullptr,
724
0
                              "AnimationPlaybackEvent", aDefineOnGlobal,
725
0
                              nullptr,
726
0
                              false);
727
0
728
0
  JS::Rooted<JSObject*> unforgeableHolder(aCx);
729
0
  {
730
0
    JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
731
0
    unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
732
0
    if (!unforgeableHolder) {
733
0
      *protoCache = nullptr;
734
0
      if (interfaceCache) {
735
0
        *interfaceCache = nullptr;
736
0
      }
737
0
      return;
738
0
    }
739
0
  }
740
0
741
0
  if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
742
0
    *protoCache = nullptr;
743
0
    if (interfaceCache) {
744
0
      *interfaceCache = nullptr;
745
0
    }
746
0
    return;
747
0
  }
748
0
749
0
  if (*protoCache) {
750
0
    js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
751
0
                        JS::ObjectValue(*unforgeableHolder));
752
0
  }
753
0
}
754
755
JSObject*
756
GetConstructorObject(JSContext* aCx)
757
0
{
758
0
  return GetConstructorObjectHandle(aCx);
759
0
}
760
761
} // namespace AnimationPlaybackEvent_Binding
762
763
764
765
} // namespace dom
766
} // namespace mozilla