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