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