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