Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/AnimationEffectBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM AnimationEffect.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AnimationEffectBinding.h"
4
#include "AtomList.h"
5
#include "WrapperFactory.h"
6
#include "jsapi.h"
7
#include "mozilla/FloatingPoint.h"
8
#include "mozilla/OwningNonNull.h"
9
#include "mozilla/dom/AnimationEffect.h"
10
#include "mozilla/dom/BindingUtils.h"
11
#include "mozilla/dom/DOMJSClass.h"
12
#include "mozilla/dom/NonRefcountedDOMObject.h"
13
#include "mozilla/dom/PrimitiveConversions.h"
14
#include "mozilla/dom/ScriptSettings.h"
15
#include "mozilla/dom/UnionConversions.h"
16
#include "mozilla/dom/XrayExpandoClass.h"
17
#include "nsDocument.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
namespace binding_detail {}; // Just to make sure it's known as a namespace
23
using namespace mozilla::dom::binding_detail;
24
25
26
namespace FillModeValues {
27
extern const EnumEntry strings[6] = {
28
  {"none", 4},
29
  {"forwards", 8},
30
  {"backwards", 9},
31
  {"both", 4},
32
  {"auto", 4},
33
  { nullptr, 0 }
34
};
35
} // namespace FillModeValues
36
37
bool
38
ToJSValue(JSContext* aCx, FillMode aArgument, JS::MutableHandle<JS::Value> aValue)
39
0
{
40
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(FillModeValues::strings));
41
0
  JSString* resultStr =
42
0
    JS_NewStringCopyN(aCx, FillModeValues::strings[uint32_t(aArgument)].value,
43
0
                      FillModeValues::strings[uint32_t(aArgument)].length);
44
0
  if (!resultStr) {
45
0
    return false;
46
0
  }
47
0
  aValue.setString(resultStr);
48
0
  return true;
49
0
}
50
51
52
namespace PlaybackDirectionValues {
53
extern const EnumEntry strings[5] = {
54
  {"normal", 6},
55
  {"reverse", 7},
56
  {"alternate", 9},
57
  {"alternate-reverse", 17},
58
  { nullptr, 0 }
59
};
60
} // namespace PlaybackDirectionValues
61
62
bool
63
ToJSValue(JSContext* aCx, PlaybackDirection aArgument, JS::MutableHandle<JS::Value> aValue)
64
0
{
65
0
  MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PlaybackDirectionValues::strings));
66
0
  JSString* resultStr =
67
0
    JS_NewStringCopyN(aCx, PlaybackDirectionValues::strings[uint32_t(aArgument)].value,
68
0
                      PlaybackDirectionValues::strings[uint32_t(aArgument)].length);
69
0
  if (!resultStr) {
70
0
    return false;
71
0
  }
72
0
  aValue.setString(resultStr);
73
0
  return true;
74
0
}
75
76
77
78
EffectTiming::EffectTiming()
79
0
{
80
0
  // Safe to pass a null context if we pass a null value
81
0
  Init(nullptr, JS::NullHandleValue);
82
0
}
83
84
85
86
bool
87
EffectTiming::InitIds(JSContext* cx, EffectTimingAtoms* atomsCache)
88
0
{
89
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
90
0
91
0
  // Initialize these in reverse order so that any failure leaves the first one
92
0
  // uninitialized.
93
0
  if (!atomsCache->iterations_id.init(cx, "iterations") ||
94
0
      !atomsCache->iterationStart_id.init(cx, "iterationStart") ||
95
0
      !atomsCache->fill_id.init(cx, "fill") ||
96
0
      !atomsCache->endDelay_id.init(cx, "endDelay") ||
97
0
      !atomsCache->easing_id.init(cx, "easing") ||
98
0
      !atomsCache->duration_id.init(cx, "duration") ||
99
0
      !atomsCache->direction_id.init(cx, "direction") ||
100
0
      !atomsCache->delay_id.init(cx, "delay")) {
101
0
    return false;
102
0
  }
103
0
  return true;
104
0
}
105
106
bool
107
EffectTiming::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
108
0
{
109
0
  // Passing a null JSContext is OK only if we're initing from null,
110
0
  // Since in that case we will not have to do any property gets
111
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
112
0
  // checkers by static analysis tools
113
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
114
0
  EffectTimingAtoms* atomsCache = nullptr;
115
0
  if (cx) {
116
0
    atomsCache = GetAtomCache<EffectTimingAtoms>(cx);
117
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
118
0
      return false;
119
0
    }
120
0
  }
121
0
122
0
  if (!IsConvertibleToDictionary(val)) {
123
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
124
0
  }
125
0
126
0
  bool isNull = val.isNullOrUndefined();
127
0
  // We only need these if !isNull, in which case we have |cx|.
128
0
  Maybe<JS::Rooted<JSObject *> > object;
129
0
  Maybe<JS::Rooted<JS::Value> > temp;
130
0
  if (!isNull) {
131
0
    MOZ_ASSERT(cx);
132
0
    object.emplace(cx, &val.toObject());
133
0
    temp.emplace(cx);
134
0
  }
135
0
  if (!isNull) {
136
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->delay_id, temp.ptr())) {
137
0
      return false;
138
0
    }
139
0
  }
140
0
  if (!isNull && !temp->isUndefined()) {
141
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mDelay)) {
142
0
      return false;
143
0
    } else if (!mozilla::IsFinite(mDelay)) {
144
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'delay' member of EffectTiming");
145
0
      return false;
146
0
    }
147
0
  } else {
148
0
    mDelay = 0.0;
149
0
  }
150
0
  mIsAnyMemberPresent = true;
151
0
152
0
  if (!isNull) {
153
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->direction_id, temp.ptr())) {
154
0
      return false;
155
0
    }
156
0
  }
