Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/AnimationBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM Animation.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AnimationBinding.h"
4
#include "EventHandlerBinding.h"
5
#include "EventTargetBinding.h"
6
#include "WrapperFactory.h"
7
#include "jsapi.h"
8
#include "mozilla/FloatingPoint.h"
9
#include "mozilla/OwningNonNull.h"
10
#include "mozilla/dom/Animation.h"
11
#include "mozilla/dom/AnimationEffect.h"
12
#include "mozilla/dom/AnimationTimeline.h"
13
#include "mozilla/dom/BindingUtils.h"
14
#include "mozilla/dom/DOMJSClass.h"
15
#include "mozilla/dom/NonRefcountedDOMObject.h"
16
#include "mozilla/dom/Nullable.h"
17
#include "mozilla/dom/PrimitiveConversions.h"
18
#include "mozilla/dom/Promise.h"
19
#include "mozilla/dom/ToJSValue.h"
20
#include "mozilla/dom/XrayExpandoClass.h"
21
#include "nsContentUtils.h"
22
#include "nsDocument.h"
23
24
namespace mozilla {
25
namespace dom {
26
27
namespace binding_detail {}; // Just to make sure it's known as a namespace
28
using namespace mozilla::dom::binding_detail;
29
30
31
namespace AnimationPlayStateValues {
32
extern const EnumEntry strings[5] = {
33
  {"idle", 4},
34
  {"running", 7},
35
  {"paused", 6},
36
  {"finished", 8},
37
  { nullptr, 0 }
38
};
39
} // namespace AnimationPlayStateValues
40
41
bool
42
ToJSValue(JSContext* aCx, AnimationPlayState aArgument, JS::MutableHandle<JS::Value> aValue)
43
0
{
44
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(AnimationPlayStateValues::strings));
45
0
  JSString* resultStr =
46
0
    JS_NewStringCopyN(aCx, AnimationPlayStateValues::strings[uint32_t(aArgument)].value,
47
0
                      AnimationPlayStateValues::strings[uint32_t(aArgument)].length);
48
0
  if (!resultStr) {
49
0
    return false;
50
0
  }
51
0
  aValue.setString(resultStr);
52
0
  return true;
53
0
}
54
55
56
namespace Animation_Binding {
57
58
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value,
59
              "Can't inherit from an interface with a different ownership model.");
60
61
MOZ_CAN_RUN_SCRIPT static bool
62
get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
63
0
{
64
0
  AUTO_PROFILER_LABEL_FAST("get Animation.id", DOM, cx);
65
0
66
0
  DOMString result;
67
0
  self->GetId(result);
68
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
69
0
  if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
70
0
    return false;
71
0
  }
72
0
  return true;
73
0
}
74
75
MOZ_CAN_RUN_SCRIPT static bool
76
set_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
77
0
{
78
0
  AUTO_PROFILER_LABEL_FAST("set Animation.id", DOM, cx);
79
0
80
0
  binding_detail::FakeString arg0;
81
0
  if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
82
0
    return false;
83
0
  }
84
0
  self->SetId(NonNullHelper(Constify(arg0)));
85
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
86
0
87
0
  return true;
88
0
}
89
90
static const JSJitInfo id_getterinfo = {
91
  { (JSJitGetterOp)get_id },
92
  { prototypes::id::Animation },
93
  { PrototypeTraits<prototypes::id::Animation>::Depth },
94
  JSJitInfo::Getter,
95
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
96
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
97
  false,  /* isInfallible. False in setters. */
98
  false,  /* isMovable.  Not relevant for setters. */
99
  false, /* isEliminatable.  Not relevant for setters. */
100
  false, /* isAlwaysInSlot.  Only relevant for getters. */
101
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
102
  false,  /* isTypedMethod.  Only relevant for methods. */
103
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
104
};
105
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
106
static_assert(0 < 1, "There is no slot for us");
107
static const JSJitInfo id_setterinfo = {
108
  { (JSJitGetterOp)set_id },
109
  { prototypes::id::Animation },
110
  { PrototypeTraits<prototypes::id::Animation>::Depth },
111
  JSJitInfo::Setter,
112
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
113
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
114
  false,  /* isInfallible. False in setters. */
115
  false,  /* isMovable.  Not relevant for setters. */
116
  false, /* isEliminatable.  Not relevant for setters. */
117
  false, /* isAlwaysInSlot.  Only relevant for getters. */
118
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
119
  false,  /* isTypedMethod.  Only relevant for methods. */
120
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
121
};
122
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
123
static_assert(0 < 1, "There is no slot for us");
124
125
MOZ_CAN_RUN_SCRIPT static bool
126
get_effect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
127
0
{
128
0
  AUTO_PROFILER_LABEL_FAST("get Animation.effect", DOM, cx);
129
0
130
0
  auto result(StrongOrRawPtr<mozilla::dom::AnimationEffect>(self->GetEffect()));
131
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
132
0
  if (!result) {
133
0
    args.rval().setNull();
134
0
    return true;
135
0
  }
136
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
137
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
138
0
    return false;
139
0
  }
140
0
  return true;
