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