157
0
  if (!isNull && !temp->isUndefined()) {
158
0
    {
159
0
      int index;
160
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), PlaybackDirectionValues::strings, "PlaybackDirection", "'direction' member of EffectTiming", &index)) {
161
0
        return false;
162
0
      }
163
0
      MOZ_ASSERT(index >= 0);
164
0
      mDirection = static_cast<PlaybackDirection>(index);
165
0
    }
166
0
  } else {
167
0
    mDirection = PlaybackDirection::Normal;
168
0
  }
169
0
  mIsAnyMemberPresent = true;
170
0
171
0
  if (!isNull) {
172
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->duration_id, temp.ptr())) {
173
0
      return false;
174
0
    }
175
0
  }
176
0
  mDuration.Uninit();
177
0
  if (!(!isNull && !temp->isUndefined())) {
178
0
    static const char16_t data[] = { 'a', 'u', 't', 'o', 0 };
179
0
    mDuration.SetStringData(data, ArrayLength(data) - 1);
180
0
  } else {
181
0
    {
182
0
      bool done = false, failed = false, tryNext;
183
0
      do {
184
0
        if (temp.ref().isNumber()) {
185
0
          done = (failed = !mDuration.TrySetToUnrestrictedDouble(cx, temp.ref(), tryNext)) || !tryNext;
186
0
          break;
187
0
        }
188
0
        done = (failed = !mDuration.TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
189
0
        break;
190
0
      } while (false);
191
0
      if (failed) {
192
0
        return false;
193
0
      }
194
0
      if (!done) {
195
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'duration' member of EffectTiming", "");
196
0
        return false;
197
0
      }
198
0
    }
199
0
  }
200
0
  mIsAnyMemberPresent = true;
201
0
202
0
  if (!isNull) {
203
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->easing_id, temp.ptr())) {
204
0
      return false;
205
0
    }
206
0
  }
207
0
  if (!isNull && !temp->isUndefined()) {
208
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mEasing)) {
209
0
      return false;
210
0
    }
211
0
  } else {
212
0
    static const char16_t data[] = { 'l', 'i', 'n', 'e', 'a', 'r', 0 };
213
0
    mEasing.Rebind(data, ArrayLength(data) - 1);
214
0
  }
215
0
  mIsAnyMemberPresent = true;
216
0
217
0
  if (!isNull) {
218
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->endDelay_id, temp.ptr())) {
219
0
      return false;
220
0
    }
221
0
  }
222
0
  if (!isNull && !temp->isUndefined()) {
223
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mEndDelay)) {
224
0
      return false;
225
0
    } else if (!mozilla::IsFinite(mEndDelay)) {
226
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'endDelay' member of EffectTiming");
227
0
      return false;
228
0
    }
229
0
  } else {
230
0
    mEndDelay = 0.0;
231
0
  }
232
0
  mIsAnyMemberPresent = true;
233
0
234
0
  if (!isNull) {
235
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->fill_id, temp.ptr())) {
236
0
      return false;
237
0
    }
238
0
  }
239
0
  if (!isNull && !temp->isUndefined()) {
240
0
    {
241
0
      int index;
242
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), FillModeValues::strings, "FillMode", "'fill' member of EffectTiming", &index)) {
243
0
        return false;
244
0
      }
245
0
      MOZ_ASSERT(index >= 0);
246
0
      mFill = static_cast<FillMode>(index);
247
0
    }
248
0
  } else {
249
0
    mFill = FillMode::Auto;
250
0
  }
251
0
  mIsAnyMemberPresent = true;
252
0
253
0
  if (!isNull) {
254
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->iterationStart_id, temp.ptr())) {
255
0
      return false;
256
0
    }
257
0
  }
258
0
  if (!isNull && !temp->isUndefined()) {
259
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mIterationStart)) {
260
0
      return false;
261
0
    } else if (!mozilla::IsFinite(mIterationStart)) {
262
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'iterationStart' member of EffectTiming");
263
0
      return false;
264
0
    }
265
0
  } else {
266
0
    mIterationStart = 0.0;
267
0
  }
268
0
  mIsAnyMemberPresent = true;
269
0
270
0
  if (!isNull) {
271
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->iterations_id, temp.ptr())) {
272
0
      return false;
273
0
    }
274
0
  }
275
0
  if (!isNull && !temp->isUndefined()) {
276
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mIterations)) {
277
0
      return false;
278
0
    }
279
0
  } else {
280
0
    mIterations = 1.0;
281
0
  }
282
0
  mIsAnyMemberPresent = true;
283
0
  return true;
284
0
}
285
286
bool
287
EffectTiming::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
288
0
{
289
0
  EffectTimingAtoms* atomsCache = GetAtomCache<EffectTimingAtoms>(cx);
290
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
291
0
    return false;
292
0
  }
293
0
294
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
295
0
  if (!obj) {
296
0
    return false;
297
0
  }
298
0
  rval.set(JS::ObjectValue(*obj));
299
0
300
0
  do {
301
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
302
0
    JS::Rooted<JS::Value> temp(cx);
303
0
    double const & currentValue = mDelay;
304
0
    temp.set(JS_NumberValue(double(currentValue)));
305
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->delay_id, temp, JSPROP_ENUMERATE)) {
306
0
      return false;
307
0
    }
308
0
    break;
309
0
  } while(false);
310
0
311
0
  do {
312
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
313
0
    JS::Rooted<JS::Value> temp(cx);
314
0
    PlaybackDirection const & currentValue = mDirection;
315
0
    if (!ToJSValue(cx, currentValue, &temp)) {
316
0
      return false;
317
0
    }
318
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->direction_id, temp, JSPROP_ENUMERATE)) {
319
0
      return false;
320
0
    }
321
0
    break;
322
0
  } while(false);