141
0
}
142
143
MOZ_CAN_RUN_SCRIPT static bool
144
set_effect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
145
0
{
146
0
  AUTO_PROFILER_LABEL_FAST("set Animation.effect", DOM, cx);
147
0
148
0
  mozilla::dom::AnimationEffect* arg0;
149
0
  if (args[0].isObject()) {
150
0
    {
151
0
      nsresult rv = UnwrapObject<prototypes::id::AnimationEffect, mozilla::dom::AnimationEffect>(args[0], arg0);
152
0
      if (NS_FAILED(rv)) {
153
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to Animation.effect", "AnimationEffect");
154
0
        return false;
155
0
      }
156
0
    }
157
0
  } else if (args[0].isNullOrUndefined()) {
158
0
    arg0 = nullptr;
159
0
  } else {
160
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to Animation.effect");
161
0
    return false;
162
0
  }
163
0
  self->SetEffect(MOZ_KnownLive(Constify(arg0)));
164
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
165
0
166
0
  return true;
167
0
}
168
169
static const JSJitInfo effect_getterinfo = {
170
  { (JSJitGetterOp)get_effect },
171
  { prototypes::id::Animation },
172
  { PrototypeTraits<prototypes::id::Animation>::Depth },
173
  JSJitInfo::Getter,
174
  JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
175
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
176
  false,  /* isInfallible. False in setters. */
177
  true,  /* isMovable.  Not relevant for setters. */
178
  true, /* isEliminatable.  Not relevant for setters. */
179
  false, /* isAlwaysInSlot.  Only relevant for getters. */
180
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
181
  false,  /* isTypedMethod.  Only relevant for methods. */
182
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
183
};
184
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
185
static_assert(0 < 1, "There is no slot for us");
186
static const JSJitInfo effect_setterinfo = {
187
  { (JSJitGetterOp)set_effect },
188
  { prototypes::id::Animation },
189
  { PrototypeTraits<prototypes::id::Animation>::Depth },
190
  JSJitInfo::Setter,
191
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
192
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
193
  false,  /* isInfallible. False in setters. */
194
  false,  /* isMovable.  Not relevant for setters. */
195
  false, /* isEliminatable.  Not relevant for setters. */
196
  false, /* isAlwaysInSlot.  Only relevant for getters. */
197
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
198
  false,  /* isTypedMethod.  Only relevant for methods. */
199
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
200
};
201
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
202
static_assert(0 < 1, "There is no slot for us");
203
204
MOZ_CAN_RUN_SCRIPT static bool
205
get_timeline(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
206
0
{
207
0
  AUTO_PROFILER_LABEL_FAST("get Animation.timeline", DOM, cx);
208
0
209
0
  auto result(StrongOrRawPtr<mozilla::dom::AnimationTimeline>(self->GetTimeline()));
210
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
211
0
  if (!result) {
212
0
    args.rval().setNull();
213
0
    return true;
214
0
  }
215
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
216
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
217
0
    return false;
218
0
  }
219
0
  return true;
220
0
}
221
222
MOZ_CAN_RUN_SCRIPT static bool
223
set_timeline(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
224
0
{
225
0
  AUTO_PROFILER_LABEL_FAST("set Animation.timeline", DOM, cx);
226
0
227
0
  mozilla::dom::AnimationTimeline* arg0;
228
0
  if (args[0].isObject()) {
229
0
    {
230
0
      nsresult rv = UnwrapObject<prototypes::id::AnimationTimeline, mozilla::dom::AnimationTimeline>(args[0], arg0);
231
0
      if (NS_FAILED(rv)) {
232
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to Animation.timeline", "AnimationTimeline");
233
0
        return false;
234
0
      }
235
0
    }
236
0
  } else if (args[0].isNullOrUndefined()) {
237
0
    arg0 = nullptr;
238
0
  } else {
239
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to Animation.timeline");
240
0
    return false;
241
0
  }
242
0
  self->SetTimeline(MOZ_KnownLive(Constify(arg0)));
243
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
244
0
245
0
  return true;
246
0
}
247
248
static const JSJitInfo timeline_getterinfo = {
249
  { (JSJitGetterOp)get_timeline },
250
  { prototypes::id::Animation },
251
  { PrototypeTraits<prototypes::id::Animation>::Depth },
252
  JSJitInfo::Getter,
253
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
254
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
255
  false,  /* isInfallible. False in setters. */
256
  false,  /* isMovable.  Not relevant for setters. */
257
  false, /* isEliminatable.  Not relevant for setters. */
258
  false, /* isAlwaysInSlot.  Only relevant for getters. */
259
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
260
  false,  /* isTypedMethod.  Only relevant for methods. */
261
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
262
};
263
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
264
static_assert(0 < 1, "There is no slot for us");
265
static const JSJitInfo timeline_setterinfo = {
266
  { (JSJitGetterOp)set_timeline },
267
  { prototypes::id::Animation },
268
  { PrototypeTraits<prototypes::id::Animation>::Depth },
269
  JSJitInfo::Setter,
270
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
271
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
272
  false,  /* isInfallible. False in setters. */
273
  false,  /* isMovable.  Not relevant for setters. */
274
  false, /* isEliminatable.  Not relevant for setters. */
275
  false, /* isAlwaysInSlot.  Only relevant for getters. */
276
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
277
  false,  /* isTypedMethod.  Only relevant for methods. */
278
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
279
};
280
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
281
static_assert(0 < 1, "There is no slot for us");
282
283
MOZ_CAN_RUN_SCRIPT static bool
284
get_startTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
285
0
{
286
0
  AUTO_PROFILER_LABEL_FAST("get Animation.startTime", DOM, cx);
287
0
288
0
  Nullable<double> result(self->GetStartTimeAsDouble());
289
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
290
0
  if (result.IsNull()) {
291
0
    args.rval().setNull();
292
0
    return true;
293
0
  }
294
0
  args.rval().set(JS_NumberValue(double(result.Value())));
295
0
  return true;
296
0
}
297
298
MOZ_CAN_RUN_SCRIPT static bool
299
set_startTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
300
0
{
301
0
  AUTO_PROFILER_LABEL_FAST("set Animation.startTime", DOM, cx);
302
0
303
0
  Nullable<double> arg0;
304
0
  if (args[0].isNullOrUndefined()) {
305
0
    arg0.SetNull();
306
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0.SetValue())) {
307
0
    return false;
308
0
  } else if (!mozilla::IsFinite(arg0.Value())) {
309
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to Animation.startTime");
310
0
    return false;
311
0
  }
312
0
  self->SetStartTimeAsDouble(Constify(arg0));
313
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
314
0
315
0
  return true;
316
0
}
317
318
static const JSJitInfo startTime_getterinfo = {
319
  { (JSJitGetterOp)get_startTime },
320
  { prototypes::id::Animation },
321
  { PrototypeTraits<prototypes::id::Animation>::Depth },
322
  JSJitInfo::Getter,
323
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
324
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
325
  true,  /* isInfallible. False in setters. */
326
  false,  /* isMovable.  Not relevant for setters. */
327
  false, /* isEliminatable.  Not relevant for setters. */
328
  false, /* isAlwaysInSlot.  Only relevant for getters. */
329
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
330
  false,  /* isTypedMethod.  Only relevant for methods. */
331
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
332
};
333
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
334
static_assert(0 < 1, "There is no slot for us");
335
static const JSJitInfo startTime_setterinfo = {
336
  { (JSJitGetterOp)set_startTime },
337
  { prototypes::id::Animation },
338
  { PrototypeTraits<prototypes::id::Animation>::Depth },
339
  JSJitInfo::Setter,
340
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
341
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
342
  false,  /* isInfallible. False in setters. */
343
  false,  /* isMovable.  Not relevant for setters. */
344
  false, /* isEliminatable.  Not relevant for setters. */
345
  false, /* isAlwaysInSlot.  Only relevant for getters. */
346
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
347
  false,  /* isTypedMethod.  Only relevant for methods. */
348
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
349
};
350
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
351
static_assert(0 < 1, "There is no slot for us");
352
353
MOZ_CAN_RUN_SCRIPT static bool
354
get_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
355
0
{
356
0
  AUTO_PROFILER_LABEL_FAST("get Animation.currentTime", DOM, cx);
357
0
358
0
  Nullable<double> result(self->GetCurrentTimeAsDouble());
359
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
360
0
  if (result.IsNull()) {
361
0
    args.rval().setNull();
362
0
    return true;
363
0
  }
364
0
  args.rval().set(JS_NumberValue(double(result.Value())));
365
0
  return true;
366
0
}
367
368
MOZ_CAN_RUN_SCRIPT static bool
369
set_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
370
0
{
371
0
  AUTO_PROFILER_LABEL_FAST("set Animation.currentTime", DOM, cx);
372
0
373
0
  Nullable<double> arg0;
374
0
  if (args[0].isNullOrUndefined()) {
375
0
    arg0.SetNull();
376
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0.SetValue())) {
377
0
    return false;
378
0
  } else if (!mozilla::IsFinite(arg0.Value())) {
379
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to Animation.currentTime");
380
0
    return false;
381
0
  }
