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