323
0
324
0
  do {
325
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
326
0
    JS::Rooted<JS::Value> temp(cx);
327
0
    OwningUnrestrictedDoubleOrString const & currentValue = mDuration;
328
0
    if (!currentValue.ToJSVal(cx, obj, &temp)) {
329
0
      return false;
330
0
    }
331
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->duration_id, temp, JSPROP_ENUMERATE)) {
332
0
      return false;
333
0
    }
334
0
    break;
335
0
  } while(false);
336
0
337
0
  do {
338
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
339
0
    JS::Rooted<JS::Value> temp(cx);
340
0
    nsString const & currentValue = mEasing;
341
0
    if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
342
0
      return false;
343
0
    }
344
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->easing_id, temp, JSPROP_ENUMERATE)) {
345
0
      return false;
346
0
    }
347
0
    break;
348
0
  } while(false);
349
0
350
0
  do {
351
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
352
0
    JS::Rooted<JS::Value> temp(cx);
353
0
    double const & currentValue = mEndDelay;
354
0
    temp.set(JS_NumberValue(double(currentValue)));
355
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->endDelay_id, temp, JSPROP_ENUMERATE)) {
356
0
      return false;
357
0
    }
358
0
    break;
359
0
  } while(false);
360
0
361
0
  do {
362
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
363
0
    JS::Rooted<JS::Value> temp(cx);
364
0
    FillMode const & currentValue = mFill;
365
0
    if (!ToJSValue(cx, currentValue, &temp)) {
366
0
      return false;
367
0
    }
368
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->fill_id, temp, JSPROP_ENUMERATE)) {
369
0
      return false;
370
0
    }
371
0
    break;
372
0
  } while(false);
373
0
374
0
  do {
375
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
376
0
    JS::Rooted<JS::Value> temp(cx);
377
0
    double const & currentValue = mIterationStart;
378
0
    temp.set(JS_NumberValue(double(currentValue)));
379
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->iterationStart_id, temp, JSPROP_ENUMERATE)) {
380
0
      return false;
381
0
    }
382
0
    break;
383
0
  } while(false);
384
0
385
0
  do {
386
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
387
0
    JS::Rooted<JS::Value> temp(cx);
388
0
    double const & currentValue = mIterations;
389
0
    temp.set(JS_NumberValue(double(currentValue)));
390
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->iterations_id, temp, JSPROP_ENUMERATE)) {
391
0
      return false;
392
0
    }
393
0
    break;
394
0
  } while(false);
395
0
396
0
  return true;
397
0
}
398
399
void
400
EffectTiming::TraceDictionary(JSTracer* trc)
401
0
{
402
0
}
403
404
EffectTiming&
405
EffectTiming::operator=(const EffectTiming& aOther)
406
0
{
407
0
  DictionaryBase::operator=(aOther);
408
0
  mDelay = aOther.mDelay;
409
0
  mDirection = aOther.mDirection;
410
0
  mDuration = aOther.mDuration;
411
0
  mEasing = aOther.mEasing;
412
0
  mEndDelay = aOther.mEndDelay;
413
0
  mFill = aOther.mFill;
414
0
  mIterationStart = aOther.mIterationStart;
415
0
  mIterations = aOther.mIterations;
416
0
  return *this;
417
0
}
418
419
namespace binding_detail {
420
} // namespace binding_detail
421
422
423
424
OptionalEffectTiming::OptionalEffectTiming()
425
0
{
426
0
  // Safe to pass a null context if we pass a null value
427
0
  Init(nullptr, JS::NullHandleValue);
428
0
}
429
430
431
432
bool
433
OptionalEffectTiming::InitIds(JSContext* cx, OptionalEffectTimingAtoms* atomsCache)
434
0
{
435
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
436
0
437
0
  // Initialize these in reverse order so that any failure leaves the first one
438
0
  // uninitialized.
439
0
  if (!atomsCache->iterations_id.init(cx, "iterations") ||
440
0
      !atomsCache->iterationStart_id.init(cx, "iterationStart") ||
441
0
      !atomsCache->fill_id.init(cx, "fill") ||
442
0
      !atomsCache->endDelay_id.init(cx, "endDelay") ||
443
0
      !atomsCache->easing_id.init(cx, "easing") ||
444
0
      !atomsCache->duration_id.init(cx, "duration") ||
445
0
      !atomsCache->direction_id.init(cx, "direction") ||
446
0
      !atomsCache->delay_id.init(cx, "delay")) {
447
0
    return false;
448
0
  }
449
0
  return true;
450
0
}
451
452
bool
453
OptionalEffectTiming::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
454
0
{
455
0
  // Passing a null JSContext is OK only if we're initing from null,
456
0
  // Since in that case we will not have to do any property gets
457
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
458
0
  // checkers by static analysis tools
459
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
460
0
  OptionalEffectTimingAtoms* atomsCache = nullptr;
461
0
  if (cx) {
462
0
    atomsCache = GetAtomCache<OptionalEffectTimingAtoms>(cx);
463
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
464
0
      return false;
465
0
    }
466
0
  }
467
0
468
0
  if (!IsConvertibleToDictionary(val)) {
469
0
    return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
470
0
  }
471
0
472
0
  bool isNull = val.isNullOrUndefined();
473
0
  // We only need these if !isNull, in which case we have |cx|.
474
0
  Maybe<JS::Rooted<JSObject *> > object;
475
0
  Maybe<JS::Rooted<JS::Value> > temp;
476
0
  if (!isNull) {
477
0
    MOZ_ASSERT(cx);
478
0
    object.emplace(cx, &val.toObject());
479
0
    temp.emplace(cx);
480
0
  }
481
0
  if (!isNull) {
482
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->delay_id, temp.ptr())) {
483
0
      return false;
484
0
    }
485
0
  }
486
0
  if (!isNull && !temp->isUndefined()) {
487
0
    mDelay.Construct();
488
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &(mDelay.Value()))) {
489
0
      return false;
490
0
    } else if (!mozilla::IsFinite((mDelay.Value()))) {
491
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'delay' member of OptionalEffectTiming");
492
0
      return false;
493
0
    }