382
0
  FastErrorResult rv;
383
0
  self->SetCurrentTimeAsDouble(Constify(arg0), rv);
384
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
385
0
    return false;
386
0
  }
387
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
388
0
389
0
  return true;
390
0
}
391
392
static const JSJitInfo currentTime_getterinfo = {
393
  { (JSJitGetterOp)get_currentTime },
394
  { prototypes::id::Animation },
395
  { PrototypeTraits<prototypes::id::Animation>::Depth },
396
  JSJitInfo::Getter,
397
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
398
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
399
  true,  /* isInfallible. False in setters. */
400
  false,  /* isMovable.  Not relevant for setters. */
401
  false, /* isEliminatable.  Not relevant for setters. */
402
  false, /* isAlwaysInSlot.  Only relevant for getters. */
403
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
404
  false,  /* isTypedMethod.  Only relevant for methods. */
405
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
406
};
407
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
408
static_assert(0 < 1, "There is no slot for us");
409
static const JSJitInfo currentTime_setterinfo = {
410
  { (JSJitGetterOp)set_currentTime },
411
  { prototypes::id::Animation },
412
  { PrototypeTraits<prototypes::id::Animation>::Depth },
413
  JSJitInfo::Setter,
414
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
415
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
416
  false,  /* isInfallible. False in setters. */
417
  false,  /* isMovable.  Not relevant for setters. */
418
  false, /* isEliminatable.  Not relevant for setters. */
419
  false, /* isAlwaysInSlot.  Only relevant for getters. */
420
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
421
  false,  /* isTypedMethod.  Only relevant for methods. */
422
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
423
};
424
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
425
static_assert(0 < 1, "There is no slot for us");
426
427
MOZ_CAN_RUN_SCRIPT static bool
428
get_playbackRate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
429
0
{
430
0
  AUTO_PROFILER_LABEL_FAST("get Animation.playbackRate", DOM, cx);
431
0
432
0
  double result(self->PlaybackRate());
433
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
434
0
  args.rval().set(JS_NumberValue(double(result)));
435
0
  return true;
436
0
}
437
438
MOZ_CAN_RUN_SCRIPT static bool
439
set_playbackRate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
440
0
{
441
0
  AUTO_PROFILER_LABEL_FAST("set Animation.playbackRate", DOM, cx);
442
0
443
0
  double arg0;
444
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
445
0
    return false;
446
0
  } else if (!mozilla::IsFinite(arg0)) {
447
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to Animation.playbackRate");
448
0
    return false;
449
0
  }
450
0
  self->SetPlaybackRate(arg0);
451
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
452
0
453
0
  return true;
