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