494
0
    mIsAnyMemberPresent = true;
495
0
  }
496
0
497
0
  if (!isNull) {
498
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->direction_id, temp.ptr())) {
499
0
      return false;
500
0
    }
501
0
  }
502
0
  if (!isNull && !temp->isUndefined()) {
503
0
    mDirection.Construct();
504
0
    {
505
0
      int index;
506
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), PlaybackDirectionValues::strings, "PlaybackDirection", "'direction' member of OptionalEffectTiming", &index)) {
507
0
        return false;
508
0
      }
509
0
      MOZ_ASSERT(index >= 0);
510
0
      (mDirection.Value()) = static_cast<PlaybackDirection>(index);
511
0
    }
512
0
    mIsAnyMemberPresent = true;
513
0
  }
514
0
515
0
  if (!isNull) {
516
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->duration_id, temp.ptr())) {
517
0
      return false;
518
0
    }
519
0
  }
520
0
  if (!isNull && !temp->isUndefined()) {
521
0
    mDuration.Construct();
522
0
    {
523
0
      bool done = false, failed = false, tryNext;
524
0
      do {
525
0
        if (temp.ref().isNumber()) {
526
0
          done = (failed = !(mDuration.Value()).TrySetToUnrestrictedDouble(cx, temp.ref(), tryNext)) || !tryNext;
527
0
          break;
528
0
        }
529
0
        done = (failed = !(mDuration.Value()).TrySetToString(cx, temp.ref(), tryNext)) || !tryNext;
530
0
        break;
531
0
      } while (false);
532
0
      if (failed) {
533
0
        return false;
534
0
      }
535
0
      if (!done) {
536
0
        ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'duration' member of OptionalEffectTiming", "");
537
0
        return false;
538
0
      }
539
0
    }
540
0
    mIsAnyMemberPresent = true;
541
0
  }
542
0
543
0
  if (!isNull) {
544
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->easing_id, temp.ptr())) {
545
0
      return false;
546
0
    }
547
0
  }
548
0
  if (!isNull && !temp->isUndefined()) {
549
0
    mEasing.Construct();
550
0
    if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mEasing.Value()))) {
551
0
      return false;
552
0
    }
553
0
    mIsAnyMemberPresent = true;
554
0
  }
555
0
556
0
  if (!isNull) {
557
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->endDelay_id, temp.ptr())) {
558
0
      return false;
559
0
    }
560
0
  }
561
0
  if (!isNull && !temp->isUndefined()) {
562
0
    mEndDelay.Construct();
563
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &(mEndDelay.Value()))) {
564
0
      return false;
565
0
    } else if (!mozilla::IsFinite((mEndDelay.Value()))) {
566
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'endDelay' member of OptionalEffectTiming");
567
0
      return false;
568
0
    }
569
0
    mIsAnyMemberPresent = true;
570
0
  }
571
0
572
0
  if (!isNull) {
573
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->fill_id, temp.ptr())) {
574
0
      return false;
575
0
    }
576
0
  }
577
0
  if (!isNull && !temp->isUndefined()) {
578
0
    mFill.Construct();
579
0
    {
580
0
      int index;
581
0
      if (!FindEnumStringIndex<true>(cx, temp.ref(), FillModeValues::strings, "FillMode", "'fill' member of OptionalEffectTiming", &index)) {
582
0
        return false;
583
0
      }
584
0
      MOZ_ASSERT(index >= 0);
585
0
      (mFill.Value()) = static_cast<FillMode>(index);
586
0
    }
587
0
    mIsAnyMemberPresent = true;
588
0
  }
589
0
590
0
  if (!isNull) {
591
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->iterationStart_id, temp.ptr())) {
592
0
      return false;
593
0
    }
594
0
  }
595
0
  if (!isNull && !temp->isUndefined()) {
596
0
    mIterationStart.Construct();
597
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &(mIterationStart.Value()))) {
598
0
      return false;
599
0
    } else if (!mozilla::IsFinite((mIterationStart.Value()))) {
600
0
      ThrowErrorMessage(cx, MSG_NOT_FINITE, "'iterationStart' member of OptionalEffectTiming");
601
0
      return false;
602
0
    }
603
0
    mIsAnyMemberPresent = true;
604
0
  }
605
0
606
0
  if (!isNull) {
607
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->iterations_id, temp.ptr())) {
608
0
      return false;
609
0
    }
610
0
  }
611
0
  if (!isNull && !temp->isUndefined()) {
612
0
    mIterations.Construct();
613
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &(mIterations.Value()))) {
614
0
      return false;
615
0
    }
616
0
    mIsAnyMemberPresent = true;
617
0
  }
618
0
  return true;
619
0
}
620
621
bool
622
OptionalEffectTiming::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
623
0
{
624
0
  OptionalEffectTimingAtoms* atomsCache = GetAtomCache<OptionalEffectTimingAtoms>(cx);
625
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
626
0
    return false;
627
0
  }
628
0
629
0
  JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
630
0
  if (!obj) {
631
0
    return false;
632
0
  }
633
0
  rval.set(JS::ObjectValue(*obj));
634
0
635
0
  if (mDelay.WasPassed()) {
636
0
    do {
637
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
638
0
      JS::Rooted<JS::Value> temp(cx);
639
0
      double const & currentValue = mDelay.InternalValue();
640
0
      temp.set(JS_NumberValue(double(currentValue)));
641
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->delay_id, temp, JSPROP_ENUMERATE)) {
642
0
        return false;
643
0
      }
644
0
      break;
645
0
    } while(false);
646
0
  }