454
0
}
455
456
static const JSJitInfo playbackRate_getterinfo = {
457
  { (JSJitGetterOp)get_playbackRate },
458
  { prototypes::id::Animation },
459
  { PrototypeTraits<prototypes::id::Animation>::Depth },
460
  JSJitInfo::Getter,
461
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
462
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
463
  true,  /* isInfallible. False in setters. */
464
  false,  /* isMovable.  Not relevant for setters. */
465
  false, /* isEliminatable.  Not relevant for setters. */
466
  false, /* isAlwaysInSlot.  Only relevant for getters. */
467
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
468
  false,  /* isTypedMethod.  Only relevant for methods. */
469
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
470
};
471
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
472
static_assert(0 < 1, "There is no slot for us");
473
static const JSJitInfo playbackRate_setterinfo = {
474
  { (JSJitGetterOp)set_playbackRate },
475
  { prototypes::id::Animation },
476
  { PrototypeTraits<prototypes::id::Animation>::Depth },
477
  JSJitInfo::Setter,
478
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
479
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
480
  false,  /* isInfallible. False in setters. */
481
  false,  /* isMovable.  Not relevant for setters. */
482
  false, /* isEliminatable.  Not relevant for setters. */
483
  false, /* isAlwaysInSlot.  Only relevant for getters. */
484
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
485
  false,  /* isTypedMethod.  Only relevant for methods. */
486
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
487
};
488
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
489
static_assert(0 < 1, "There is no slot for us");
490
491
MOZ_CAN_RUN_SCRIPT static bool
492
get_playState(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
493
0
{
494
0
  AUTO_PROFILER_LABEL_FAST("get Animation.playState", DOM, cx);
495
0
496
0
  AnimationPlayState result(self->PlayStateFromJS());
497
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
498
0
  if (!ToJSValue(cx, result, args.rval())) {
499
0
    return false;
500
0
  }
501
0
  return true;
502
0
}
503
504
static const JSJitInfo playState_getterinfo = {
505
  { (JSJitGetterOp)get_playState },
506
  { prototypes::id::Animation },
507
  { PrototypeTraits<prototypes::id::Animation>::Depth },
508
  JSJitInfo::Getter,
509
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
510
  JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
511
  false,  /* isInfallible. False in setters. */
512
  false,  /* isMovable.  Not relevant for setters. */
513
  false, /* isEliminatable.  Not relevant for setters. */
514
  false, /* isAlwaysInSlot.  Only relevant for getters. */
515
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
516
  false,  /* isTypedMethod.  Only relevant for methods. */
517
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
518
};
519
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
520
static_assert(0 < 1, "There is no slot for us");
521
522
MOZ_CAN_RUN_SCRIPT static bool
523
get_pending(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
524
0
{
525
0
  AUTO_PROFILER_LABEL_FAST("get Animation.pending", DOM, cx);
526
0
527
0
  bool result(self->PendingFromJS());
528
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
529
0
  args.rval().setBoolean(result);
530
0
  return true;
531
0
}
532
533
static const JSJitInfo pending_getterinfo = {
534
  { (JSJitGetterOp)get_pending },
535
  { prototypes::id::Animation },
536
  { PrototypeTraits<prototypes::id::Animation>::Depth },
537
  JSJitInfo::Getter,
538
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
539
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
540
  true,  /* isInfallible. False in setters. */
541
  false,  /* isMovable.  Not relevant for setters. */
542
  false, /* isEliminatable.  Not relevant for setters. */
543
  false, /* isAlwaysInSlot.  Only relevant for getters. */
544
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
545
  false,  /* isTypedMethod.  Only relevant for methods. */
546
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
547
};
548
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
549
static_assert(0 < 1, "There is no slot for us");
550
551
MOZ_CAN_RUN_SCRIPT static bool
552
get_ready(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
553
0
{
554
0
  AUTO_PROFILER_LABEL_FAST("get Animation.ready", DOM, cx);
555
0
556
0
  FastErrorResult rv;
557
0
  auto result(StrongOrRawPtr<Promise>(self->GetReady(rv)));
558
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
559
0
    return false;
560
0
  }
561
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
562
0
  if (!ToJSValue(cx, result, args.rval())) {
563
0
    return false;
564
0
  }
565
0
  return true;
566
0
}
567
568
MOZ_CAN_RUN_SCRIPT static bool
569
get_ready_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
570
0
{
571
0
  bool ok = get_ready(cx, obj, self, args);
572
0
  if (ok) {
573
0
    return true;
574
0
  }
575
0
  return ConvertExceptionToPromise(cx, args.rval());
576
0
}
577
578
static const JSJitInfo ready_getterinfo = {
579
  { (JSJitGetterOp)get_ready_promiseWrapper },
580
  { prototypes::id::Animation },
581
  { PrototypeTraits<prototypes::id::Animation>::Depth },
582
  JSJitInfo::Getter,
583
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
584
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
585
  false,  /* isInfallible. False in setters. */
586
  false,  /* isMovable.  Not relevant for setters. */
587
  false, /* isEliminatable.  Not relevant for setters. */
588
  false, /* isAlwaysInSlot.  Only relevant for getters. */
589
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
590
  false,  /* isTypedMethod.  Only relevant for methods. */
591
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
592
};
593
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
594
static_assert(0 < 1, "There is no slot for us");
595
596
MOZ_CAN_RUN_SCRIPT static bool
597
get_finished(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
598
0
{
599
0
  AUTO_PROFILER_LABEL_FAST("get Animation.finished", DOM, cx);
600
0
601
0
  FastErrorResult rv;
602
0
  auto result(StrongOrRawPtr<Promise>(self->GetFinished(rv)));
603
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
604
0
    return false;
605
0
  }
606
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
607
0
  if (!ToJSValue(cx, result, args.rval())) {
608
0
    return false;
609
0
  }
610
0
  return true;
611
0
}
612
613
MOZ_CAN_RUN_SCRIPT static bool
614
get_finished_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
615
0
{
616
0
  bool ok = get_finished(cx, obj, self, args);
617
0
  if (ok) {
618
0
    return true;
619
0
  }
620
0
  return ConvertExceptionToPromise(cx, args.rval());
621
0
}
622
623
static const JSJitInfo finished_getterinfo = {
624
  { (JSJitGetterOp)get_finished_promiseWrapper },
625
  { prototypes::id::Animation },
626
  { PrototypeTraits<prototypes::id::Animation>::Depth },
627
  JSJitInfo::Getter,
628
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
629
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
630
  false,  /* isInfallible. False in setters. */
631
  false,  /* isMovable.  Not relevant for setters. */
632
  false, /* isEliminatable.  Not relevant for setters. */
633
  false, /* isAlwaysInSlot.  Only relevant for getters. */
634
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
635
  false,  /* isTypedMethod.  Only relevant for methods. */
636
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
637
};
638
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
639
static_assert(0 < 1, "There is no slot for us");
640
641
MOZ_CAN_RUN_SCRIPT static bool
642
get_onfinish(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
643
0
{
644
0
  AUTO_PROFILER_LABEL_FAST("get Animation.onfinish", DOM, cx);
645
0
646
0
  RefPtr<EventHandlerNonNull> result(self->GetOnfinish());
647
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
648
0
  if (result) {
649
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
650
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
651
0
      return false;
652
0
    }
653
0
    return true;
654
0
  } else {
655
0
    args.rval().setNull();
656
0
    return true;
657
0
  }
658
0
}
659
660
MOZ_CAN_RUN_SCRIPT static bool
661
set_onfinish(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
662
0
{
663
0
  AUTO_PROFILER_LABEL_FAST("set Animation.onfinish", DOM, cx);
664
0
665
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
666
0
  if (args[0].isObject()) {
667
0
    { // scope for tempRoot and tempGlobalRoot if needed
668
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
669
0
    }
670
0
  } else {
671
0
    arg0 = nullptr;
672
0
  }
673
0
  self->SetOnfinish(Constify(arg0));
674
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
675
0
676
0
  return true;
677
0
}
678
679
static const JSJitInfo onfinish_getterinfo = {
680
  { (JSJitGetterOp)get_onfinish },
681
  { prototypes::id::Animation },
682
  { PrototypeTraits<prototypes::id::Animation>::Depth },
683
  JSJitInfo::Getter,
684
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
685
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
686
  false,  /* isInfallible. False in setters. */
687
  false,  /* isMovable.  Not relevant for setters. */
688
  false, /* isEliminatable.  Not relevant for setters. */
689
  false, /* isAlwaysInSlot.  Only relevant for getters. */
690
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
691
  false,  /* isTypedMethod.  Only relevant for methods. */
692
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
693
};
694
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
695
static_assert(0 < 1, "There is no slot for us");
696
static const JSJitInfo onfinish_setterinfo = {
697
  { (JSJitGetterOp)set_onfinish },
698
  { prototypes::id::Animation },
699
  { PrototypeTraits<prototypes::id::Animation>::Depth },
700
  JSJitInfo::Setter,
701
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
702
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
703
  false,  /* isInfallible. False in setters. */
704
  false,  /* isMovable.  Not relevant for setters. */
705
  false, /* isEliminatable.  Not relevant for setters. */
706
  false, /* isAlwaysInSlot.  Only relevant for getters. */
707
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
708
  false,  /* isTypedMethod.  Only relevant for methods. */
709
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
710
};
711
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
712
static_assert(0 < 1, "There is no slot for us");
713
714
MOZ_CAN_RUN_SCRIPT static bool
715
get_oncancel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
716
0
{
717
0
  AUTO_PROFILER_LABEL_FAST("get Animation.oncancel", DOM, cx);
718
0
719
0
  RefPtr<EventHandlerNonNull> result(self->GetOncancel());
720
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
721
0
  if (result) {
722
0
    args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result));
723
0
    if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
724
0
      return false;
725
0
    }
726
0
    return true;
727
0
  } else {
728
0
    args.rval().setNull();
729
0
    return true;
730
0
  }
731
0
}
732
733
MOZ_CAN_RUN_SCRIPT static bool
734
set_oncancel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitSetterCallArgs args)
735
0
{
736
0
  AUTO_PROFILER_LABEL_FAST("set Animation.oncancel", DOM, cx);
737
0
738
0
  RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
739
0
  if (args[0].isObject()) {
740
0
    { // scope for tempRoot and tempGlobalRoot if needed
741
0
      arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx));
742
0
    }
743
0
  } else {
744
0
    arg0 = nullptr;
745
0
  }
746
0
  self->SetOncancel(Constify(arg0));
747
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
748
0
749
0
  return true;
