Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM AnimationEffectTimingReadOnly.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AnimationEffectTimingReadOnlyBinding.h"
4 : #include "WrapperFactory.h"
5 : #include "mozilla/FloatingPoint.h"
6 : #include "mozilla/OwningNonNull.h"
7 : #include "mozilla/dom/AnimationEffectTimingReadOnly.h"
8 : #include "mozilla/dom/BindingUtils.h"
9 : #include "mozilla/dom/DOMJSClass.h"
10 : #include "mozilla/dom/NonRefcountedDOMObject.h"
11 : #include "mozilla/dom/PrimitiveConversions.h"
12 : #include "mozilla/dom/UnionConversions.h"
13 : #include "mozilla/dom/UnionTypes.h"
14 : #include "mozilla/dom/XrayExpandoClass.h"
15 : #include "nsDocument.h"
16 :
17 : namespace mozilla {
18 : namespace dom {
19 :
20 : namespace AnimationEffectTimingReadOnlyBinding {
21 :
22 : static bool
23 0 : get_delay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
24 : {
25 0 : double result(self->Delay());
26 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
27 0 : args.rval().set(JS_NumberValue(double(result)));
28 0 : return true;
29 : }
30 :
31 : static const JSJitInfo delay_getterinfo = {
32 : { (JSJitGetterOp)get_delay },
33 : { prototypes::id::AnimationEffectTimingReadOnly },
34 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
35 : JSJitInfo::Getter,
36 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
37 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
38 : true, /* isInfallible. False in setters. */
39 : false, /* isMovable. Not relevant for setters. */
40 : false, /* isEliminatable. Not relevant for setters. */
41 : false, /* isAlwaysInSlot. Only relevant for getters. */
42 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
43 : false, /* isTypedMethod. Only relevant for methods. */
44 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
45 : };
46 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
47 : static_assert(0 < 1, "There is no slot for us");
48 :
49 : static bool
50 0 : get_endDelay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
51 : {
52 0 : double result(self->EndDelay());
53 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
54 0 : args.rval().set(JS_NumberValue(double(result)));
55 0 : return true;
56 : }
57 :
58 : static const JSJitInfo endDelay_getterinfo = {
59 : { (JSJitGetterOp)get_endDelay },
60 : { prototypes::id::AnimationEffectTimingReadOnly },
61 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
62 : JSJitInfo::Getter,
63 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
64 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
65 : true, /* isInfallible. False in setters. */
66 : false, /* isMovable. Not relevant for setters. */
67 : false, /* isEliminatable. Not relevant for setters. */
68 : false, /* isAlwaysInSlot. Only relevant for getters. */
69 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
70 : false, /* isTypedMethod. Only relevant for methods. */
71 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
72 : };
73 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
74 : static_assert(0 < 1, "There is no slot for us");
75 :
76 : static bool
77 0 : get_fill(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
78 : {
79 0 : FillMode result(self->Fill());
80 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
81 0 : if (!ToJSValue(cx, result, args.rval())) {
82 0 : return false;
83 : }
84 0 : return true;
85 : }
86 :
87 : static const JSJitInfo fill_getterinfo = {
88 : { (JSJitGetterOp)get_fill },
89 : { prototypes::id::AnimationEffectTimingReadOnly },
90 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
91 : JSJitInfo::Getter,
92 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
93 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
94 : false, /* isInfallible. False in setters. */
95 : false, /* isMovable. Not relevant for setters. */
96 : false, /* isEliminatable. Not relevant for setters. */
97 : false, /* isAlwaysInSlot. Only relevant for getters. */
98 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
99 : false, /* isTypedMethod. Only relevant for methods. */
100 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
101 : };
102 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
103 : static_assert(0 < 1, "There is no slot for us");
104 :
105 : static bool
106 0 : get_iterationStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
107 : {
108 0 : double result(self->IterationStart());
109 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
110 0 : args.rval().set(JS_NumberValue(double(result)));
111 0 : return true;
112 : }
113 :
114 : static const JSJitInfo iterationStart_getterinfo = {
115 : { (JSJitGetterOp)get_iterationStart },
116 : { prototypes::id::AnimationEffectTimingReadOnly },
117 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
118 : JSJitInfo::Getter,
119 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
120 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
121 : true, /* isInfallible. False in setters. */
122 : false, /* isMovable. Not relevant for setters. */
123 : false, /* isEliminatable. Not relevant for setters. */
124 : false, /* isAlwaysInSlot. Only relevant for getters. */
125 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
126 : false, /* isTypedMethod. Only relevant for methods. */
127 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
128 : };
129 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
130 : static_assert(0 < 1, "There is no slot for us");
131 :
132 : static bool
133 0 : get_iterations(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
134 : {
135 0 : double result(self->Iterations());
136 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
137 0 : args.rval().set(JS_NumberValue(double(result)));
138 0 : return true;
139 : }
140 :
141 : static const JSJitInfo iterations_getterinfo = {
142 : { (JSJitGetterOp)get_iterations },
143 : { prototypes::id::AnimationEffectTimingReadOnly },
144 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
145 : JSJitInfo::Getter,
146 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
147 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
148 : true, /* isInfallible. False in setters. */
149 : false, /* isMovable. Not relevant for setters. */
150 : false, /* isEliminatable. Not relevant for setters. */
151 : false, /* isAlwaysInSlot. Only relevant for getters. */
152 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
153 : false, /* isTypedMethod. Only relevant for methods. */
154 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
155 : };
156 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
157 : static_assert(0 < 1, "There is no slot for us");
158 :
159 : static bool
160 0 : get_duration(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
161 : {
162 0 : OwningUnrestrictedDoubleOrString result;
163 0 : self->GetDuration(result);
164 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
165 0 : if (!result.ToJSVal(cx, obj, args.rval())) {
166 0 : return false;
167 : }
168 0 : return true;
169 : }
170 :
171 : static const JSJitInfo duration_getterinfo = {
172 : { (JSJitGetterOp)get_duration },
173 : { prototypes::id::AnimationEffectTimingReadOnly },
174 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
175 : JSJitInfo::Getter,
176 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
177 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
178 : false, /* isInfallible. False in setters. */
179 : false, /* isMovable. Not relevant for setters. */
180 : false, /* isEliminatable. Not relevant for setters. */
181 : false, /* isAlwaysInSlot. Only relevant for getters. */
182 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
183 : false, /* isTypedMethod. Only relevant for methods. */
184 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
185 : };
186 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
187 : static_assert(0 < 1, "There is no slot for us");
188 :
189 : static bool
190 0 : get_direction(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
191 : {
192 0 : PlaybackDirection result(self->Direction());
193 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
194 0 : if (!ToJSValue(cx, result, args.rval())) {
195 0 : return false;
196 : }
197 0 : return true;
198 : }
199 :
200 : static const JSJitInfo direction_getterinfo = {
201 : { (JSJitGetterOp)get_direction },
202 : { prototypes::id::AnimationEffectTimingReadOnly },
203 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
204 : JSJitInfo::Getter,
205 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
206 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
207 : false, /* isInfallible. False in setters. */
208 : false, /* isMovable. Not relevant for setters. */
209 : false, /* isEliminatable. Not relevant for setters. */
210 : false, /* isAlwaysInSlot. Only relevant for getters. */
211 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
212 : false, /* isTypedMethod. Only relevant for methods. */
213 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
214 : };
215 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
216 : static_assert(0 < 1, "There is no slot for us");
217 :
218 : static bool
219 0 : get_easing(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AnimationEffectTimingReadOnly* self, JSJitGetterCallArgs args)
220 : {
221 0 : DOMString result;
222 0 : self->GetEasing(result);
223 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
224 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
225 0 : return false;
226 : }
227 0 : return true;
228 : }
229 :
230 : static const JSJitInfo easing_getterinfo = {
231 : { (JSJitGetterOp)get_easing },
232 : { prototypes::id::AnimationEffectTimingReadOnly },
233 : { PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth },
234 : JSJitInfo::Getter,
235 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
236 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
237 : false, /* isInfallible. False in setters. */
238 : false, /* isMovable. Not relevant for setters. */
239 : false, /* isEliminatable. Not relevant for setters. */
240 : false, /* isAlwaysInSlot. Only relevant for getters. */
241 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
242 : false, /* isTypedMethod. Only relevant for methods. */
243 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
244 : };
245 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
246 : static_assert(0 < 1, "There is no slot for us");
247 :
248 : static bool
249 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
250 : {
251 0 : mozilla::dom::AnimationEffectTimingReadOnly* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationEffectTimingReadOnly>(obj);
252 : // We don't want to preserve if we don't have a wrapper, and we
253 : // obviously can't preserve if we're not initialized.
254 0 : if (self && self->GetWrapperPreserveColor()) {
255 0 : PreserveWrapper(self);
256 : }
257 0 : return true;
258 : }
259 :
260 : static void
261 0 : _finalize(js::FreeOp* fop, JSObject* obj)
262 : {
263 0 : mozilla::dom::AnimationEffectTimingReadOnly* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationEffectTimingReadOnly>(obj);
264 0 : if (self) {
265 0 : ClearWrapper(self, self, obj);
266 0 : AddForDeferredFinalization<mozilla::dom::AnimationEffectTimingReadOnly>(self);
267 : }
268 0 : }
269 :
270 : static void
271 0 : _objectMoved(JSObject* obj, const JSObject* old)
272 : {
273 0 : mozilla::dom::AnimationEffectTimingReadOnly* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AnimationEffectTimingReadOnly>(obj);
274 0 : if (self) {
275 0 : UpdateWrapper(self, self, obj, old);
276 : }
277 0 : }
278 :
279 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
280 : #if defined(__clang__)
281 : #pragma clang diagnostic push
282 : #pragma clang diagnostic ignored "-Wmissing-braces"
283 : #endif
284 : static const JSPropertySpec sAttributes_specs[] = {
285 : { "delay", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &delay_getterinfo, nullptr, nullptr },
286 : { "endDelay", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &endDelay_getterinfo, nullptr, nullptr },
287 : { "fill", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &fill_getterinfo, nullptr, nullptr },
288 : { "iterationStart", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &iterationStart_getterinfo, nullptr, nullptr },
289 : { "iterations", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &iterations_getterinfo, nullptr, nullptr },
290 : { "duration", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &duration_getterinfo, nullptr, nullptr },
291 : { "direction", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &direction_getterinfo, nullptr, nullptr },
292 : { "easing", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &easing_getterinfo, nullptr, nullptr },
293 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
294 : };
295 : #if defined(__clang__)
296 : #pragma clang diagnostic pop
297 : #endif
298 :
299 :
300 : // Can't be const because the pref-enabled boolean needs to be writable
301 : static Prefable<const JSPropertySpec> sAttributes[] = {
302 : { nullptr, &sAttributes_specs[0] },
303 : { nullptr, nullptr }
304 : };
305 :
306 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
307 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
308 : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
309 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
310 :
311 :
312 : static uint16_t sNativeProperties_sortedPropertyIndices[8];
313 : static PropertyInfo sNativeProperties_propertyInfos[8];
314 :
315 : static const NativePropertiesN<1> sNativeProperties = {
316 : false, 0,
317 : false, 0,
318 : false, 0,
319 : true, 0 /* sAttributes */,
320 : false, 0,
321 : false, 0,
322 : false, 0,
323 : -1,
324 : 8,
325 : sNativeProperties_sortedPropertyIndices,
326 : {
327 : { sAttributes, &sNativeProperties_propertyInfos[0] }
328 : }
329 : };
330 : static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
331 : "We have a property info count that is oversized");
332 :
333 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
334 : {
335 : "Function",
336 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
337 : &sBoringInterfaceObjectClassClassOps,
338 : JS_NULL_CLASS_SPEC,
339 : JS_NULL_CLASS_EXT,
340 : &sInterfaceObjectClassObjectOps
341 : },
342 : eInterface,
343 : true,
344 : prototypes::id::AnimationEffectTimingReadOnly,
345 : PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth,
346 : sNativePropertyHooks,
347 : "function AnimationEffectTimingReadOnly() {\n [native code]\n}",
348 : JS::GetRealmFunctionPrototype
349 : };
350 :
351 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
352 : {
353 : "AnimationEffectTimingReadOnlyPrototype",
354 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
355 : JS_NULL_CLASS_OPS,
356 : JS_NULL_CLASS_SPEC,
357 : JS_NULL_CLASS_EXT,
358 : JS_NULL_OBJECT_OPS
359 : },
360 : eInterfacePrototype,
361 : false,
362 : prototypes::id::AnimationEffectTimingReadOnly,
363 : PrototypeTraits<prototypes::id::AnimationEffectTimingReadOnly>::Depth,
364 : sNativePropertyHooks,
365 : "[object AnimationEffectTimingReadOnlyPrototype]",
366 : JS::GetRealmObjectPrototype
367 : };
368 :
369 : bool
370 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
371 : {
372 0 : return nsDocument::IsWebAnimationsEnabled(aCx, aObj);
373 : }
374 :
375 : JSObject*
376 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
377 : {
378 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
379 : }
380 :
381 : static const js::ClassOps sClassOps = {
382 : _addProperty, /* addProperty */
383 : nullptr, /* delProperty */
384 : nullptr, /* getProperty */
385 : nullptr, /* setProperty */
386 : nullptr, /* enumerate */
387 : nullptr, /* newEnumerate */
388 : nullptr, /* resolve */
389 : nullptr, /* mayResolve */
390 : _finalize, /* finalize */
391 : nullptr, /* call */
392 : nullptr, /* hasInstance */
393 : nullptr, /* construct */
394 : nullptr, /* trace */
395 : };
396 :
397 : static const js::ClassExtension sClassExtension = {
398 : nullptr, /* weakmapKeyDelegateOp */
399 : _objectMoved /* objectMovedOp */
400 : };
401 :
402 : static const DOMJSClass sClass = {
403 : { "AnimationEffectTimingReadOnly",
404 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
405 : &sClassOps,
406 : JS_NULL_CLASS_SPEC,
407 : &sClassExtension,
408 : JS_NULL_OBJECT_OPS
409 : },
410 : { prototypes::id::AnimationEffectTimingReadOnly, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
411 : IsBaseOf<nsISupports, mozilla::dom::AnimationEffectTimingReadOnly >::value,
412 : sNativePropertyHooks,
413 : FindAssociatedGlobalForNative<mozilla::dom::AnimationEffectTimingReadOnly>::Get,
414 : GetProtoObjectHandle,
415 : GetCCParticipant<mozilla::dom::AnimationEffectTimingReadOnly>::Get()
416 : };
417 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
418 : "Must have the right minimal number of reserved slots.");
419 : static_assert(1 >= 1,
420 : "Must have enough reserved slots.");
421 :
422 : const JSClass*
423 0 : GetJSClass()
424 : {
425 0 : return sClass.ToJSClass();
426 : }
427 :
428 : bool
429 0 : Wrap(JSContext* aCx, mozilla::dom::AnimationEffectTimingReadOnly* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
430 : {
431 : MOZ_ASSERT(static_cast<mozilla::dom::AnimationEffectTimingReadOnly*>(aObject) ==
432 : reinterpret_cast<mozilla::dom::AnimationEffectTimingReadOnly*>(aObject),
433 : "Multiple inheritance for mozilla::dom::AnimationEffectTimingReadOnly is broken.");
434 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
435 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
436 0 : MOZ_ASSERT(!aCache->GetWrapper(),
437 : "You should probably not be using Wrap() directly; use "
438 : "GetOrCreateDOMReflector instead");
439 :
440 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
441 : "nsISupports must be on our primary inheritance chain");
442 :
443 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
444 0 : if (!global) {
445 0 : return false;
446 : }
447 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
448 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
449 :
450 : // That might have ended up wrapping us already, due to the wonders
451 : // of XBL. Check for that, and bail out as needed.
452 0 : aReflector.set(aCache->GetWrapper());
453 0 : if (aReflector) {
454 : #ifdef DEBUG
455 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
456 : #endif // DEBUG
457 0 : return true;
458 : }
459 :
460 0 : JSAutoCompartment ac(aCx, global);
461 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
462 0 : if (!canonicalProto) {
463 0 : return false;
464 : }
465 0 : JS::Rooted<JSObject*> proto(aCx);
466 0 : if (aGivenProto) {
467 0 : proto = aGivenProto;
468 : // Unfortunately, while aGivenProto was in the compartment of aCx
469 : // coming in, we changed compartments to that of "parent" so may need
470 : // to wrap the proto here.
471 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
472 0 : if (!JS_WrapObject(aCx, &proto)) {
473 0 : return false;
474 : }
475 : }
476 : } else {
477 0 : proto = canonicalProto;
478 : }
479 :
480 0 : BindingJSObjectCreator<mozilla::dom::AnimationEffectTimingReadOnly> creator(aCx);
481 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
482 0 : if (!aReflector) {
483 0 : return false;
484 : }
485 :
486 0 : aCache->SetWrapper(aReflector);
487 0 : creator.InitializationSucceeded();
488 :
489 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
490 : aCache->GetWrapperPreserveColor() == aReflector);
491 : // If proto != canonicalProto, we have to preserve our wrapper;
492 : // otherwise we won't be able to properly recreate it later, since
493 : // we won't know what proto to use. Note that we don't check
494 : // aGivenProto here, since it's entirely possible (and even
495 : // somewhat common) to have a non-null aGivenProto which is the
496 : // same as canonicalProto.
497 0 : if (proto != canonicalProto) {
498 0 : PreserveWrapper(aObject);
499 : }
500 :
501 0 : return true;
502 : }
503 :
504 : const NativePropertyHooks sNativePropertyHooks[] = { {
505 : nullptr,
506 : nullptr,
507 : nullptr,
508 : { sNativeProperties.Upcast(), nullptr },
509 : prototypes::id::AnimationEffectTimingReadOnly,
510 : constructors::id::AnimationEffectTimingReadOnly,
511 : nullptr,
512 : &DefaultXrayExpandoObjectClass
513 : } };
514 :
515 : void
516 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
517 : {
518 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
519 0 : if (!parentProto) {
520 0 : return;
521 : }
522 :
523 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
524 0 : if (!constructorProto) {
525 0 : return;
526 : }
527 :
528 : static bool sIdsInited = false;
529 0 : if (!sIdsInited && NS_IsMainThread()) {
530 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
531 0 : return;
532 : }
533 0 : sIdsInited = true;
534 : }
535 :
536 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnimationEffectTimingReadOnly);
537 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnimationEffectTimingReadOnly);
538 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
539 : &sPrototypeClass.mBase, protoCache,
540 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
541 : interfaceCache,
542 : sNativeProperties.Upcast(),
543 : nullptr,
544 : "AnimationEffectTimingReadOnly", aDefineOnGlobal,
545 : nullptr,
546 0 : false);
547 : }
548 :
549 : JS::Handle<JSObject*>
550 0 : GetProtoObjectHandle(JSContext* aCx)
551 : {
552 : /* Get the interface prototype object for this class. This will create the
553 : object as needed. */
554 0 : bool aDefineOnGlobal = true;
555 :
556 : /* Make sure our global is sane. Hopefully we can remove this sometime */
557 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
558 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
559 0 : return nullptr;
560 : }
561 :
562 : /* Check to see whether the interface objects are already installed */
563 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
564 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AnimationEffectTimingReadOnly)) {
565 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
566 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
567 : }
568 :
569 : /*
570 : * The object might _still_ be null, but that's OK.
571 : *
572 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
573 : * traced by TraceProtoAndIfaceCache() and its contents are never
574 : * changed after they have been set.
575 : *
576 : * Calling address() avoids the read read barrier that does gray
577 : * unmarking, but it's not possible for the object to be gray here.
578 : */
579 :
580 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AnimationEffectTimingReadOnly);
581 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
582 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
583 : }
584 :
585 : JSObject*
586 0 : GetProtoObject(JSContext* aCx)
587 : {
588 0 : return GetProtoObjectHandle(aCx);
589 : }
590 :
591 : JS::Handle<JSObject*>
592 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
593 : {
594 : /* Get the interface object for this class. This will create the object as
595 : needed. */
596 :
597 : /* Make sure our global is sane. Hopefully we can remove this sometime */
598 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
599 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
600 0 : return nullptr;
601 : }
602 :
603 : /* Check to see whether the interface objects are already installed */
604 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
605 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AnimationEffectTimingReadOnly)) {
606 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
607 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
608 : }
609 :
610 : /*
611 : * The object might _still_ be null, but that's OK.
612 : *
613 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
614 : * traced by TraceProtoAndIfaceCache() and its contents are never
615 : * changed after they have been set.
616 : *
617 : * Calling address() avoids the read read barrier that does gray
618 : * unmarking, but it's not possible for the object to be gray here.
619 : */
620 :
621 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AnimationEffectTimingReadOnly);
622 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
623 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
624 : }
625 :
626 : JSObject*
627 0 : GetConstructorObject(JSContext* aCx)
628 : {
629 0 : return GetConstructorObjectHandle(aCx);
630 : }
631 :
632 : } // namespace AnimationEffectTimingReadOnlyBinding
633 :
634 :
635 :
636 : } // namespace dom
637 : } // namespace mozilla
|