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