Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM AnimationEffectTiming.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AnimationEffectTimingBinding.h"
4 : #include "AnimationEffectTimingReadOnlyBinding.h"
5 : #include "WrapperFactory.h"
6 : #include "mozilla/FloatingPoint.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/dom/AnimationEffectTiming.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/NonRefcountedDOMObject.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/UnionConversions.h"
14 : #include "mozilla/dom/UnionTypes.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 : #include "nsDocument.h"
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : namespace AnimationEffectTimingBinding {
22 :
23 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AnimationEffectTimingReadOnlyBinding::NativeType>::value,
24 : "Can't inherit from an interface with a different ownership model.");
25 :
26 : static bool
27 0 : get_delay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
28 : {
29 0 : double result(self->Delay());
30 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
31 0 : args.rval().set(JS_NumberValue(double(result)));
32 0 : return true;
33 : }
34 :
35 : static bool
36 0 : set_delay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
37 : {
38 : double arg0;
39 0 : if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
40 0 : return false;
41 0 : } else if (!mozilla::IsFinite(arg0)) {
42 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to AnimationEffectTiming.delay");
43 0 : return false;
44 : }
45 0 : self->SetDelay(arg0);
46 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
47 :
48 0 : return true;
49 : }
50 :
51 : static const JSJitInfo delay_getterinfo = {
52 : { (JSJitGetterOp)get_delay },
53 : { prototypes::id::AnimationEffectTiming },
54 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
55 : JSJitInfo::Getter,
56 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
57 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
58 : true, /* isInfallible. False in setters. */
59 : false, /* isMovable. Not relevant for setters. */
60 : false, /* isEliminatable. Not relevant for setters. */
61 : false, /* isAlwaysInSlot. Only relevant for getters. */
62 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
63 : false, /* isTypedMethod. Only relevant for methods. */
64 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
65 : };
66 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
67 : static_assert(0 < 1, "There is no slot for us");
68 : static const JSJitInfo delay_setterinfo = {
69 : { (JSJitGetterOp)set_delay },
70 : { prototypes::id::AnimationEffectTiming },
71 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
72 : JSJitInfo::Setter,
73 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
74 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
75 : false, /* isInfallible. False in setters. */
76 : false, /* isMovable. Not relevant for setters. */
77 : false, /* isEliminatable. Not relevant for setters. */
78 : false, /* isAlwaysInSlot. Only relevant for getters. */
79 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
80 : false, /* isTypedMethod. Only relevant for methods. */
81 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
82 : };
83 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
84 : static_assert(0 < 1, "There is no slot for us");
85 :
86 : static bool
87 0 : get_endDelay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
88 : {
89 0 : double result(self->EndDelay());
90 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
91 0 : args.rval().set(JS_NumberValue(double(result)));
92 0 : return true;
93 : }
94 :
95 : static bool
96 0 : set_endDelay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
97 : {
98 : double arg0;
99 0 : if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
100 0 : return false;
101 0 : } else if (!mozilla::IsFinite(arg0)) {
102 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to AnimationEffectTiming.endDelay");
103 0 : return false;
104 : }
105 0 : self->SetEndDelay(arg0);
106 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
107 :
108 0 : return true;
109 : }
110 :
111 : static const JSJitInfo endDelay_getterinfo = {
112 : { (JSJitGetterOp)get_endDelay },
113 : { prototypes::id::AnimationEffectTiming },
114 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
115 : JSJitInfo::Getter,
116 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
117 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
118 : true, /* isInfallible. False in setters. */
119 : false, /* isMovable. Not relevant for setters. */
120 : false, /* isEliminatable. Not relevant for setters. */
121 : false, /* isAlwaysInSlot. Only relevant for getters. */
122 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
123 : false, /* isTypedMethod. Only relevant for methods. */
124 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
125 : };
126 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
127 : static_assert(0 < 1, "There is no slot for us");
128 : static const JSJitInfo endDelay_setterinfo = {
129 : { (JSJitGetterOp)set_endDelay },
130 : { prototypes::id::AnimationEffectTiming },
131 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
132 : JSJitInfo::Setter,
133 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
134 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
135 : false, /* isInfallible. False in setters. */
136 : false, /* isMovable. Not relevant for setters. */
137 : false, /* isEliminatable. Not relevant for setters. */
138 : false, /* isAlwaysInSlot. Only relevant for getters. */
139 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
140 : false, /* isTypedMethod. Only relevant for methods. */
141 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
142 : };
143 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
144 : static_assert(0 < 1, "There is no slot for us");
145 :
146 : static bool
147 0 : get_fill(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
148 : {
149 0 : FillMode result(self->Fill());
150 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
151 0 : if (!ToJSValue(cx, result, args.rval())) {
152 0 : return false;
153 : }
154 0 : return true;
155 : }
156 :
157 : static bool
158 0 : set_fill(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
159 : {
160 : FillMode arg0;
161 : {
162 : int index;
163 0 : if (!FindEnumStringIndex<false>(cx, args[0], FillModeValues::strings, "FillMode", "Value being assigned to AnimationEffectTiming.fill", &index)) {
164 0 : return false;
165 : }
166 0 : if (index < 0) {
167 0 : return true;
168 : }
169 0 : arg0 = static_cast<FillMode>(index);
170 : }
171 0 : self->SetFill(arg0);
172 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
173 :
174 0 : return true;
175 : }
176 :
177 : static const JSJitInfo fill_getterinfo = {
178 : { (JSJitGetterOp)get_fill },
179 : { prototypes::id::AnimationEffectTiming },
180 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
181 : JSJitInfo::Getter,
182 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
183 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
184 : false, /* isInfallible. False in setters. */
185 : false, /* isMovable. Not relevant for setters. */
186 : false, /* isEliminatable. Not relevant for setters. */
187 : false, /* isAlwaysInSlot. Only relevant for getters. */
188 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
189 : false, /* isTypedMethod. Only relevant for methods. */
190 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
191 : };
192 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
193 : static_assert(0 < 1, "There is no slot for us");
194 : static const JSJitInfo fill_setterinfo = {
195 : { (JSJitGetterOp)set_fill },
196 : { prototypes::id::AnimationEffectTiming },
197 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
198 : JSJitInfo::Setter,
199 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
200 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
201 : false, /* isInfallible. False in setters. */
202 : false, /* isMovable. Not relevant for setters. */
203 : false, /* isEliminatable. Not relevant for setters. */
204 : false, /* isAlwaysInSlot. Only relevant for getters. */
205 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
206 : false, /* isTypedMethod. Only relevant for methods. */
207 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
208 : };
209 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
210 : static_assert(0 < 1, "There is no slot for us");
211 :
212 : static bool
213 0 : get_iterationStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
214 : {
215 0 : double result(self->IterationStart());
216 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
217 0 : args.rval().set(JS_NumberValue(double(result)));
218 0 : return true;
219 : }
220 :
221 : static bool
222 0 : set_iterationStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
223 : {
224 : double arg0;
225 0 : if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
226 0 : return false;
227 0 : } else if (!mozilla::IsFinite(arg0)) {
228 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to AnimationEffectTiming.iterationStart");
229 0 : return false;
230 : }
231 0 : binding_detail::FastErrorResult rv;
232 0 : self->SetIterationStart(arg0, rv);
233 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
234 0 : return false;
235 : }
236 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
237 :
238 0 : return true;
239 : }
240 :
241 : static const JSJitInfo iterationStart_getterinfo = {
242 : { (JSJitGetterOp)get_iterationStart },
243 : { prototypes::id::AnimationEffectTiming },
244 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
245 : JSJitInfo::Getter,
246 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
247 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
248 : true, /* isInfallible. False in setters. */
249 : false, /* isMovable. Not relevant for setters. */
250 : false, /* isEliminatable. Not relevant for setters. */
251 : false, /* isAlwaysInSlot. Only relevant for getters. */
252 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
253 : false, /* isTypedMethod. Only relevant for methods. */
254 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
255 : };
256 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
257 : static_assert(0 < 1, "There is no slot for us");
258 : static const JSJitInfo iterationStart_setterinfo = {
259 : { (JSJitGetterOp)set_iterationStart },
260 : { prototypes::id::AnimationEffectTiming },
261 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
262 : JSJitInfo::Setter,
263 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
264 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
265 : false, /* isInfallible. False in setters. */
266 : false, /* isMovable. Not relevant for setters. */
267 : false, /* isEliminatable. Not relevant for setters. */
268 : false, /* isAlwaysInSlot. Only relevant for getters. */
269 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
270 : false, /* isTypedMethod. Only relevant for methods. */
271 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
272 : };
273 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
274 : static_assert(0 < 1, "There is no slot for us");
275 :
276 : static bool
277 0 : get_iterations(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
278 : {
279 0 : double result(self->Iterations());
280 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
281 0 : args.rval().set(JS_NumberValue(double(result)));
282 0 : return true;
283 : }
284 :
285 : static bool
286 0 : set_iterations(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
287 : {
288 : double arg0;
289 0 : if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
290 0 : return false;
291 : }
292 0 : binding_detail::FastErrorResult rv;
293 0 : self->SetIterations(arg0, rv);
294 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
295 0 : return false;
296 : }
297 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
298 :
299 0 : return true;
300 : }
301 :
302 : static const JSJitInfo iterations_getterinfo = {
303 : { (JSJitGetterOp)get_iterations },
304 : { prototypes::id::AnimationEffectTiming },
305 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
306 : JSJitInfo::Getter,
307 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
308 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
309 : true, /* isInfallible. False in setters. */
310 : false, /* isMovable. Not relevant for setters. */
311 : false, /* isEliminatable. Not relevant for setters. */
312 : false, /* isAlwaysInSlot. Only relevant for getters. */
313 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
314 : false, /* isTypedMethod. Only relevant for methods. */
315 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
316 : };
317 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
318 : static_assert(0 < 1, "There is no slot for us");
319 : static const JSJitInfo iterations_setterinfo = {
320 : { (JSJitGetterOp)set_iterations },
321 : { prototypes::id::AnimationEffectTiming },
322 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
323 : JSJitInfo::Setter,
324 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
325 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
326 : false, /* isInfallible. False in setters. */
327 : false, /* isMovable. Not relevant for setters. */
328 : false, /* isEliminatable. Not relevant for setters. */
329 : false, /* isAlwaysInSlot. Only relevant for getters. */
330 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
331 : false, /* isTypedMethod. Only relevant for methods. */
332 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
333 : };
334 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
335 : static_assert(0 < 1, "There is no slot for us");
336 :
337 : static bool
338 0 : get_duration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
339 : {
340 0 : OwningUnrestrictedDoubleOrString result;
341 0 : self->GetDuration(result);
342 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
343 0 : if (!result.ToJSVal(cx, obj, args.rval())) {
344 0 : return false;
345 : }
346 0 : return true;
347 : }
348 :
349 : static bool
350 0 : set_duration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
351 : {
352 0 : UnrestrictedDoubleOrString arg0;
353 0 : UnrestrictedDoubleOrStringArgument arg0_holder(arg0);
354 : {
355 0 : bool done = false, failed = false, tryNext;
356 : do {
357 0 : if (args[0].isNumber()) {
358 0 : done = (failed = !arg0_holder.TrySetToUnrestrictedDouble(cx, args[0], tryNext)) || !tryNext;
359 0 : break;
360 : }
361 0 : done = (failed = !arg0_holder.TrySetToString(cx, args[0], tryNext)) || !tryNext;
362 0 : break;
363 : } while (0);
364 0 : if (failed) {
365 0 : return false;
366 : }
367 0 : if (!done) {
368 0 : ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to AnimationEffectTiming.duration", "");
369 0 : return false;
370 : }
371 : }
372 0 : binding_detail::FastErrorResult rv;
373 0 : self->SetDuration(Constify(arg0), rv);
374 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
375 0 : return false;
376 : }
377 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
378 :
379 0 : return true;
380 : }
381 :
382 : static const JSJitInfo duration_getterinfo = {
383 : { (JSJitGetterOp)get_duration },
384 : { prototypes::id::AnimationEffectTiming },
385 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
386 : JSJitInfo::Getter,
387 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
388 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
389 : false, /* isInfallible. False in setters. */
390 : false, /* isMovable. Not relevant for setters. */
391 : false, /* isEliminatable. Not relevant for setters. */
392 : false, /* isAlwaysInSlot. Only relevant for getters. */
393 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
394 : false, /* isTypedMethod. Only relevant for methods. */
395 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
396 : };
397 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
398 : static_assert(0 < 1, "There is no slot for us");
399 : static const JSJitInfo duration_setterinfo = {
400 : { (JSJitGetterOp)set_duration },
401 : { prototypes::id::AnimationEffectTiming },
402 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
403 : JSJitInfo::Setter,
404 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
405 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
406 : false, /* isInfallible. False in setters. */
407 : false, /* isMovable. Not relevant for setters. */
408 : false, /* isEliminatable. Not relevant for setters. */
409 : false, /* isAlwaysInSlot. Only relevant for getters. */
410 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
411 : false, /* isTypedMethod. Only relevant for methods. */
412 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
413 : };
414 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
415 : static_assert(0 < 1, "There is no slot for us");
416 :
417 : static bool
418 0 : get_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
419 : {
420 0 : PlaybackDirection result(self->Direction());
421 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
422 0 : if (!ToJSValue(cx, result, args.rval())) {
423 0 : return false;
424 : }
425 0 : return true;
426 : }
427 :
428 : static bool
429 0 : set_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
430 : {
431 : PlaybackDirection arg0;
432 : {
433 : int index;
434 0 : if (!FindEnumStringIndex<false>(cx, args[0], PlaybackDirectionValues::strings, "PlaybackDirection", "Value being assigned to AnimationEffectTiming.direction", &index)) {
435 0 : return false;
436 : }
437 0 : if (index < 0) {
438 0 : return true;
439 : }
440 0 : arg0 = static_cast<PlaybackDirection>(index);
441 : }
442 0 : self->SetDirection(arg0);
443 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
444 :
445 0 : return true;
446 : }
447 :
448 : static const JSJitInfo direction_getterinfo = {
449 : { (JSJitGetterOp)get_direction },
450 : { prototypes::id::AnimationEffectTiming },
451 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
452 : JSJitInfo::Getter,
453 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
454 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
455 : false, /* isInfallible. False in setters. */
456 : false, /* isMovable. Not relevant for setters. */
457 : false, /* isEliminatable. Not relevant for setters. */
458 : false, /* isAlwaysInSlot. Only relevant for getters. */
459 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
460 : false, /* isTypedMethod. Only relevant for methods. */
461 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
462 : };
463 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
464 : static_assert(0 < 1, "There is no slot for us");
465 : static const JSJitInfo direction_setterinfo = {
466 : { (JSJitGetterOp)set_direction },
467 : { prototypes::id::AnimationEffectTiming },
468 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
469 : JSJitInfo::Setter,
470 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
471 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
472 : false, /* isInfallible. False in setters. */
473 : false, /* isMovable. Not relevant for setters. */
474 : false, /* isEliminatable. Not relevant for setters. */
475 : false, /* isAlwaysInSlot. Only relevant for getters. */
476 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
477 : false, /* isTypedMethod. Only relevant for methods. */
478 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
479 : };
480 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
481 : static_assert(0 < 1, "There is no slot for us");
482 :
483 : static bool
484 0 : get_easing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitGetterCallArgs args)
485 : {
486 0 : DOMString result;
487 0 : self->GetEasing(result);
488 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
489 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
490 0 : return false;
491 : }
492 0 : return true;
493 : }
494 :
495 : static bool
496 0 : set_easing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTiming* self, JSJitSetterCallArgs args)
497 : {
498 0 : binding_detail::FakeString arg0;
499 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
500 0 : return false;
501 : }
502 0 : binding_detail::FastErrorResult rv;
503 0 : self->SetEasing(NonNullHelper(Constify(arg0)), rv);
504 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
505 0 : return false;
506 : }
507 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
508 :
509 0 : return true;
510 : }
511 :
512 : static const JSJitInfo easing_getterinfo = {
513 : { (JSJitGetterOp)get_easing },
514 : { prototypes::id::AnimationEffectTiming },
515 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
516 : JSJitInfo::Getter,
517 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
518 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
519 : false, /* isInfallible. False in setters. */
520 : false, /* isMovable. Not relevant for setters. */
521 : false, /* isEliminatable. Not relevant for setters. */
522 : false, /* isAlwaysInSlot. Only relevant for getters. */
523 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
524 : false, /* isTypedMethod. Only relevant for methods. */
525 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
526 : };
527 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
528 : static_assert(0 < 1, "There is no slot for us");
529 : static const JSJitInfo easing_setterinfo = {
530 : { (JSJitGetterOp)set_easing },
531 : { prototypes::id::AnimationEffectTiming },
532 : { PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth },
533 : JSJitInfo::Setter,
534 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
535 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
536 : false, /* isInfallible. False in setters. */
537 : false, /* isMovable. Not relevant for setters. */
538 : false, /* isEliminatable. Not relevant for setters. */
539 : false, /* isAlwaysInSlot. Only relevant for getters. */
540 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
541 : false, /* isTypedMethod. Only relevant for methods. */
542 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
543 : };
544 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
545 : static_assert(0 < 1, "There is no slot for us");
546 :
547 : static bool
548 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
549 : {
550 0 : mozilla::dom::AnimationEffectTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationEffectTiming>(obj);
551 : // We don't want to preserve if we don't have a wrapper, and we
552 : // obviously can't preserve if we're not initialized.
553 0 : if (self && self->GetWrapperPreserveColor()) {
554 0 : PreserveWrapper(self);
555 : }
556 0 : return true;
557 : }
558 :
559 : static void
560 0 : _finalize(js::FreeOp* fop, JSObject* obj)
561 : {
562 0 : mozilla::dom::AnimationEffectTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationEffectTiming>(obj);
563 0 : if (self) {
564 0 : ClearWrapper(self, self, obj);
565 0 : AddForDeferredFinalization<mozilla::dom::AnimationEffectTiming>(self);
566 : }
567 0 : }
568 :
569 : static void
570 0 : _objectMoved(JSObject* obj, const JSObject* old)
571 : {
572 0 : mozilla::dom::AnimationEffectTiming* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationEffectTiming>(obj);
573 0 : if (self) {
574 0 : UpdateWrapper(self, self, obj, old);
575 : }
576 0 : }
577 :
578 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
579 : #if defined(__clang__)
580 : #pragma clang diagnostic push
581 : #pragma clang diagnostic ignored "-Wmissing-braces"
582 : #endif
583 : static const JSPropertySpec sAttributes_specs[] = {
584 : { "delay", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &delay_getterinfo, GenericBindingSetter, &delay_setterinfo },
585 : { "endDelay", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &endDelay_getterinfo, GenericBindingSetter, &endDelay_setterinfo },
586 : { "fill", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &fill_getterinfo, GenericBindingSetter, &fill_setterinfo },
587 : { "iterationStart", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &iterationStart_getterinfo, GenericBindingSetter, &iterationStart_setterinfo },
588 : { "iterations", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &iterations_getterinfo, GenericBindingSetter, &iterations_setterinfo },
589 : { "duration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &duration_getterinfo, GenericBindingSetter, &duration_setterinfo },
590 : { "direction", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &direction_getterinfo, GenericBindingSetter, &direction_setterinfo },
591 : { "easing", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &easing_getterinfo, GenericBindingSetter, &easing_setterinfo },
592 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
593 : };
594 : #if defined(__clang__)
595 : #pragma clang diagnostic pop
596 : #endif
597 :
598 :
599 : // Can't be const because the pref-enabled boolean needs to be writable
600 : static Prefable<const JSPropertySpec> sAttributes[] = {
601 : { nullptr, &sAttributes_specs[0] },
602 : { nullptr, nullptr }
603 : };
604 :
605 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
606 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
607 : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
608 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
609 :
610 :
611 : static uint16_t sNativeProperties_sortedPropertyIndices[8];
612 : static PropertyInfo sNativeProperties_propertyInfos[8];
613 :
614 : static const NativePropertiesN<1> sNativeProperties = {
615 : false, 0,
616 : false, 0,
617 : false, 0,
618 : true, 0 /* sAttributes */,
619 : false, 0,
620 : false, 0,
621 : false, 0,
622 : -1,
623 : 8,
624 : sNativeProperties_sortedPropertyIndices,
625 : {
626 : { sAttributes, &sNativeProperties_propertyInfos[0] }
627 : }
628 : };
629 : static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
630 : "We have a property info count that is oversized");
631 :
632 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
633 : {
634 : "Function",
635 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
636 : &sBoringInterfaceObjectClassClassOps,
637 : JS_NULL_CLASS_SPEC,
638 : JS_NULL_CLASS_EXT,
639 : &sInterfaceObjectClassObjectOps
640 : },
641 : eInterface,
642 : true,
643 : prototypes::id::AnimationEffectTiming,
644 : PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth,
645 : sNativePropertyHooks,
646 : "function AnimationEffectTiming() {\n [native code]\n}",
647 : AnimationEffectTimingReadOnlyBinding::GetConstructorObject
648 : };
649 :
650 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
651 : {
652 : "AnimationEffectTimingPrototype",
653 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
654 : JS_NULL_CLASS_OPS,
655 : JS_NULL_CLASS_SPEC,
656 : JS_NULL_CLASS_EXT,
657 : JS_NULL_OBJECT_OPS
658 : },
659 : eInterfacePrototype,
660 : false,
661 : prototypes::id::AnimationEffectTiming,
662 : PrototypeTraits<prototypes::id::AnimationEffectTiming>::Depth,
663 : sNativePropertyHooks,
664 : "[object AnimationEffectTimingPrototype]",
665 : AnimationEffectTimingReadOnlyBinding::GetProtoObject
666 : };
667 :
668 : bool
669 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
670 : {
671 0 : return nsDocument::IsWebAnimationsEnabled(aCx, aObj);
672 : }
673 :
674 : JSObject*
675 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
676 : {
677 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
678 : }
679 :
680 : static const js::ClassOps sClassOps = {
681 : _addProperty, /* addProperty */
682 : nullptr, /* delProperty */
683 : nullptr, /* getProperty */
684 : nullptr, /* setProperty */
685 : nullptr, /* enumerate */
686 : nullptr, /* newEnumerate */
687 : nullptr, /* resolve */
688 : nullptr, /* mayResolve */
689 : _finalize, /* finalize */
690 : nullptr, /* call */
691 : nullptr, /* hasInstance */
692 : nullptr, /* construct */
693 : nullptr, /* trace */
694 : };
695 :
696 : static const js::ClassExtension sClassExtension = {
697 : nullptr, /* weakmapKeyDelegateOp */
698 : _objectMoved /* objectMovedOp */
699 : };
700 :
701 : static const DOMJSClass sClass = {
702 : { "AnimationEffectTiming",
703 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
704 : &sClassOps,
705 : JS_NULL_CLASS_SPEC,
706 : &sClassExtension,
707 : JS_NULL_OBJECT_OPS
708 : },
709 : { prototypes::id::AnimationEffectTimingReadOnly, prototypes::id::AnimationEffectTiming, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
710 : IsBaseOf<nsISupports, mozilla::dom::AnimationEffectTiming >::value,
711 : sNativePropertyHooks,
712 : FindAssociatedGlobalForNative<mozilla::dom::AnimationEffectTiming>::Get,
713 : GetProtoObjectHandle,
714 : GetCCParticipant<mozilla::dom::AnimationEffectTiming>::Get()
715 : };
716 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
717 : "Must have the right minimal number of reserved slots.");
718 : static_assert(1 >= 1,
719 : "Must have enough reserved slots.");
720 :
721 : const JSClass*
722 0 : GetJSClass()
723 : {
724 0 : return sClass.ToJSClass();
725 : }
726 :
727 : bool
728 0 : Wrap(JSContext* aCx, mozilla::dom::AnimationEffectTiming* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
729 : {
730 : MOZ_ASSERT(static_cast<mozilla::dom::AnimationEffectTiming*>(aObject) ==
731 : reinterpret_cast<mozilla::dom::AnimationEffectTiming*>(aObject),
732 : "Multiple inheritance for mozilla::dom::AnimationEffectTiming is broken.");
733 : MOZ_ASSERT(static_cast<mozilla::dom::AnimationEffectTimingReadOnly*>(aObject) ==
734 : reinterpret_cast<mozilla::dom::AnimationEffectTimingReadOnly*>(aObject),
735 : "Multiple inheritance for mozilla::dom::AnimationEffectTimingReadOnly is broken.");
736 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
737 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
738 0 : MOZ_ASSERT(!aCache->GetWrapper(),
739 : "You should probably not be using Wrap() directly; use "
740 : "GetOrCreateDOMReflector instead");
741 :
742 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
743 : "nsISupports must be on our primary inheritance chain");
744 :
745 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
746 0 : if (!global) {
747 0 : return false;
748 : }
749 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
750 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
751 :
752 : // That might have ended up wrapping us already, due to the wonders
753 : // of XBL. Check for that, and bail out as needed.
754 0 : aReflector.set(aCache->GetWrapper());
755 0 : if (aReflector) {
756 : #ifdef DEBUG
757 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
758 : #endif // DEBUG
759 0 : return true;
760 : }
761 :
762 0 : JSAutoCompartment ac(aCx, global);
763 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
764 0 : if (!canonicalProto) {
765 0 : return false;
766 : }
767 0 : JS::Rooted<JSObject*> proto(aCx);
768 0 : if (aGivenProto) {
769 0 : proto = aGivenProto;
770 : // Unfortunately, while aGivenProto was in the compartment of aCx
771 : // coming in, we changed compartments to that of "parent" so may need
772 : // to wrap the proto here.
773 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
774 0 : if (!JS_WrapObject(aCx, &proto)) {
775 0 : return false;
776 : }
777 : }
778 : } else {
779 0 : proto = canonicalProto;
780 : }
781 :
782 0 : BindingJSObjectCreator<mozilla::dom::AnimationEffectTiming> creator(aCx);
783 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
784 0 : if (!aReflector) {
785 0 : return false;
786 : }
787 :
788 0 : aCache->SetWrapper(aReflector);
789 0 : creator.InitializationSucceeded();
790 :
791 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
792 : aCache->GetWrapperPreserveColor() == aReflector);
793 : // If proto != canonicalProto, we have to preserve our wrapper;
794 : // otherwise we won't be able to properly recreate it later, since
795 : // we won't know what proto to use. Note that we don't check
796 : // aGivenProto here, since it's entirely possible (and even
797 : // somewhat common) to have a non-null aGivenProto which is the
798 : // same as canonicalProto.
799 0 : if (proto != canonicalProto) {
800 0 : PreserveWrapper(aObject);
801 : }
802 :
803 0 : return true;
804 : }
805 :
806 : const NativePropertyHooks sNativePropertyHooks[] = { {
807 : nullptr,
808 : nullptr,
809 : nullptr,
810 : { sNativeProperties.Upcast(), nullptr },
811 : prototypes::id::AnimationEffectTiming,
812 : constructors::id::AnimationEffectTiming,
813 : AnimationEffectTimingReadOnlyBinding::sNativePropertyHooks,
814 : &DefaultXrayExpandoObjectClass
815 : } };
816 :
817 : void
818 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
819 : {
820 0 : JS::Handle<JSObject*> parentProto(AnimationEffectTimingReadOnlyBinding::GetProtoObjectHandle(aCx));
821 0 : if (!parentProto) {
822 0 : return;
823 : }
824 :
825 0 : JS::Handle<JSObject*> constructorProto(AnimationEffectTimingReadOnlyBinding::GetConstructorObjectHandle(aCx));
826 0 : if (!constructorProto) {
827 0 : return;
828 : }
829 :
830 : static bool sIdsInited = false;
831 0 : if (!sIdsInited && NS_IsMainThread()) {
832 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
833 0 : return;
834 : }
835 0 : sIdsInited = true;
836 : }
837 :
838 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnimationEffectTiming);
839 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnimationEffectTiming);
840 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
841 : &sPrototypeClass.mBase, protoCache,
842 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
843 : interfaceCache,
844 : sNativeProperties.Upcast(),
845 : nullptr,
846 : "AnimationEffectTiming", aDefineOnGlobal,
847 : nullptr,
848 0 : false);
849 : }
850 :
851 : JS::Handle<JSObject*>
852 0 : GetProtoObjectHandle(JSContext* aCx)
853 : {
854 : /* Get the interface prototype object for this class. This will create the
855 : object as needed. */
856 0 : bool aDefineOnGlobal = true;
857 :
858 : /* Make sure our global is sane. Hopefully we can remove this sometime */
859 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
860 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
861 0 : return nullptr;
862 : }
863 :
864 : /* Check to see whether the interface objects are already installed */
865 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
866 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AnimationEffectTiming)) {
867 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
868 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
869 : }
870 :
871 : /*
872 : * The object might _still_ be null, but that's OK.
873 : *
874 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
875 : * traced by TraceProtoAndIfaceCache() and its contents are never
876 : * changed after they have been set.
877 : *
878 : * Calling address() avoids the read read barrier that does gray
879 : * unmarking, but it's not possible for the object to be gray here.
880 : */
881 :
882 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AnimationEffectTiming);
883 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
884 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
885 : }
886 :
887 : JS::Handle<JSObject*>
888 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
889 : {
890 : /* Get the interface object for this class. This will create the object as
891 : needed. */
892 :
893 : /* Make sure our global is sane. Hopefully we can remove this sometime */
894 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
895 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
896 0 : return nullptr;
897 : }
898 :
899 : /* Check to see whether the interface objects are already installed */
900 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
901 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AnimationEffectTiming)) {
902 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
903 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
904 : }
905 :
906 : /*
907 : * The object might _still_ be null, but that's OK.
908 : *
909 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
910 : * traced by TraceProtoAndIfaceCache() and its contents are never
911 : * changed after they have been set.
912 : *
913 : * Calling address() avoids the read read barrier that does gray
914 : * unmarking, but it's not possible for the object to be gray here.
915 : */
916 :
917 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AnimationEffectTiming);
918 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
919 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
920 : }
921 :
922 : JSObject*
923 0 : GetConstructorObject(JSContext* aCx)
924 : {
925 0 : return GetConstructorObjectHandle(aCx);
926 : }
927 :
928 : } // namespace AnimationEffectTimingBinding
929 :
930 :
931 :
932 : } // namespace dom
933 : } // namespace mozilla
|