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