647
0
648
0
  if (mDirection.WasPassed()) {
649
0
    do {
650
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
651
0
      JS::Rooted<JS::Value> temp(cx);
652
0
      PlaybackDirection const & currentValue = mDirection.InternalValue();
653
0
      if (!ToJSValue(cx, currentValue, &temp)) {
654
0
        return false;
655
0
      }
656
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->direction_id, temp, JSPROP_ENUMERATE)) {
657
0
        return false;
658
0
      }
659
0
      break;
660
0
    } while(false);
661
0
  }
662
0
663
0
  if (mDuration.WasPassed()) {
664
0
    do {
665
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
666
0
      JS::Rooted<JS::Value> temp(cx);
667
0
      OwningUnrestrictedDoubleOrString const & currentValue = mDuration.InternalValue();
668
0
      if (!currentValue.ToJSVal(cx, obj, &temp)) {
669
0
        return false;
670
0
      }
671
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->duration_id, temp, JSPROP_ENUMERATE)) {
672
0
        return false;
673
0
      }
674
0
      break;
675
0
    } while(false);
676
0
  }
677
0
678
0
  if (mEasing.WasPassed()) {
679
0
    do {
680
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
681
0
      JS::Rooted<JS::Value> temp(cx);
682
0
      nsString const & currentValue = mEasing.InternalValue();
683
0
      if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
684
0
        return false;
685
0
      }
686
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->easing_id, temp, JSPROP_ENUMERATE)) {
687
0
        return false;
688
0
      }
689
0
      break;
690
0
    } while(false);
691
0
  }
692
0
693
0
  if (mEndDelay.WasPassed()) {
694
0
    do {
695
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
696
0
      JS::Rooted<JS::Value> temp(cx);
697
0
      double const & currentValue = mEndDelay.InternalValue();
698
0
      temp.set(JS_NumberValue(double(currentValue)));
699
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->endDelay_id, temp, JSPROP_ENUMERATE)) {
700
0
        return false;
701
0
      }
702
0
      break;
703
0
    } while(false);
704
0
  }
705
0
706
0
  if (mFill.WasPassed()) {
707
0
    do {
708
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
709
0
      JS::Rooted<JS::Value> temp(cx);
710
0
      FillMode const & currentValue = mFill.InternalValue();
711
0
      if (!ToJSValue(cx, currentValue, &temp)) {
712
0
        return false;
713
0
      }
714
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->fill_id, temp, JSPROP_ENUMERATE)) {
715
0
        return false;
716
0
      }
717
0
      break;
718
0
    } while(false);
719
0
  }
720
0
721
0
  if (mIterationStart.WasPassed()) {
722
0
    do {
723
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
724
0
      JS::Rooted<JS::Value> temp(cx);
725
0
      double const & currentValue = mIterationStart.InternalValue();
726
0
      temp.set(JS_NumberValue(double(currentValue)));
727
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->iterationStart_id, temp, JSPROP_ENUMERATE)) {
728
0
        return false;
729
0
      }
730
0
      break;
731
0
    } while(false);
732
0
  }
733
0
734
0
  if (mIterations.WasPassed()) {
735
0
    do {
736
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
737
0
      JS::Rooted<JS::Value> temp(cx);
738
0
      double const & currentValue = mIterations.InternalValue();
739
0
      temp.set(JS_NumberValue(double(currentValue)));
740
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->iterations_id, temp, JSPROP_ENUMERATE)) {
741
0
        return false;
742
0
      }
743
0
      break;
744
0
    } while(false);
745
0
  }
746
0
747
0
  return true;
748
0
}
749
750
void
751
OptionalEffectTiming::TraceDictionary(JSTracer* trc)
752
0
{
753
0
}
754
755
OptionalEffectTiming&
756
OptionalEffectTiming::operator=(const OptionalEffectTiming& aOther)
757
0
{
758
0
  DictionaryBase::operator=(aOther);
759
0
  mDelay.Reset();
760
0
  if (aOther.mDelay.WasPassed()) {
761
0
    mDelay.Construct(aOther.mDelay.Value());
762
0
  }
763
0
  mDirection.Reset();
764
0
  if (aOther.mDirection.WasPassed()) {
765
0
    mDirection.Construct(aOther.mDirection.Value());
766
0
  }
767
0
  mDuration.Reset();
768
0
  if (aOther.mDuration.WasPassed()) {
769
0
    mDuration.Construct(aOther.mDuration.Value());
770
0
  }
771
0
  mEasing.Reset();
772
0
  if (aOther.mEasing.WasPassed()) {
773
0
    mEasing.Construct(aOther.mEasing.Value());
774
0
  }
775
0
  mEndDelay.Reset();
776
0
  if (aOther.mEndDelay.WasPassed()) {
777
0
    mEndDelay.Construct(aOther.mEndDelay.Value());
778
0
  }
779
0
  mFill.Reset();
780
0
  if (aOther.mFill.WasPassed()) {
781
0
    mFill.Construct(aOther.mFill.Value());
782
0
  }
783
0
  mIterationStart.Reset();
784
0
  if (aOther.mIterationStart.WasPassed()) {
785
0
    mIterationStart.Construct(aOther.mIterationStart.Value());
786
0
  }
787
0
  mIterations.Reset();
788
0
  if (aOther.mIterations.WasPassed()) {
789
0
    mIterations.Construct(aOther.mIterations.Value());
790
0
  }
791
0
  return *this;
792
0
}
793
794
namespace binding_detail {
795
} // namespace binding_detail
796
797
798
799
ComputedEffectTiming::ComputedEffectTiming()
800
  : EffectTiming(FastDictionaryInitializer())