750
0
}
751
752
static const JSJitInfo oncancel_getterinfo = {
753
  { (JSJitGetterOp)get_oncancel },
754
  { prototypes::id::Animation },
755
  { PrototypeTraits<prototypes::id::Animation>::Depth },
756
  JSJitInfo::Getter,
757
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
758
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
759
  false,  /* isInfallible. False in setters. */
760
  false,  /* isMovable.  Not relevant for setters. */
761
  false, /* isEliminatable.  Not relevant for setters. */
762
  false, /* isAlwaysInSlot.  Only relevant for getters. */
763
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
764
  false,  /* isTypedMethod.  Only relevant for methods. */
765
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
766
};
767
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
768
static_assert(0 < 1, "There is no slot for us");
769
static const JSJitInfo oncancel_setterinfo = {
770
  { (JSJitGetterOp)set_oncancel },
771
  { prototypes::id::Animation },
772
  { PrototypeTraits<prototypes::id::Animation>::Depth },
773
  JSJitInfo::Setter,
774
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
775
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
776
  false,  /* isInfallible. False in setters. */
777
  false,  /* isMovable.  Not relevant for setters. */
778
  false, /* isEliminatable.  Not relevant for setters. */
779
  false, /* isAlwaysInSlot.  Only relevant for getters. */
780
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
781
  false,  /* isTypedMethod.  Only relevant for methods. */
782
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
783
};
784
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
785
static_assert(0 < 1, "There is no slot for us");
786
787
MOZ_CAN_RUN_SCRIPT static bool
788
cancel(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, const JSJitMethodCallArgs& args)
789
0
{
790
0
  AUTO_PROFILER_LABEL_FAST("Animation.cancel", DOM, cx);
791
0
792
0
  self->Cancel();
793
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
794
0
  args.rval().setUndefined();
795
0
  return true;
796
0
}
797
798
static const JSJitInfo cancel_methodinfo = {
799
  { (JSJitGetterOp)cancel },
800
  { prototypes::id::Animation },
801
  { PrototypeTraits<prototypes::id::Animation>::Depth },
802
  JSJitInfo::Method,
803
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
804
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
805
  true,  /* isInfallible. False in setters. */
806
  false,  /* isMovable.  Not relevant for setters. */
807
  false, /* isEliminatable.  Not relevant for setters. */
808
  false, /* isAlwaysInSlot.  Only relevant for getters. */
809
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
810
  false,  /* isTypedMethod.  Only relevant for methods. */
811
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
812
};
813
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
814
static_assert(0 < 1, "There is no slot for us");
815
816
MOZ_CAN_RUN_SCRIPT static bool
817
finish(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, const JSJitMethodCallArgs& args)
818
0
{
819
0
  AUTO_PROFILER_LABEL_FAST("Animation.finish", DOM, cx);
820
0
821
0
  FastErrorResult rv;
822
0
  self->Finish(rv);
823
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
824
0
    return false;
825
0
  }
826
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
827
0
  args.rval().setUndefined();
828
0
  return true;
829
0
}
830
831
static const JSJitInfo finish_methodinfo = {
832
  { (JSJitGetterOp)finish },
833
  { prototypes::id::Animation },
834
  { PrototypeTraits<prototypes::id::Animation>::Depth },
835
  JSJitInfo::Method,
836
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
837
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
838
  false,  /* isInfallible. False in setters. */
839
  false,  /* isMovable.  Not relevant for setters. */
840
  false, /* isEliminatable.  Not relevant for setters. */
841
  false, /* isAlwaysInSlot.  Only relevant for getters. */
842
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
843
  false,  /* isTypedMethod.  Only relevant for methods. */
844
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
845
};
846
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
847
static_assert(0 < 1, "There is no slot for us");
848
849
MOZ_CAN_RUN_SCRIPT static bool
850
play(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, const JSJitMethodCallArgs& args)
851
0
{
852
0
  AUTO_PROFILER_LABEL_FAST("Animation.play", DOM, cx);
853
0
854
0
  FastErrorResult rv;
855
0
  self->PlayFromJS(rv);
856
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
857
0
    return false;
858
0
  }
859
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
860
0
  args.rval().setUndefined();
861
0
  return true;
862
0
}
863
864
static const JSJitInfo play_methodinfo = {
865
  { (JSJitGetterOp)play },
866
  { prototypes::id::Animation },
867
  { PrototypeTraits<prototypes::id::Animation>::Depth },
868
  JSJitInfo::Method,
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
pause(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, const JSJitMethodCallArgs& args)
884
0
{
885
0
  AUTO_PROFILER_LABEL_FAST("Animation.pause", DOM, cx);
886
0
887
0
  FastErrorResult rv;
888
0
  self->PauseFromJS(rv);
889
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
890
0
    return false;
891
0
  }
892
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
893
0
  args.rval().setUndefined();
894
0
  return true;
895
0
}
896
897
static const JSJitInfo pause_methodinfo = {
898
  { (JSJitGetterOp)pause },
899
  { prototypes::id::Animation },
900
  { PrototypeTraits<prototypes::id::Animation>::Depth },
901
  JSJitInfo::Method,
902
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
903
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
904
  false,  /* isInfallible. False in setters. */
905
  false,  /* isMovable.  Not relevant for setters. */
906
  false, /* isEliminatable.  Not relevant for setters. */
907
  false, /* isAlwaysInSlot.  Only relevant for getters. */
908
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
909
  false,  /* isTypedMethod.  Only relevant for methods. */
910
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
911
};
912
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
913
static_assert(0 < 1, "There is no slot for us");
914
915
MOZ_CAN_RUN_SCRIPT static bool
916
updatePlaybackRate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, const JSJitMethodCallArgs& args)
917
0
{
918
0
  AUTO_PROFILER_LABEL_FAST("Animation.updatePlaybackRate", DOM, cx);
919
0
920
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
921
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "Animation.updatePlaybackRate");
922
0
  }
923
0
  double arg0;
924
0
  if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
925
0
    return false;
926
0
  } else if (!mozilla::IsFinite(arg0)) {
927
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of Animation.updatePlaybackRate");
928
0
    return false;
929
0
  }
930
0
  self->UpdatePlaybackRate(arg0);
931
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
932
0
  args.rval().setUndefined();
933
0
  return true;
934
0
}
935
936
static const JSJitInfo updatePlaybackRate_methodinfo = {
937
  { (JSJitGetterOp)updatePlaybackRate },
938
  { prototypes::id::Animation },
939
  { PrototypeTraits<prototypes::id::Animation>::Depth },
940
  JSJitInfo::Method,
941
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
942
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
943
  false,  /* isInfallible. False in setters. */
944
  false,  /* isMovable.  Not relevant for setters. */
945
  false, /* isEliminatable.  Not relevant for setters. */
946
  false, /* isAlwaysInSlot.  Only relevant for getters. */
947
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
948
  false,  /* isTypedMethod.  Only relevant for methods. */
949
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
950
};
951
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
952
static_assert(0 < 1, "There is no slot for us");
953
954
MOZ_CAN_RUN_SCRIPT static bool
955
reverse(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, const JSJitMethodCallArgs& args)
956
0
{
957
0
  AUTO_PROFILER_LABEL_FAST("Animation.reverse", DOM, cx);
958
0
959
0
  FastErrorResult rv;
960
0
  self->Reverse(rv);
961
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
962
0
    return false;
963
0
  }
964
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
965
0
  args.rval().setUndefined();
966
0
  return true;
