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