/work/obj-fuzz/dom/bindings/SVGFEMergeElementBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SVGFEMergeElement.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "SVGElementBinding.h" |
4 | | #include "SVGFEMergeElementBinding.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/SVGAnimatedString.h" |
12 | | #include "mozilla/dom/SVGFEMergeElement.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 SVGFEMergeElement_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_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFEMergeElement* self, JSJitGetterCallArgs args) |
29 | 0 | { |
30 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGFEMergeElement.x", DOM, cx); |
31 | 0 |
|
32 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->X())); |
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 x_getterinfo = { |
42 | | { (JSJitGetterOp)get_x }, |
43 | | { prototypes::id::SVGFEMergeElement }, |
44 | | { PrototypeTraits<prototypes::id::SVGFEMergeElement>::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_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFEMergeElement* self, JSJitGetterCallArgs args) |
61 | 0 | { |
62 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGFEMergeElement.y", DOM, cx); |
63 | 0 |
|
64 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Y())); |
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 y_getterinfo = { |
74 | | { (JSJitGetterOp)get_y }, |
75 | | { prototypes::id::SVGFEMergeElement }, |
76 | | { PrototypeTraits<prototypes::id::SVGFEMergeElement>::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_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFEMergeElement* self, JSJitGetterCallArgs args) |
93 | 0 | { |
94 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGFEMergeElement.width", DOM, cx); |
95 | 0 |
|
96 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Width())); |
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 width_getterinfo = { |
106 | | { (JSJitGetterOp)get_width }, |
107 | | { prototypes::id::SVGFEMergeElement }, |
108 | | { PrototypeTraits<prototypes::id::SVGFEMergeElement>::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_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFEMergeElement* self, JSJitGetterCallArgs args) |
125 | 0 | { |
126 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGFEMergeElement.height", DOM, cx); |
127 | 0 |
|
128 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Height())); |
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 height_getterinfo = { |
138 | | { (JSJitGetterOp)get_height }, |
139 | | { prototypes::id::SVGFEMergeElement }, |
140 | | { PrototypeTraits<prototypes::id::SVGFEMergeElement>::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_result(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGFEMergeElement* self, JSJitGetterCallArgs args) |
157 | 0 | { |
158 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGFEMergeElement.result", DOM, cx); |
159 | 0 |
|
160 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedString>(self->Result())); |
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 result_getterinfo = { |
170 | | { (JSJitGetterOp)get_result }, |
171 | | { prototypes::id::SVGFEMergeElement }, |
172 | | { PrototypeTraits<prototypes::id::SVGFEMergeElement>::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 | | static bool |
188 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
189 | 0 | { |
190 | 0 | mozilla::dom::SVGFEMergeElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGFEMergeElement>(obj); |
191 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
192 | 0 | // obviously can't preserve if we're not initialized. |
193 | 0 | if (self && self->GetWrapperPreserveColor()) { |
194 | 0 | PreserveWrapper(self); |
195 | 0 | } |
196 | 0 | return true; |
197 | 0 | } |
198 | | |
199 | | static void |
200 | | _finalize(js::FreeOp* fop, JSObject* obj) |
201 | 0 | { |
202 | 0 | mozilla::dom::SVGFEMergeElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGFEMergeElement>(obj); |
203 | 0 | if (self) { |
204 | 0 | ClearWrapper(self, self, obj); |
205 | 0 | AddForDeferredFinalization<mozilla::dom::SVGFEMergeElement>(self); |
206 | 0 | } |
207 | 0 | } |
208 | | |
209 | | static size_t |
210 | | _objectMoved(JSObject* obj, JSObject* old) |
211 | 0 | { |
212 | 0 | mozilla::dom::SVGFEMergeElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGFEMergeElement>(obj); |
213 | 0 | if (self) { |
214 | 0 | UpdateWrapper(self, self, obj, old); |
215 | 0 | } |
216 | 0 |
|
217 | 0 | return 0; |
218 | 0 | } |
219 | | |
220 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
221 | | #if defined(__clang__) |
222 | | #pragma clang diagnostic push |
223 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
224 | | #endif |
225 | | static const JSPropertySpec sAttributes_specs[] = { |
226 | | { "x", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &x_getterinfo, nullptr, nullptr }, |
227 | | { "y", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &y_getterinfo, nullptr, nullptr }, |
228 | | { "width", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &width_getterinfo, nullptr, nullptr }, |
229 | | { "height", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &height_getterinfo, nullptr, nullptr }, |
230 | | { "result", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &result_getterinfo, nullptr, nullptr }, |
231 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
232 | | }; |
233 | | #if defined(__clang__) |
234 | | #pragma clang diagnostic pop |
235 | | #endif |
236 | | |
237 | | |
238 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
239 | | { nullptr, &sAttributes_specs[0] }, |
240 | | { nullptr, nullptr } |
241 | | }; |
242 | | |
243 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
244 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
245 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
246 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
247 | | |
248 | | |
249 | | static uint16_t sNativeProperties_sortedPropertyIndices[5]; |
250 | | static PropertyInfo sNativeProperties_propertyInfos[5]; |
251 | | |
252 | | static const NativePropertiesN<1> sNativeProperties = { |
253 | | false, 0, |
254 | | false, 0, |
255 | | false, 0, |
256 | | true, 0 /* sAttributes */, |
257 | | false, 0, |
258 | | false, 0, |
259 | | false, 0, |
260 | | -1, |
261 | | 5, |
262 | | sNativeProperties_sortedPropertyIndices, |
263 | | { |
264 | | { sAttributes, &sNativeProperties_propertyInfos[0] } |
265 | | } |
266 | | }; |
267 | | static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
268 | | "We have a property info count that is oversized"); |
269 | | |
270 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
271 | | { |
272 | | "Function", |
273 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
274 | | &sBoringInterfaceObjectClassClassOps, |
275 | | JS_NULL_CLASS_SPEC, |
276 | | JS_NULL_CLASS_EXT, |
277 | | &sInterfaceObjectClassObjectOps |
278 | | }, |
279 | | eInterface, |
280 | | true, |
281 | | prototypes::id::SVGFEMergeElement, |
282 | | PrototypeTraits<prototypes::id::SVGFEMergeElement>::Depth, |
283 | | sNativePropertyHooks, |
284 | | "function SVGFEMergeElement() {\n [native code]\n}", |
285 | | SVGElement_Binding::GetConstructorObject |
286 | | }; |
287 | | |
288 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
289 | | { |
290 | | "SVGFEMergeElementPrototype", |
291 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
292 | | JS_NULL_CLASS_OPS, |
293 | | JS_NULL_CLASS_SPEC, |
294 | | JS_NULL_CLASS_EXT, |
295 | | JS_NULL_OBJECT_OPS |
296 | | }, |
297 | | eInterfacePrototype, |
298 | | false, |
299 | | prototypes::id::SVGFEMergeElement, |
300 | | PrototypeTraits<prototypes::id::SVGFEMergeElement>::Depth, |
301 | | sNativePropertyHooks, |
302 | | "[object SVGFEMergeElementPrototype]", |
303 | | SVGElement_Binding::GetProtoObject |
304 | | }; |
305 | | |
306 | | static const js::ClassOps sClassOps = { |
307 | | _addProperty, /* addProperty */ |
308 | | nullptr, /* delProperty */ |
309 | | nullptr, /* enumerate */ |
310 | | nullptr, /* newEnumerate */ |
311 | | nullptr, /* resolve */ |
312 | | nullptr, /* mayResolve */ |
313 | | _finalize, /* finalize */ |
314 | | nullptr, /* call */ |
315 | | nullptr, /* hasInstance */ |
316 | | nullptr, /* construct */ |
317 | | nullptr, /* trace */ |
318 | | }; |
319 | | |
320 | | static const js::ClassExtension sClassExtension = { |
321 | | nullptr, /* weakmapKeyDelegateOp */ |
322 | | _objectMoved /* objectMovedOp */ |
323 | | }; |
324 | | |
325 | | static const DOMJSClass sClass = { |
326 | | { "SVGFEMergeElement", |
327 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
328 | | &sClassOps, |
329 | | JS_NULL_CLASS_SPEC, |
330 | | &sClassExtension, |
331 | | JS_NULL_OBJECT_OPS |
332 | | }, |
333 | | { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::SVGElement, prototypes::id::SVGFEMergeElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
334 | | IsBaseOf<nsISupports, mozilla::dom::SVGFEMergeElement >::value, |
335 | | sNativePropertyHooks, |
336 | | FindAssociatedGlobalForNative<mozilla::dom::SVGFEMergeElement>::Get, |
337 | | GetProtoObjectHandle, |
338 | | GetCCParticipant<mozilla::dom::SVGFEMergeElement>::Get() |
339 | | }; |
340 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
341 | | "Must have the right minimal number of reserved slots."); |
342 | | static_assert(1 >= 1, |
343 | | "Must have enough reserved slots."); |
344 | | |
345 | | const JSClass* |
346 | | GetJSClass() |
347 | 0 | { |
348 | 0 | return sClass.ToJSClass(); |
349 | 0 | } |
350 | | |
351 | | bool |
352 | | Wrap(JSContext* aCx, mozilla::dom::SVGFEMergeElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
353 | 0 | { |
354 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGFEMergeElement>::value, |
355 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
356 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SVGFEMergeElement*>(aObject) == |
357 | 0 | reinterpret_cast<mozilla::dom::SVGFEMergeElement*>(aObject), |
358 | 0 | "Multiple inheritance for mozilla::dom::SVGFEMergeElement is broken."); |
359 | 0 | MOZ_ASSERT(static_cast<nsSVGElement*>(aObject) == |
360 | 0 | reinterpret_cast<nsSVGElement*>(aObject), |
361 | 0 | "Multiple inheritance for nsSVGElement is broken."); |
362 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) == |
363 | 0 | reinterpret_cast<mozilla::dom::Element*>(aObject), |
364 | 0 | "Multiple inheritance for mozilla::dom::Element is broken."); |
365 | 0 | MOZ_ASSERT(static_cast<nsINode*>(aObject) == |
366 | 0 | reinterpret_cast<nsINode*>(aObject), |
367 | 0 | "Multiple inheritance for nsINode is broken."); |
368 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
369 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
370 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
371 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
372 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
373 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
374 | 0 | "You should probably not be using Wrap() directly; use " |
375 | 0 | "GetOrCreateDOMReflector instead"); |
376 | 0 |
|
377 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
378 | 0 | "nsISupports must be on our primary inheritance chain"); |
379 | 0 |
|
380 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
381 | 0 | if (!global) { |
382 | 0 | return false; |
383 | 0 | } |
384 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
385 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
386 | 0 |
|
387 | 0 | // That might have ended up wrapping us already, due to the wonders |
388 | 0 | // of XBL. Check for that, and bail out as needed. |
389 | 0 | aReflector.set(aCache->GetWrapper()); |
390 | 0 | if (aReflector) { |
391 | | #ifdef DEBUG |
392 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
393 | | #endif // DEBUG |
394 | | return true; |
395 | 0 | } |
396 | 0 |
|
397 | 0 | JSAutoRealm ar(aCx, global); |
398 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
399 | 0 | if (!canonicalProto) { |
400 | 0 | return false; |
401 | 0 | } |
402 | 0 | JS::Rooted<JSObject*> proto(aCx); |
403 | 0 | if (aGivenProto) { |
404 | 0 | proto = aGivenProto; |
405 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
406 | 0 | // coming in, we changed compartments to that of "parent" so may need |
407 | 0 | // to wrap the proto here. |
408 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
409 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
410 | 0 | return false; |
411 | 0 | } |
412 | 0 | } |
413 | 0 | } else { |
414 | 0 | proto = canonicalProto; |
415 | 0 | } |
416 | 0 |
|
417 | 0 | BindingJSObjectCreator<mozilla::dom::SVGFEMergeElement> creator(aCx); |
418 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
419 | 0 | if (!aReflector) { |
420 | 0 | return false; |
421 | 0 | } |
422 | 0 | |
423 | 0 | aCache->SetWrapper(aReflector); |
424 | 0 | creator.InitializationSucceeded(); |
425 | 0 |
|
426 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
427 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
428 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
429 | 0 | // otherwise we won't be able to properly recreate it later, since |
430 | 0 | // we won't know what proto to use. Note that we don't check |
431 | 0 | // aGivenProto here, since it's entirely possible (and even |
432 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
433 | 0 | // same as canonicalProto. |
434 | 0 | if (proto != canonicalProto) { |
435 | 0 | PreserveWrapper(aObject); |
436 | 0 | } |
437 | 0 |
|
438 | 0 | return true; |
439 | 0 | } |
440 | | |
441 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
442 | | nullptr, |
443 | | nullptr, |
444 | | nullptr, |
445 | | { sNativeProperties.Upcast(), nullptr }, |
446 | | prototypes::id::SVGFEMergeElement, |
447 | | constructors::id::SVGFEMergeElement, |
448 | | SVGElement_Binding::sNativePropertyHooks, |
449 | | &DefaultXrayExpandoObjectClass |
450 | | } }; |
451 | | |
452 | | void |
453 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
454 | 0 | { |
455 | 0 | JS::Handle<JSObject*> parentProto(SVGElement_Binding::GetProtoObjectHandle(aCx)); |
456 | 0 | if (!parentProto) { |
457 | 0 | return; |
458 | 0 | } |
459 | 0 | |
460 | 0 | JS::Handle<JSObject*> constructorProto(SVGElement_Binding::GetConstructorObjectHandle(aCx)); |
461 | 0 | if (!constructorProto) { |
462 | 0 | return; |
463 | 0 | } |
464 | 0 | |
465 | 0 | static bool sIdsInited = false; |
466 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
467 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
468 | 0 | return; |
469 | 0 | } |
470 | 0 | sIdsInited = true; |
471 | 0 | } |
472 | 0 |
|
473 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGFEMergeElement); |
474 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGFEMergeElement); |
475 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
476 | 0 | &sPrototypeClass.mBase, protoCache, |
477 | 0 | nullptr, |
478 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
479 | 0 | interfaceCache, |
480 | 0 | sNativeProperties.Upcast(), |
481 | 0 | nullptr, |
482 | 0 | "SVGFEMergeElement", aDefineOnGlobal, |
483 | 0 | nullptr, |
484 | 0 | false); |
485 | 0 | } |
486 | | |
487 | | JSObject* |
488 | | GetConstructorObject(JSContext* aCx) |
489 | 0 | { |
490 | 0 | return GetConstructorObjectHandle(aCx); |
491 | 0 | } |
492 | | |
493 | | } // namespace SVGFEMergeElement_Binding |
494 | | |
495 | | |
496 | | |
497 | | } // namespace dom |
498 | | } // namespace mozilla |