967
0
}
968
969
static const JSJitInfo reverse_methodinfo = {
970
  { (JSJitGetterOp)reverse },
971
  { prototypes::id::Animation },
972
  { PrototypeTraits<prototypes::id::Animation>::Depth },
973
  JSJitInfo::Method,
974
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
975
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
976
  false,  /* isInfallible. False in setters. */
977
  false,  /* isMovable.  Not relevant for setters. */
978
  false, /* isEliminatable.  Not relevant for setters. */
979
  false, /* isAlwaysInSlot.  Only relevant for getters. */
980
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
981
  false,  /* isTypedMethod.  Only relevant for methods. */
982
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
983
};
984
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
985
static_assert(0 < 1, "There is no slot for us");
986
987
MOZ_CAN_RUN_SCRIPT static bool
988
get_isRunningOnCompositor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::Animation* self, JSJitGetterCallArgs args)
989
0
{
990
0
  AUTO_PROFILER_LABEL_FAST("get Animation.isRunningOnCompositor", DOM, cx);
991
0
992
0
  bool result(self->IsRunningOnCompositor());
993
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
994
0
  args.rval().setBoolean(result);
995
0
  return true;
996
0
}
997
998
static const JSJitInfo isRunningOnCompositor_getterinfo = {
999
  { (JSJitGetterOp)get_isRunningOnCompositor },
1000
  { prototypes::id::Animation },
1001
  { PrototypeTraits<prototypes::id::Animation>::Depth },
1002
  JSJitInfo::Getter,
1003
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1004
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
1005
  true,  /* isInfallible. False in setters. */
1006
  false,  /* isMovable.  Not relevant for setters. */
1007
  false, /* isEliminatable.  Not relevant for setters. */
1008
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1009
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1010
  false,  /* isTypedMethod.  Only relevant for methods. */
1011
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1012
};
1013
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1014
static_assert(0 < 1, "There is no slot for us");
1015
1016
static bool
1017
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1018
0
{
1019
0
  mozilla::dom::Animation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Animation>(obj);
1020
0
  // We don't want to preserve if we don't have a wrapper, and we
1021
0
  // obviously can't preserve if we're not initialized.
1022
0
  if (self && self->GetWrapperPreserveColor()) {
1023
0
    PreserveWrapper(self);
1024
0
  }
1025
0
  return true;
1026
0
}
1027
1028
static void
1029
_finalize(js::FreeOp* fop, JSObject* obj)
1030
0
{
1031
0
  mozilla::dom::Animation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Animation>(obj);
1032
0
  if (self) {
1033
0
    ClearWrapper(self, self, obj);
1034
0
    AddForDeferredFinalization<mozilla::dom::Animation>(self);
1035
0
  }
1036
0
}
1037
1038
static size_t
1039
_objectMoved(JSObject* obj, JSObject* old)
1040
0
{
1041
0
  mozilla::dom::Animation* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Animation>(obj);
1042
0
  if (self) {
1043
0
    UpdateWrapper(self, self, obj, old);
1044
0
  }
1045
0
1046
0
  return 0;
1047
0
}
1048
1049
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1050
#if defined(__clang__)
1051
#pragma clang diagnostic push
1052
#pragma clang diagnostic ignored "-Wmissing-braces"
1053
#endif
1054
static const JSFunctionSpec sMethods_specs[] = {
1055
  JS_FNSPEC("cancel", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&cancel_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1056
  JS_FNSPEC("finish", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&finish_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1057
  JS_FNSPEC("play", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&play_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1058
  JS_FNSPEC("pause", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&pause_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1059
  JS_FNSPEC("updatePlaybackRate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&updatePlaybackRate_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1060
  JS_FNSPEC("reverse", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&reverse_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1061
  JS_FS_END
1062
};
1063
#if defined(__clang__)
1064
#pragma clang diagnostic pop
1065
#endif
1066
1067
1068
static const Prefable<const JSFunctionSpec> sMethods[] = {
1069
  { nullptr, &sMethods_specs[0] },
1070
  { nullptr, nullptr }
1071
};
1072
1073
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1074
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1075
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1076
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1077
1078
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1079
#if defined(__clang__)
1080
#pragma clang diagnostic push
1081
#pragma clang diagnostic ignored "-Wmissing-braces"
1082
#endif
1083
static const JSPropertySpec sAttributes_specs[] = {
1084
  { "id", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &id_getterinfo, GenericSetter<NormalThisPolicy>, &id_setterinfo },
1085
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1086
  { "effect", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &effect_getterinfo, GenericSetter<NormalThisPolicy>, &effect_setterinfo },
1087
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1088
  { "timeline", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &timeline_getterinfo, GenericSetter<NormalThisPolicy>, &timeline_setterinfo },
1089
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1090
  { "startTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &startTime_getterinfo, GenericSetter<NormalThisPolicy>, &startTime_setterinfo },
1091
  { "currentTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &currentTime_getterinfo, GenericSetter<NormalThisPolicy>, &currentTime_setterinfo },
1092
  { "playbackRate", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &playbackRate_getterinfo, GenericSetter<NormalThisPolicy>, &playbackRate_setterinfo },
1093
  { "playState", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &playState_getterinfo, nullptr, nullptr },
1094
  { "pending", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &pending_getterinfo, nullptr, nullptr },
1095
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1096
  { "ready", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ConvertExceptionsToPromises>, &ready_getterinfo, nullptr, nullptr },
1097
  { "finished", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ConvertExceptionsToPromises>, &finished_getterinfo, nullptr, nullptr },
1098
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
1099
  { "onfinish", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onfinish_getterinfo, GenericSetter<NormalThisPolicy>, &onfinish_setterinfo },
1100
  { "oncancel", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &oncancel_getterinfo, GenericSetter<NormalThisPolicy>, &oncancel_setterinfo },
1101
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1102
};
1103
#if defined(__clang__)
1104
#pragma clang diagnostic pop
1105
#endif
1106
1107
// Can't be const because the pref-enabled boolean needs to be writable
1108
static PrefableDisablers sAttributes_disablers2 = {
1109
  true, false, 0, &nsDocument::IsWebAnimationsEnabled
1110
};
1111
1112
// Can't be const because the pref-enabled boolean needs to be writable
1113
static PrefableDisablers sAttributes_disablers4 = {
1114
  true, false, 0, &nsDocument::AreWebAnimationsTimelinesEnabled
1115
};
1116
1117
// Can't be const because the pref-enabled boolean needs to be writable
1118
static PrefableDisablers sAttributes_disablers12 = {
1119
  true, false, 0, &nsDocument::IsWebAnimationsEnabled
1120
};
1121
1122
static const Prefable<const JSPropertySpec> sAttributes[] = {
1123
  { nullptr, &sAttributes_specs[0] },
1124
  { &sAttributes_disablers2, &sAttributes_specs[2] },
1125
  { &sAttributes_disablers4, &sAttributes_specs[4] },
1126
  { nullptr, &sAttributes_specs[6] },
1127
  { &sAttributes_disablers12, &sAttributes_specs[12] },
1128
  { nullptr, &sAttributes_specs[15] },
1129
  { nullptr, nullptr }
1130
};
1131
1132
static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1133
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1134
static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1135
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1136
1137
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1138
#if defined(__clang__)
1139
#pragma clang diagnostic push
1140
#pragma clang diagnostic ignored "-Wmissing-braces"
1141
#endif
1142
static const JSPropertySpec sChromeAttributes_specs[] = {
1143
  { "isRunningOnCompositor", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &isRunningOnCompositor_getterinfo, nullptr, nullptr },
1144
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1145
};
1146
#if defined(__clang__)
1147
#pragma clang diagnostic pop
1148
#endif
1149
1150
1151
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
1152
  { nullptr, &sChromeAttributes_specs[0] },
1153
  { nullptr, nullptr }
1154
};
1155
1156
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1157
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1158
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1159
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1160
1161
1162
static uint16_t sNativeProperties_sortedPropertyIndices[18];
1163
static PropertyInfo sNativeProperties_propertyInfos[18];
1164
1165
static const NativePropertiesN<2> sNativeProperties = {
1166
  false, 0,
1167
  false, 0,
1168
  true,  0 /* sMethods */,
1169
  true,  1 /* sAttributes */,
1170
  false, 0,
1171
  false, 0,
1172
  false, 0,
1173
  -1,
1174
  18,
1175
  sNativeProperties_sortedPropertyIndices,
1176
  {
1177
    { sMethods, &sNativeProperties_propertyInfos[0] },
1178
    { sAttributes, &sNativeProperties_propertyInfos[6] }
1179
  }
1180
};
1181
static_assert(18 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1182
    "We have a property info count that is oversized");
1183
1184
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
1185
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
1186
1187
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1188
  false, 0,
1189
  false, 0,
1190
  false, 0,
1191
  true,  0 /* sChromeAttributes */,
1192
  false, 0,
1193
  false, 0,
1194
  false, 0,
1195
  -1,
1196
  1,
1197
  sChromeOnlyNativeProperties_sortedPropertyIndices,
1198
  {
1199
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
1200
  }
1201
};
1202
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1203
    "We have a property info count that is oversized");
1204
1205
static bool
1206
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1207
0
{
1208
0
  AUTO_PROFILER_LABEL_FAST("Animation constructor", DOM, cx);
1209
0
1210
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1211
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
1212
0
  if (!args.isConstructing()) {
1213
0
    // XXXbz wish I could get the name from the callee instead of
1214
0
    // Adding more relocations
1215
0
    return ThrowConstructorWithoutNew(cx, "Animation");
1216
0
  }
1217
0
1218
0
  JS::Rooted<JSObject*> desiredProto(cx);
1219
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
1220
0
    return false;
1221
0
  }
1222
0
1223
0
  GlobalObject global(cx, obj);
1224
0
  if (global.Failed()) {
1225
0
    return false;
1226
0
  }
1227
0
1228
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1229
0
  mozilla::dom::AnimationEffect* arg0;
1230
0
  if (args.hasDefined(0)) {
1231
0
    if (args[0].isObject()) {
1232
0
      {
1233
0
        nsresult rv = UnwrapObject<prototypes::id::AnimationEffect, mozilla::dom::AnimationEffect>(args[0], arg0);
1234
0
        if (NS_FAILED(rv)) {
1235
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of Animation.constructor", "AnimationEffect");
1236
0
          return false;
1237
0
        }
1238
0
      }
1239
0
    } else if (args[0].isNullOrUndefined()) {
1240
0
      arg0 = nullptr;
1241
0
    } else {
1242
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of Animation.constructor");
1243
0
      return false;
1244
0
    }
1245
0
  } else {
1246
0
    arg0 = nullptr;
1247
0
  }
1248
0
  Optional<mozilla::dom::AnimationTimeline*> arg1;
1249
0
  if (args.hasDefined(1)) {
1250
0
    arg1.Construct();
1251
0
    if (args[1].isObject()) {
1252
0
      {
1253
0
        nsresult rv = UnwrapObject<prototypes::id::AnimationTimeline, mozilla::dom::AnimationTimeline>(args[1], arg1.Value());
1254
0
        if (NS_FAILED(rv)) {
1255
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of Animation.constructor", "AnimationTimeline");
1256
0
          return false;
1257
0
        }
1258
0
      }
1259
0
    } else if (args[1].isNullOrUndefined()) {
1260
0
      arg1.Value() = nullptr;
1261
0
    } else {
1262
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of Animation.constructor");
1263
0
      return false;
1264
0
    }
1265
0
  }
1266
0
  Maybe<JSAutoRealm> ar;
1267
0
  if (objIsXray) {
1268
0
    obj = js::CheckedUnwrap(obj);
1269
0
    if (!obj) {
1270
0
      return false;
1271
0
    }
1272
0
    ar.emplace(cx, obj);
1273
0
    if (!JS_WrapObject(cx, &desiredProto)) {
1274
0
      return false;
1275
0
    }
1276
0
  }
1277
0
  FastErrorResult rv;
1278
0
  auto result(StrongOrRawPtr<mozilla::dom::Animation>(mozilla::dom::Animation::Constructor(global, MOZ_KnownLive(Constify(arg0)), MOZ_KnownLive(Constify(arg1)), rv)));
1279
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1280
0
    return false;
1281
0
  }
1282
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1283
0
  static_assert(!IsPointer<decltype(result)>::value,
1284
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
1285
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1286
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
1287
0
    return false;
1288
0
  }
1289
0
  return true;
1290
0
}
1291
1292
static const js::ClassOps sInterfaceObjectClassOps = {
1293
    nullptr,               /* addProperty */
1294
    nullptr,               /* delProperty */
1295
    nullptr,               /* enumerate */
1296
    nullptr,               /* newEnumerate */
1297
    nullptr,               /* resolve */
1298
    nullptr,               /* mayResolve */
1299
    nullptr,               /* finalize */
1300
    _constructor, /* call */
1301
    nullptr,               /* hasInstance */
1302
    _constructor, /* construct */
1303
    nullptr,               /* trace */
1304
};
1305
1306
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1307
  {
1308
    "Function",
1309
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1310
    &sInterfaceObjectClassOps,
1311
    JS_NULL_CLASS_SPEC,
1312
    JS_NULL_CLASS_EXT,
1313
    &sInterfaceObjectClassObjectOps
1314
  },
1315
  eInterface,
1316
  true,
1317
  prototypes::id::Animation,
1318
  PrototypeTraits<prototypes::id::Animation>::Depth,
1319
  sNativePropertyHooks,
1320
  "function Animation() {\n    [native code]\n}",
1321
  EventTarget_Binding::GetConstructorObject
1322
};
1323
1324
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1325
  {
1326
    "AnimationPrototype",
1327
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1328
    JS_NULL_CLASS_OPS,
1329
    JS_NULL_CLASS_SPEC,
1330
    JS_NULL_CLASS_EXT,
1331
    JS_NULL_OBJECT_OPS
1332
  },
1333
  eInterfacePrototype,
1334
  false,
1335
  prototypes::id::Animation,
1336
  PrototypeTraits<prototypes::id::Animation>::Depth,
1337
  sNativePropertyHooks,
1338
  "[object AnimationPrototype]",
1339
  EventTarget_Binding::GetProtoObject
1340
};
1341
1342
static const js::ClassOps sClassOps = {
1343
  _addProperty, /* addProperty */
1344
  nullptr,               /* delProperty */
1345
  nullptr,               /* enumerate */
1346
  nullptr, /* newEnumerate */
1347
  nullptr, /* resolve */
1348
  nullptr, /* mayResolve */
1349
  _finalize, /* finalize */
1350
  nullptr, /* call */
1351
  nullptr,               /* hasInstance */
1352
  nullptr,               /* construct */
1353
  nullptr, /* trace */
1354
};
1355
1356
static const js::ClassExtension sClassExtension = {
1357
  nullptr, /* weakmapKeyDelegateOp */
1358
  _objectMoved /* objectMovedOp */
1359
};
1360
1361
static const DOMJSClass sClass = {
1362
  { "Animation",
1363
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1364
    &sClassOps,
1365
    JS_NULL_CLASS_SPEC,
1366
    &sClassExtension,
1367
    JS_NULL_OBJECT_OPS
1368
  },
1369
  { prototypes::id::EventTarget, prototypes::id::Animation, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1370
  IsBaseOf<nsISupports, mozilla::dom::Animation >::value,
1371
  sNativePropertyHooks,
1372
  FindAssociatedGlobalForNative<mozilla::dom::Animation>::Get,
1373
  GetProtoObjectHandle,
1374
  GetCCParticipant<mozilla::dom::Animation>::Get()
1375
};
1376
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1377
              "Must have the right minimal number of reserved slots.");
1378
static_assert(1 >= 1,
1379
              "Must have enough reserved slots.");
1380
1381
const JSClass*
1382
GetJSClass()
1383
0
{
1384
0
  return sClass.ToJSClass();
1385
0
}
1386
1387
bool
1388
Wrap(JSContext* aCx, mozilla::dom::Animation* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1389
0
{
1390
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::Animation>::value,
1391
0
                "Shouldn't have wrappercached things that are not refcounted.");
1392
0
  MOZ_ASSERT(static_cast<mozilla::dom::Animation*>(aObject) ==
1393
0
             reinterpret_cast<mozilla::dom::Animation*>(aObject),
1394
0
             "Multiple inheritance for mozilla::dom::Animation is broken.");
1395
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1396
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1397
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1398
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1399
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1400
0
  MOZ_ASSERT(!aCache->GetWrapper(),
1401
0
             "You should probably not be using Wrap() directly; use "
1402
0
             "GetOrCreateDOMReflector instead");
1403
0
1404
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1405
0
             "nsISupports must be on our primary inheritance chain");
1406
0
1407
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1408
0
  if (!global) {
1409
0
    return false;
1410
0
  }
1411
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
1412
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
1413
0
1414
0
  // That might have ended up wrapping us already, due to the wonders
1415
0
  // of XBL.  Check for that, and bail out as needed.
1416
0
  aReflector.set(aCache->GetWrapper());
1417
0
  if (aReflector) {
1418
#ifdef DEBUG
1419
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1420
#endif // DEBUG
1421
    return true;
1422
0
  }
1423
0
1424
0
  JSAutoRealm ar(aCx, global);
1425
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1426
0
  if (!canonicalProto) {
1427
0
    return false;
1428
0
  }
1429
0
  JS::Rooted<JSObject*> proto(aCx);
1430
0
  if (aGivenProto) {
1431
0
    proto = aGivenProto;
1432
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
1433
0
    // coming in, we changed compartments to that of "parent" so may need
1434
0
    // to wrap the proto here.
1435
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1436
0
      if (!JS_WrapObject(aCx, &proto)) {
1437
0
        return false;
1438
0
      }
1439
0
    }
1440
0
  } else {
1441
0
    proto = canonicalProto;
1442
0
  }
