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