801
0
{
802
0
  // Safe to pass a null context if we pass a null value
803
0
  Init(nullptr, JS::NullHandleValue);
804
0
}
805
806
807
808
bool
809
ComputedEffectTiming::InitIds(JSContext* cx, ComputedEffectTimingAtoms* atomsCache)
810
0
{
811
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
812
0
813
0
  // Initialize these in reverse order so that any failure leaves the first one
814
0
  // uninitialized.
815
0
  if (!atomsCache->progress_id.init(cx, "progress") ||
816
0
      !atomsCache->localTime_id.init(cx, "localTime") ||
817
0
      !atomsCache->endTime_id.init(cx, "endTime") ||
818
0
      !atomsCache->currentIteration_id.init(cx, "currentIteration") ||
819
0
      !atomsCache->activeDuration_id.init(cx, "activeDuration")) {
820
0
    return false;
821
0
  }
822
0
  return true;
823
0
}
824
825
bool
826
ComputedEffectTiming::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
827
0
{
828
0
  // Passing a null JSContext is OK only if we're initing from null,
829
0
  // Since in that case we will not have to do any property gets
830
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
831
0
  // checkers by static analysis tools
832
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
833
0
  ComputedEffectTimingAtoms* atomsCache = nullptr;
834
0
  if (cx) {
835
0
    atomsCache = GetAtomCache<ComputedEffectTimingAtoms>(cx);
836
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
837
0
      return false;
838
0
    }
839
0
  }
840
0
841
0
  // Per spec, we init the parent's members first
842
0
  if (!EffectTiming::Init(cx, val)) {
843
0
    return false;
844
0
  }
845
0
846
0
  bool isNull = val.isNullOrUndefined();
847
0
  // We only need these if !isNull, in which case we have |cx|.
848
0
  Maybe<JS::Rooted<JSObject *> > object;
849
0
  Maybe<JS::Rooted<JS::Value> > temp;
850
0
  if (!isNull) {
851
0
    MOZ_ASSERT(cx);
852
0
    object.emplace(cx, &val.toObject());
853
0
    temp.emplace(cx);
854
0
  }
855
0
  if (!isNull) {
856
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->activeDuration_id, temp.ptr())) {
857
0
      return false;
858
0
    }
859
0
  }
860
0
  if (!isNull && !temp->isUndefined()) {
861
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mActiveDuration)) {
862
0
      return false;
863
0
    }
864
0
  } else {
865
0
    mActiveDuration = 0.0;
866
0
  }
867
0
  mIsAnyMemberPresent = true;
868
0
869
0
  if (!isNull) {
870
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->currentIteration_id, temp.ptr())) {
871
0
      return false;
872
0
    }
873
0
  }
874
0
  if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
875
0
    mCurrentIteration.SetNull();
876
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mCurrentIteration.SetValue())) {
877
0
    return false;
878
0
  }
879
0
  mIsAnyMemberPresent = true;
880
0
881
0
  if (!isNull) {
882
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->endTime_id, temp.ptr())) {
883
0
      return false;
884
0
    }
885
0
  }
886
0
  if (!isNull && !temp->isUndefined()) {
887
0
    if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mEndTime)) {
888
0
      return false;
889
0
    }
890
0
  } else {
891
0
    mEndTime = 0.0;
892
0
  }
893
0
  mIsAnyMemberPresent = true;
894
0
895
0
  if (!isNull) {
896
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->localTime_id, temp.ptr())) {
897
0
      return false;
898
0
    }
899
0
  }
900
0
  if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
901
0
    mLocalTime.SetNull();
902
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mLocalTime.SetValue())) {
903
0
    return false;
904
0
  } else if (!mozilla::IsFinite(mLocalTime.Value())) {
905
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "'localTime' member of ComputedEffectTiming");
906
0
    return false;
907
0
  }
908
0
  mIsAnyMemberPresent = true;
909
0
910
0
  if (!isNull) {
911
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->progress_id, temp.ptr())) {
912
0
      return false;
913
0
    }
914
0
  }
915
0
  if (!(!isNull && !temp->isUndefined()) || temp.ref().isNullOrUndefined()) {
916
0
    mProgress.SetNull();
917
0
  } else if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mProgress.SetValue())) {
918
0
    return false;
919
0
  } else if (!mozilla::IsFinite(mProgress.Value())) {
920
0
    ThrowErrorMessage(cx, MSG_NOT_FINITE, "'progress' member of ComputedEffectTiming");
921
0
    return false;
922
0
  }
923
0
  mIsAnyMemberPresent = true;
924
0
  return true;
925
0
}
926
927
bool
928
ComputedEffectTiming::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
929
0
{
930
0
  ComputedEffectTimingAtoms* atomsCache = GetAtomCache<ComputedEffectTimingAtoms>(cx);
931
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
932
0
    return false;
933
0
  }
934
0
935
0
  // Per spec, we define the parent's members first
936
0
  if (!EffectTiming::ToObjectInternal(cx, rval)) {
937
0
    return false;
938
0
  }
939
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
940
0
941
0
  do {
942
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
943
0
    JS::Rooted<JS::Value> temp(cx);
944
0
    double const & currentValue = mActiveDuration;
945
0
    temp.set(JS_NumberValue(double(currentValue)));
946
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->activeDuration_id, temp, JSPROP_ENUMERATE)) {
947
0
      return false;
948
0
    }
949
0
    break;
950
0
  } while(false);
951
0
952
0
  do {
953
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
954
0
    JS::Rooted<JS::Value> temp(cx);
955
0
    Nullable<double> const & currentValue = mCurrentIteration;
956
0
    if (currentValue.IsNull()) {
957
0
      temp.setNull();
958
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->currentIteration_id, temp, JSPROP_ENUMERATE)) {
959
0
        return false;
960
0
      }
961
0
      break;
962
0
    }
963
0
    temp.set(JS_NumberValue(double(currentValue.Value())));
964
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->currentIteration_id, temp, JSPROP_ENUMERATE)) {
965
0
      return false;
966
0
    }
967
0
    break;
968
0
  } while(false);