1443
0
1444
0
  BindingJSObjectCreator<mozilla::dom::Animation> creator(aCx);
1445
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1446
0
  if (!aReflector) {
1447
0
    return false;
1448
0
  }
1449
0
1450
0
  aCache->SetWrapper(aReflector);
1451
0
  creator.InitializationSucceeded();
1452
0
1453
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1454
0
             aCache->GetWrapperPreserveColor() == aReflector);
1455
0
  // If proto != canonicalProto, we have to preserve our wrapper;
1456
0
  // otherwise we won't be able to properly recreate it later, since
1457
0
  // we won't know what proto to use.  Note that we don't check
1458
0
  // aGivenProto here, since it's entirely possible (and even
1459
0
  // somewhat common) to have a non-null aGivenProto which is the
1460
0
  // same as canonicalProto.
1461
0
  if (proto != canonicalProto) {
1462
0
    PreserveWrapper(aObject);
1463
0
  }
1464
0
1465
0
  return true;
1466
0
}
1467
1468
const NativePropertyHooks sNativePropertyHooks[] = { {
1469
  nullptr,
1470
  nullptr,
1471
  nullptr,
1472
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1473
  prototypes::id::Animation,
1474
  constructors::id::Animation,
1475
  EventTarget_Binding::sNativePropertyHooks,
1476
  &DefaultXrayExpandoObjectClass
1477
} };
1478
1479
void
1480
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1481
0
{
1482
0
  JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx));
