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