969
0
970
0
  do {
971
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
972
0
    JS::Rooted<JS::Value> temp(cx);
973
0
    double const & currentValue = mEndTime;
974
0
    temp.set(JS_NumberValue(double(currentValue)));
975
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->endTime_id, temp, JSPROP_ENUMERATE)) {
976
0
      return false;
977
0
    }
978
0
    break;
979
0
  } while(false);
980
0
981
0
  do {
982
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
983
0
    JS::Rooted<JS::Value> temp(cx);
984
0
    Nullable<double> const & currentValue = mLocalTime;
985
0
    if (currentValue.IsNull()) {
986
0
      temp.setNull();
987
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->localTime_id, temp, JSPROP_ENUMERATE)) {
988
0
        return false;
989
0
      }
990
0
      break;
991
0
    }
992
0
    temp.set(JS_NumberValue(double(currentValue.Value())));
993
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->localTime_id, temp, JSPROP_ENUMERATE)) {
994
0
      return false;
995
0
    }
996
0
    break;
997
0
  } while(false);
998
0
999
0
  do {
1000
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
1001
0
    JS::Rooted<JS::Value> temp(cx);
1002
0
    Nullable<double> const & currentValue = mProgress;
1003
0
    if (currentValue.IsNull()) {
1004
0
      temp.setNull();
1005
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->progress_id, temp, JSPROP_ENUMERATE)) {
1006
0
        return false;
1007
0
      }
1008
0
      break;
1009
0
    }
1010
0
    temp.set(JS_NumberValue(double(currentValue.Value())));
1011
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->progress_id, temp, JSPROP_ENUMERATE)) {
1012
0
      return false;
1013
0
    }
1014
0
    break;
1015
0
  } while(false);
1016
0
1017
0
  return true;
1018
0
}
1019
1020
void
1021
ComputedEffectTiming::TraceDictionary(JSTracer* trc)
1022
0
{
1023
0
  EffectTiming::TraceDictionary(trc);
1024
0
}
1025
1026
ComputedEffectTiming&
1027
ComputedEffectTiming::operator=(const ComputedEffectTiming& aOther)
1028
0
{
1029
0
  EffectTiming::operator=(aOther);
1030
0
  mActiveDuration = aOther.mActiveDuration;
1031
0
  mCurrentIteration = aOther.mCurrentIteration;
1032
0
  mEndTime = aOther.mEndTime;
1033
0
  mLocalTime = aOther.mLocalTime;
1034
0
  mProgress = aOther.mProgress;
1035
0
  return *this;
1036
0
}
1037
1038
namespace binding_detail {
1039
} // namespace binding_detail
1040
1041
1042
namespace AnimationEffect_Binding {
1043
1044
MOZ_CAN_RUN_SCRIPT static bool
1045
getTiming(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffect* self, const JSJitMethodCallArgs& args)
1046
0
{
1047
0
  AUTO_PROFILER_LABEL_FAST("AnimationEffect.getTiming", DOM, cx);
1048
0
1049
0
  EffectTiming result;
1050
0
  self->GetTiming(result);
1051
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1052
0
  if (!result.ToObjectInternal(cx, args.rval())) {
1053
0
    return false;
1054
0
  }
1055
0
  return true;
1056
0
}
1057
1058
static const JSJitInfo getTiming_methodinfo = {
1059
  { (JSJitGetterOp)getTiming },
1060
  { prototypes::id::AnimationEffect },
1061
  { PrototypeTraits<prototypes::id::AnimationEffect>::Depth },
1062
  JSJitInfo::Method,
1063
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1064
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1065
  false,  /* isInfallible. False in setters. */
1066
  false,  /* isMovable.  Not relevant for setters. */
1067
  false, /* isEliminatable.  Not relevant for setters. */
1068
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1069
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1070
  false,  /* isTypedMethod.  Only relevant for methods. */
1071
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1072
};
1073
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1074
static_assert(0 < 1, "There is no slot for us");
1075
1076
MOZ_CAN_RUN_SCRIPT static bool
1077
getComputedTiming(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffect* self, const JSJitMethodCallArgs& args)
1078
0
{
1079
0
  AUTO_PROFILER_LABEL_FAST("AnimationEffect.getComputedTiming", DOM, cx);
1080
0
1081
0
  ComputedEffectTiming result;
1082
0
  self->GetComputedTimingAsDict(result);
1083
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1084
0
  if (!result.ToObjectInternal(cx, args.rval())) {
1085
0
    return false;
1086
0
  }
1087
0
  return true;
1088
0
}
1089
1090
static const JSJitInfo getComputedTiming_methodinfo = {
1091
  { (JSJitGetterOp)getComputedTiming },
1092
  { prototypes::id::AnimationEffect },
1093
  { PrototypeTraits<prototypes::id::AnimationEffect>::Depth },
1094
  JSJitInfo::Method,
1095
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1096
  JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
1097
  false,  /* isInfallible. False in setters. */
1098
  false,  /* isMovable.  Not relevant for setters. */
1099
  false, /* isEliminatable.  Not relevant for setters. */
1100
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1101
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1102
  false,  /* isTypedMethod.  Only relevant for methods. */
1103
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1104
};
1105
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1106
static_assert(0 < 1, "There is no slot for us");
1107
1108
MOZ_CAN_RUN_SCRIPT static bool
1109
updateTiming(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffect* self, const JSJitMethodCallArgs& args)
1110
0
{
1111
0
  AUTO_PROFILER_LABEL_FAST("AnimationEffect.updateTiming", DOM, cx);
1112
0
1113
0
  binding_detail::FastOptionalEffectTiming arg0;
1114
0
  if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of AnimationEffect.updateTiming", false)) {
1115
0
    return false;
1116
0
  }
1117
0
  FastErrorResult rv;
1118
0
  self->UpdateTiming(Constify(arg0), rv);
1119
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1120
0
    return false;
1121
0
  }
