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