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