1122
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
1123
0
  args.rval().setUndefined();
1124
0
  return true;
1125
0
}
1126
1127
static const JSJitInfo updateTiming_methodinfo = {
1128
  { (JSJitGetterOp)updateTiming },
1129
  { prototypes::id::AnimationEffect },
1130
  { PrototypeTraits<prototypes::id::AnimationEffect>::Depth },
1131
  JSJitInfo::Method,
1132
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
1133
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
1134
  false,  /* isInfallible. False in setters. */
1135
  false,  /* isMovable.  Not relevant for setters. */
1136
  false, /* isEliminatable.  Not relevant for setters. */
1137
  false, /* isAlwaysInSlot.  Only relevant for getters. */
1138
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
1139
  false,  /* isTypedMethod.  Only relevant for methods. */
1140
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
1141
};
1142
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1143
static_assert(0 < 1, "There is no slot for us");
1144
1145
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
1146
#if defined(__clang__)
1147
#pragma clang diagnostic push
1148
#pragma clang diagnostic ignored "-Wmissing-braces"
1149
#endif
1150
static const JSFunctionSpec sMethods_specs[] = {
1151
  JS_FNSPEC("getTiming", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTiming_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1152
  JS_FNSPEC("getComputedTiming", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getComputedTiming_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1153
  JS_FNSPEC("updateTiming", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&updateTiming_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1154
  JS_FS_END
1155
};
1156
#if defined(__clang__)
1157
#pragma clang diagnostic pop
1158
#endif
1159
1160
1161
static const Prefable<const JSFunctionSpec> sMethods[] = {
1162
  { nullptr, &sMethods_specs[0] },
1163
  { nullptr, nullptr }
1164
};
1165
1166
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1167
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1168
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1169
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1170
1171
1172
static uint16_t sNativeProperties_sortedPropertyIndices[3];
1173
static PropertyInfo sNativeProperties_propertyInfos[3];
1174
1175
static const NativePropertiesN<1> sNativeProperties = {
1176
  false, 0,
1177
  false, 0,
1178
  true,  0 /* sMethods */,
1179
  false, 0,
1180
  false, 0,
1181
  false, 0,
1182
  false, 0,
1183
  -1,
1184
  3,
1185
  sNativeProperties_sortedPropertyIndices,
1186
  {
1187
    { sMethods, &sNativeProperties_propertyInfos[0] }
1188
  }
1189
};
1190
static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1191
    "We have a property info count that is oversized");
1192
1193
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1194
  {
1195
    "Function",
1196
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1197
    &sBoringInterfaceObjectClassClassOps,
1198
    JS_NULL_CLASS_SPEC,
1199
    JS_NULL_CLASS_EXT,
1200
    &sInterfaceObjectClassObjectOps
1201
  },
1202
  eInterface,
1203
  true,
1204
  prototypes::id::AnimationEffect,
1205
  PrototypeTraits<prototypes::id::AnimationEffect>::Depth,
1206
  sNativePropertyHooks,
1207
  "function AnimationEffect() {\n    [native code]\n}",
1208
  JS::GetRealmFunctionPrototype
1209
};
1210
1211
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1212
  {
1213
    "AnimationEffectPrototype",
1214
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1215
    JS_NULL_CLASS_OPS,
1216
    JS_NULL_CLASS_SPEC,
1217
    JS_NULL_CLASS_EXT,
1218
    JS_NULL_OBJECT_OPS
1219
  },
1220
  eInterfacePrototype,
1221
  false,
1222
  prototypes::id::AnimationEffect,
1223
  PrototypeTraits<prototypes::id::AnimationEffect>::Depth,
1224
  sNativePropertyHooks,
1225
  "[object AnimationEffectPrototype]",
1226
  JS::GetRealmObjectPrototype
1227
};
1228
1229
bool
1230
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1231
0
{
1232
0
  return nsDocument::IsWebAnimationsEnabled(aCx, aObj);
1233
0
}
1234
1235
const NativePropertyHooks sNativePropertyHooks[] = { {
1236
  nullptr,
1237
  nullptr,
1238
  nullptr,
1239
  { sNativeProperties.Upcast(), nullptr },
1240
  prototypes::id::AnimationEffect,
1241
  constructors::id::AnimationEffect,
1242
  nullptr,
1243
  &DefaultXrayExpandoObjectClass
1244
} };
1245
1246
void
1247
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1248
0
{
1249
0
  JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1250
0
  if (!parentProto) {
1251
0
    return;
1252
0
  }
1253
0
1254
0
  JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1255
0
  if (!constructorProto) {
1256
0
    return;
1257
0
  }
1258
0
1259
0
  static bool sIdsInited = false;
1260
0
  if (!sIdsInited && NS_IsMainThread()) {
1261
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
1262
0
      return;
1263
0
    }
1264
0
    sIdsInited = true;
1265
0
  }
1266
0
1267
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnimationEffect);
1268
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnimationEffect);
1269
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1270
0
                              &sPrototypeClass.mBase, protoCache,
1271
0
                              nullptr,
1272
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1273
0
                              interfaceCache,
1274
0
                              sNativeProperties.Upcast(),
1275
0
                              nullptr,
1276
0
                              "AnimationEffect", aDefineOnGlobal,
1277
0
                              nullptr,
1278
0
                              false);
1279
0
}
1280
1281
JSObject*
1282
GetProtoObject(JSContext* aCx)
1283
0
{
1284
0
  return GetProtoObjectHandle(aCx);
1285
0
}
1286
1287
JSObject*
1288
GetConstructorObject(JSContext* aCx)
1289
0
{
1290
0
  return GetConstructorObjectHandle(aCx);
1291
0
}
1292
1293
} // namespace AnimationEffect_Binding
1294
1295
1296
1297
} // namespace dom
1298
} // namespace mozilla