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