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