1483
0
  if (!parentProto) {
1484
0
    return;
1485
0
  }
1486
0
1487
0
  JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx));
1488
0
  if (!constructorProto) {
1489
0
    return;
1490
0
  }
1491
0
1492
0
  static bool sIdsInited = false;
1493
0
  if (!sIdsInited && NS_IsMainThread()) {
1494
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1495
0
      return;
1496
0
    }
1497
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1498
0
      return;
1499
0
    }
1500
0
    sIdsInited = true;
1501
0
  }
1502
0
1503
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Animation);
1504
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Animation);
1505
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1506
0
                              &sPrototypeClass.mBase, protoCache,
1507
0
                              nullptr,
1508
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1509
0
                              interfaceCache,
1510
0
                              sNativeProperties.Upcast(),
1511
0
                              sChromeOnlyNativeProperties.Upcast(),
1512
0
                              "Animation", aDefineOnGlobal,
1513
0
                              nullptr,
1514
0
                              false);
1515
0
}
1516
1517
JSObject*
1518
GetProtoObject(JSContext* aCx)
1519
0
{
1520
0
  return GetProtoObjectHandle(aCx);
1521
0
}
1522
1523
JSObject*
1524
GetConstructorObject(JSContext* aCx)
1525
0
{
1526
0
  return GetConstructorObjectHandle(aCx);
1527
0
}
1528
1529
} // namespace Animation_Binding
1530
1531
1532
1533
} // namespace dom
1534
} // namespace mozilla