Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SVGFESpotLightElement.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "SVGElementBinding.h"
4 : #include "SVGFESpotLightElementBinding.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/SVGAnimatedNumber.h"
11 : #include "mozilla/dom/SVGFESpotLightElement.h"
12 : #include "mozilla/dom/XrayExpandoClass.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : namespace SVGFESpotLightElementBinding {
18 :
19 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<SVGElementBinding::NativeType>::value,
20 : "Can't inherit from an interface with a different ownership model.");
21 :
22 : static bool
23 0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
24 : {
25 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->X()));
26 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
27 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
28 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
29 0 : return false;
30 : }
31 0 : return true;
32 : }
33 :
34 : static const JSJitInfo x_getterinfo = {
35 : { (JSJitGetterOp)get_x },
36 : { prototypes::id::SVGFESpotLightElement },
37 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
38 : JSJitInfo::Getter,
39 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
40 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
41 : false, /* isInfallible. False in setters. */
42 : true, /* isMovable. Not relevant for setters. */
43 : true, /* isEliminatable. Not relevant for setters. */
44 : false, /* isAlwaysInSlot. Only relevant for getters. */
45 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
46 : false, /* isTypedMethod. Only relevant for methods. */
47 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
48 : };
49 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
50 : static_assert(0 < 1, "There is no slot for us");
51 :
52 : static bool
53 0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
54 : {
55 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->Y()));
56 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
57 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
58 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
59 0 : return false;
60 : }
61 0 : return true;
62 : }
63 :
64 : static const JSJitInfo y_getterinfo = {
65 : { (JSJitGetterOp)get_y },
66 : { prototypes::id::SVGFESpotLightElement },
67 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
68 : JSJitInfo::Getter,
69 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
70 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
71 : false, /* isInfallible. False in setters. */
72 : true, /* isMovable. Not relevant for setters. */
73 : true, /* isEliminatable. Not relevant for setters. */
74 : false, /* isAlwaysInSlot. Only relevant for getters. */
75 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
76 : false, /* isTypedMethod. Only relevant for methods. */
77 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
78 : };
79 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
80 : static_assert(0 < 1, "There is no slot for us");
81 :
82 : static bool
83 0 : get_z(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
84 : {
85 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->Z()));
86 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
87 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
88 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
89 0 : return false;
90 : }
91 0 : return true;
92 : }
93 :
94 : static const JSJitInfo z_getterinfo = {
95 : { (JSJitGetterOp)get_z },
96 : { prototypes::id::SVGFESpotLightElement },
97 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
98 : JSJitInfo::Getter,
99 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
100 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
101 : false, /* isInfallible. False in setters. */
102 : true, /* isMovable. Not relevant for setters. */
103 : true, /* isEliminatable. Not relevant for setters. */
104 : false, /* isAlwaysInSlot. Only relevant for getters. */
105 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
106 : false, /* isTypedMethod. Only relevant for methods. */
107 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
108 : };
109 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
110 : static_assert(0 < 1, "There is no slot for us");
111 :
112 : static bool
113 0 : get_pointsAtX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
114 : {
115 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->PointsAtX()));
116 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
117 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
118 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
119 0 : return false;
120 : }
121 0 : return true;
122 : }
123 :
124 : static const JSJitInfo pointsAtX_getterinfo = {
125 : { (JSJitGetterOp)get_pointsAtX },
126 : { prototypes::id::SVGFESpotLightElement },
127 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
128 : JSJitInfo::Getter,
129 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
130 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
131 : false, /* isInfallible. False in setters. */
132 : true, /* isMovable. Not relevant for setters. */
133 : true, /* isEliminatable. Not relevant for setters. */
134 : false, /* isAlwaysInSlot. Only relevant for getters. */
135 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
136 : false, /* isTypedMethod. Only relevant for methods. */
137 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
138 : };
139 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
140 : static_assert(0 < 1, "There is no slot for us");
141 :
142 : static bool
143 0 : get_pointsAtY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
144 : {
145 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->PointsAtY()));
146 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
147 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
148 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
149 0 : return false;
150 : }
151 0 : return true;
152 : }
153 :
154 : static const JSJitInfo pointsAtY_getterinfo = {
155 : { (JSJitGetterOp)get_pointsAtY },
156 : { prototypes::id::SVGFESpotLightElement },
157 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
158 : JSJitInfo::Getter,
159 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
160 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
161 : false, /* isInfallible. False in setters. */
162 : true, /* isMovable. Not relevant for setters. */
163 : true, /* isEliminatable. Not relevant for setters. */
164 : false, /* isAlwaysInSlot. Only relevant for getters. */
165 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
166 : false, /* isTypedMethod. Only relevant for methods. */
167 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
168 : };
169 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
170 : static_assert(0 < 1, "There is no slot for us");
171 :
172 : static bool
173 0 : get_pointsAtZ(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
174 : {
175 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->PointsAtZ()));
176 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
177 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
178 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
179 0 : return false;
180 : }
181 0 : return true;
182 : }
183 :
184 : static const JSJitInfo pointsAtZ_getterinfo = {
185 : { (JSJitGetterOp)get_pointsAtZ },
186 : { prototypes::id::SVGFESpotLightElement },
187 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
188 : JSJitInfo::Getter,
189 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
190 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
191 : false, /* isInfallible. False in setters. */
192 : true, /* isMovable. Not relevant for setters. */
193 : true, /* isEliminatable. Not relevant for setters. */
194 : false, /* isAlwaysInSlot. Only relevant for getters. */
195 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
196 : false, /* isTypedMethod. Only relevant for methods. */
197 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
198 : };
199 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
200 : static_assert(0 < 1, "There is no slot for us");
201 :
202 : static bool
203 0 : get_specularExponent(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
204 : {
205 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->SpecularExponent()));
206 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
207 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
208 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
209 0 : return false;
210 : }
211 0 : return true;
212 : }
213 :
214 : static const JSJitInfo specularExponent_getterinfo = {
215 : { (JSJitGetterOp)get_specularExponent },
216 : { prototypes::id::SVGFESpotLightElement },
217 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
218 : JSJitInfo::Getter,
219 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
220 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
221 : false, /* isInfallible. False in setters. */
222 : true, /* isMovable. Not relevant for setters. */
223 : true, /* isEliminatable. Not relevant for setters. */
224 : false, /* isAlwaysInSlot. Only relevant for getters. */
225 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
226 : false, /* isTypedMethod. Only relevant for methods. */
227 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
228 : };
229 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
230 : static_assert(0 < 1, "There is no slot for us");
231 :
232 : static bool
233 0 : get_limitingConeAngle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFESpotLightElement* self, JSJitGetterCallArgs args)
234 : {
235 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedNumber>(self->LimitingConeAngle()));
236 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
237 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
238 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
239 0 : return false;
240 : }
241 0 : return true;
242 : }
243 :
244 : static const JSJitInfo limitingConeAngle_getterinfo = {
245 : { (JSJitGetterOp)get_limitingConeAngle },
246 : { prototypes::id::SVGFESpotLightElement },
247 : { PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth },
248 : JSJitInfo::Getter,
249 : JSJitInfo::AliasNone, /* aliasSet. Not relevant for setters. */
250 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
251 : false, /* isInfallible. False in setters. */
252 : true, /* isMovable. Not relevant for setters. */
253 : true, /* isEliminatable. Not relevant for setters. */
254 : false, /* isAlwaysInSlot. Only relevant for getters. */
255 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
256 : false, /* isTypedMethod. Only relevant for methods. */
257 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
258 : };
259 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
260 : static_assert(0 < 1, "There is no slot for us");
261 :
262 : static bool
263 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
264 : {
265 0 : mozilla::dom::SVGFESpotLightElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGFESpotLightElement>(obj);
266 : // We don't want to preserve if we don't have a wrapper, and we
267 : // obviously can't preserve if we're not initialized.
268 0 : if (self && self->GetWrapperPreserveColor()) {
269 0 : PreserveWrapper(self);
270 : }
271 0 : return true;
272 : }
273 :
274 : static void
275 0 : _finalize(js::FreeOp* fop, JSObject* obj)
276 : {
277 0 : mozilla::dom::SVGFESpotLightElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGFESpotLightElement>(obj);
278 0 : if (self) {
279 0 : ClearWrapper(self, self, obj);
280 0 : AddForDeferredFinalization<mozilla::dom::SVGFESpotLightElement>(self);
281 : }
282 0 : }
283 :
284 : static void
285 0 : _objectMoved(JSObject* obj, const JSObject* old)
286 : {
287 0 : mozilla::dom::SVGFESpotLightElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGFESpotLightElement>(obj);
288 0 : if (self) {
289 0 : UpdateWrapper(self, self, obj, old);
290 : }
291 0 : }
292 :
293 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
294 : #if defined(__clang__)
295 : #pragma clang diagnostic push
296 : #pragma clang diagnostic ignored "-Wmissing-braces"
297 : #endif
298 : static const JSPropertySpec sAttributes_specs[] = {
299 : { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, nullptr, nullptr },
300 : { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, nullptr, nullptr },
301 : { "z", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &z_getterinfo, nullptr, nullptr },
302 : { "pointsAtX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pointsAtX_getterinfo, nullptr, nullptr },
303 : { "pointsAtY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pointsAtY_getterinfo, nullptr, nullptr },
304 : { "pointsAtZ", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &pointsAtZ_getterinfo, nullptr, nullptr },
305 : { "specularExponent", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &specularExponent_getterinfo, nullptr, nullptr },
306 : { "limitingConeAngle", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &limitingConeAngle_getterinfo, nullptr, nullptr },
307 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
308 : };
309 : #if defined(__clang__)
310 : #pragma clang diagnostic pop
311 : #endif
312 :
313 :
314 : // Can't be const because the pref-enabled boolean needs to be writable
315 : static Prefable<const JSPropertySpec> sAttributes[] = {
316 : { nullptr, &sAttributes_specs[0] },
317 : { nullptr, nullptr }
318 : };
319 :
320 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
321 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
322 : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
323 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
324 :
325 :
326 : static uint16_t sNativeProperties_sortedPropertyIndices[8];
327 : static PropertyInfo sNativeProperties_propertyInfos[8];
328 :
329 : static const NativePropertiesN<1> sNativeProperties = {
330 : false, 0,
331 : false, 0,
332 : false, 0,
333 : true, 0 /* sAttributes */,
334 : false, 0,
335 : false, 0,
336 : false, 0,
337 : -1,
338 : 8,
339 : sNativeProperties_sortedPropertyIndices,
340 : {
341 : { sAttributes, &sNativeProperties_propertyInfos[0] }
342 : }
343 : };
344 : static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
345 : "We have a property info count that is oversized");
346 :
347 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
348 : {
349 : "Function",
350 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
351 : &sBoringInterfaceObjectClassClassOps,
352 : JS_NULL_CLASS_SPEC,
353 : JS_NULL_CLASS_EXT,
354 : &sInterfaceObjectClassObjectOps
355 : },
356 : eInterface,
357 : true,
358 : prototypes::id::SVGFESpotLightElement,
359 : PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth,
360 : sNativePropertyHooks,
361 : "function SVGFESpotLightElement() {\n [native code]\n}",
362 : SVGElementBinding::GetConstructorObject
363 : };
364 :
365 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
366 : {
367 : "SVGFESpotLightElementPrototype",
368 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
369 : JS_NULL_CLASS_OPS,
370 : JS_NULL_CLASS_SPEC,
371 : JS_NULL_CLASS_EXT,
372 : JS_NULL_OBJECT_OPS
373 : },
374 : eInterfacePrototype,
375 : false,
376 : prototypes::id::SVGFESpotLightElement,
377 : PrototypeTraits<prototypes::id::SVGFESpotLightElement>::Depth,
378 : sNativePropertyHooks,
379 : "[object SVGFESpotLightElementPrototype]",
380 : SVGElementBinding::GetProtoObject
381 : };
382 :
383 : JSObject*
384 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
385 : {
386 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
387 : }
388 :
389 : static const js::ClassOps sClassOps = {
390 : _addProperty, /* addProperty */
391 : nullptr, /* delProperty */
392 : nullptr, /* getProperty */
393 : nullptr, /* setProperty */
394 : nullptr, /* enumerate */
395 : nullptr, /* newEnumerate */
396 : nullptr, /* resolve */
397 : nullptr, /* mayResolve */
398 : _finalize, /* finalize */
399 : nullptr, /* call */
400 : nullptr, /* hasInstance */
401 : nullptr, /* construct */
402 : nullptr, /* trace */
403 : };
404 :
405 : static const js::ClassExtension sClassExtension = {
406 : nullptr, /* weakmapKeyDelegateOp */
407 : _objectMoved /* objectMovedOp */
408 : };
409 :
410 : static const DOMJSClass sClass = {
411 : { "SVGFESpotLightElement",
412 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
413 : &sClassOps,
414 : JS_NULL_CLASS_SPEC,
415 : &sClassExtension,
416 : JS_NULL_OBJECT_OPS
417 : },
418 : { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::SVGElement, prototypes::id::SVGFESpotLightElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
419 : IsBaseOf<nsISupports, mozilla::dom::SVGFESpotLightElement >::value,
420 : sNativePropertyHooks,
421 : FindAssociatedGlobalForNative<mozilla::dom::SVGFESpotLightElement>::Get,
422 : GetProtoObjectHandle,
423 : GetCCParticipant<mozilla::dom::SVGFESpotLightElement>::Get()
424 : };
425 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
426 : "Must have the right minimal number of reserved slots.");
427 : static_assert(1 >= 1,
428 : "Must have enough reserved slots.");
429 :
430 : const JSClass*
431 0 : GetJSClass()
432 : {
433 0 : return sClass.ToJSClass();
434 : }
435 :
436 : bool
437 0 : Wrap(JSContext* aCx, mozilla::dom::SVGFESpotLightElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
438 : {
439 : MOZ_ASSERT(static_cast<mozilla::dom::SVGFESpotLightElement*>(aObject) ==
440 : reinterpret_cast<mozilla::dom::SVGFESpotLightElement*>(aObject),
441 : "Multiple inheritance for mozilla::dom::SVGFESpotLightElement is broken.");
442 : MOZ_ASSERT(static_cast<nsSVGElement*>(aObject) ==
443 : reinterpret_cast<nsSVGElement*>(aObject),
444 : "Multiple inheritance for nsSVGElement is broken.");
445 : MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
446 : reinterpret_cast<mozilla::dom::Element*>(aObject),
447 : "Multiple inheritance for mozilla::dom::Element is broken.");
448 : MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
449 : reinterpret_cast<nsINode*>(aObject),
450 : "Multiple inheritance for nsINode is broken.");
451 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
452 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
453 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
454 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
455 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
456 0 : MOZ_ASSERT(!aCache->GetWrapper(),
457 : "You should probably not be using Wrap() directly; use "
458 : "GetOrCreateDOMReflector instead");
459 :
460 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
461 : "nsISupports must be on our primary inheritance chain");
462 :
463 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
464 0 : if (!global) {
465 0 : return false;
466 : }
467 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
468 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
469 :
470 : // That might have ended up wrapping us already, due to the wonders
471 : // of XBL. Check for that, and bail out as needed.
472 0 : aReflector.set(aCache->GetWrapper());
473 0 : if (aReflector) {
474 : #ifdef DEBUG
475 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
476 : #endif // DEBUG
477 0 : return true;
478 : }
479 :
480 0 : JSAutoCompartment ac(aCx, global);
481 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
482 0 : if (!canonicalProto) {
483 0 : return false;
484 : }
485 0 : JS::Rooted<JSObject*> proto(aCx);
486 0 : if (aGivenProto) {
487 0 : proto = aGivenProto;
488 : // Unfortunately, while aGivenProto was in the compartment of aCx
489 : // coming in, we changed compartments to that of "parent" so may need
490 : // to wrap the proto here.
491 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
492 0 : if (!JS_WrapObject(aCx, &proto)) {
493 0 : return false;
494 : }
495 : }
496 : } else {
497 0 : proto = canonicalProto;
498 : }
499 :
500 0 : BindingJSObjectCreator<mozilla::dom::SVGFESpotLightElement> creator(aCx);
501 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
502 0 : if (!aReflector) {
503 0 : return false;
504 : }
505 :
506 0 : aCache->SetWrapper(aReflector);
507 0 : creator.InitializationSucceeded();
508 :
509 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
510 : aCache->GetWrapperPreserveColor() == aReflector);
511 : // If proto != canonicalProto, we have to preserve our wrapper;
512 : // otherwise we won't be able to properly recreate it later, since
513 : // we won't know what proto to use. Note that we don't check
514 : // aGivenProto here, since it's entirely possible (and even
515 : // somewhat common) to have a non-null aGivenProto which is the
516 : // same as canonicalProto.
517 0 : if (proto != canonicalProto) {
518 0 : PreserveWrapper(aObject);
519 : }
520 :
521 0 : return true;
522 : }
523 :
524 : const NativePropertyHooks sNativePropertyHooks[] = { {
525 : nullptr,
526 : nullptr,
527 : nullptr,
528 : { sNativeProperties.Upcast(), nullptr },
529 : prototypes::id::SVGFESpotLightElement,
530 : constructors::id::SVGFESpotLightElement,
531 : SVGElementBinding::sNativePropertyHooks,
532 : &DefaultXrayExpandoObjectClass
533 : } };
534 :
535 : void
536 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
537 : {
538 0 : JS::Handle<JSObject*> parentProto(SVGElementBinding::GetProtoObjectHandle(aCx));
539 0 : if (!parentProto) {
540 0 : return;
541 : }
542 :
543 0 : JS::Handle<JSObject*> constructorProto(SVGElementBinding::GetConstructorObjectHandle(aCx));
544 0 : if (!constructorProto) {
545 0 : return;
546 : }
547 :
548 : static bool sIdsInited = false;
549 0 : if (!sIdsInited && NS_IsMainThread()) {
550 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
551 0 : return;
552 : }
553 0 : sIdsInited = true;
554 : }
555 :
556 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGFESpotLightElement);
557 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGFESpotLightElement);
558 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
559 : &sPrototypeClass.mBase, protoCache,
560 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
561 : interfaceCache,
562 : sNativeProperties.Upcast(),
563 : nullptr,
564 : "SVGFESpotLightElement", aDefineOnGlobal,
565 : nullptr,
566 0 : false);
567 : }
568 :
569 : JS::Handle<JSObject*>
570 0 : GetProtoObjectHandle(JSContext* aCx)
571 : {
572 : /* Get the interface prototype object for this class. This will create the
573 : object as needed. */
574 0 : bool aDefineOnGlobal = true;
575 :
576 : /* Make sure our global is sane. Hopefully we can remove this sometime */
577 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
578 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
579 0 : return nullptr;
580 : }
581 :
582 : /* Check to see whether the interface objects are already installed */
583 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
584 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SVGFESpotLightElement)) {
585 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
586 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
587 : }
588 :
589 : /*
590 : * The object might _still_ be null, but that's OK.
591 : *
592 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
593 : * traced by TraceProtoAndIfaceCache() and its contents are never
594 : * changed after they have been set.
595 : *
596 : * Calling address() avoids the read read barrier that does gray
597 : * unmarking, but it's not possible for the object to be gray here.
598 : */
599 :
600 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SVGFESpotLightElement);
601 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
602 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
603 : }
604 :
605 : JS::Handle<JSObject*>
606 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
607 : {
608 : /* Get the interface object for this class. This will create the object as
609 : needed. */
610 :
611 : /* Make sure our global is sane. Hopefully we can remove this sometime */
612 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
613 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
614 0 : return nullptr;
615 : }
616 :
617 : /* Check to see whether the interface objects are already installed */
618 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
619 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SVGFESpotLightElement)) {
620 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
621 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
622 : }
623 :
624 : /*
625 : * The object might _still_ be null, but that's OK.
626 : *
627 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
628 : * traced by TraceProtoAndIfaceCache() and its contents are never
629 : * changed after they have been set.
630 : *
631 : * Calling address() avoids the read read barrier that does gray
632 : * unmarking, but it's not possible for the object to be gray here.
633 : */
634 :
635 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SVGFESpotLightElement);
636 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
637 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
638 : }
639 :
640 : JSObject*
641 0 : GetConstructorObject(JSContext* aCx)
642 : {
643 0 : return GetConstructorObjectHandle(aCx);
644 : }
645 :
646 : } // namespace SVGFESpotLightElementBinding
647 :
648 :
649 :
650 : } // namespace dom
651 : } // namespace mozilla
|