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