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