/work/obj-fuzz/dom/bindings/SVGPreserveAspectRatioBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SVGPreserveAspectRatio.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "SVGPreserveAspectRatio.h" |
4 | | #include "SVGPreserveAspectRatioBinding.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/PrimitiveConversions.h" |
11 | | #include "mozilla/dom/XrayExpandoClass.h" |
12 | | |
13 | | namespace mozilla { |
14 | | namespace dom { |
15 | | |
16 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
17 | | using namespace mozilla::dom::binding_detail; |
18 | | |
19 | | |
20 | | namespace SVGPreserveAspectRatio_Binding { |
21 | | |
22 | | MOZ_CAN_RUN_SCRIPT static bool |
23 | | get_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMSVGPreserveAspectRatio* self, JSJitGetterCallArgs args) |
24 | 0 | { |
25 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGPreserveAspectRatio.align", DOM, cx); |
26 | 0 |
|
27 | 0 | uint16_t result(self->Align()); |
28 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
29 | 0 | args.rval().setInt32(int32_t(result)); |
30 | 0 | return true; |
31 | 0 | } |
32 | | |
33 | | MOZ_CAN_RUN_SCRIPT static bool |
34 | | set_align(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMSVGPreserveAspectRatio* self, JSJitSetterCallArgs args) |
35 | 0 | { |
36 | 0 | AUTO_PROFILER_LABEL_FAST("set SVGPreserveAspectRatio.align", DOM, cx); |
37 | 0 |
|
38 | 0 | uint16_t arg0; |
39 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) { |
40 | 0 | return false; |
41 | 0 | } |
42 | 0 | FastErrorResult rv; |
43 | 0 | self->SetAlign(arg0, rv); |
44 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
45 | 0 | return false; |
46 | 0 | } |
47 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
48 | 0 |
|
49 | 0 | return true; |
50 | 0 | } |
51 | | |
52 | | static const JSJitInfo align_getterinfo = { |
53 | | { (JSJitGetterOp)get_align }, |
54 | | { prototypes::id::SVGPreserveAspectRatio }, |
55 | | { PrototypeTraits<prototypes::id::SVGPreserveAspectRatio>::Depth }, |
56 | | JSJitInfo::Getter, |
57 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
58 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
59 | | true, /* isInfallible. False in setters. */ |
60 | | false, /* isMovable. Not relevant for setters. */ |
61 | | false, /* isEliminatable. Not relevant for setters. */ |
62 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
63 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
64 | | false, /* isTypedMethod. Only relevant for methods. */ |
65 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
66 | | }; |
67 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
68 | | static_assert(0 < 1, "There is no slot for us"); |
69 | | static const JSJitInfo align_setterinfo = { |
70 | | { (JSJitGetterOp)set_align }, |
71 | | { prototypes::id::SVGPreserveAspectRatio }, |
72 | | { PrototypeTraits<prototypes::id::SVGPreserveAspectRatio>::Depth }, |
73 | | JSJitInfo::Setter, |
74 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
75 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
76 | | false, /* isInfallible. False in setters. */ |
77 | | false, /* isMovable. Not relevant for setters. */ |
78 | | false, /* isEliminatable. Not relevant for setters. */ |
79 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
80 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
81 | | false, /* isTypedMethod. Only relevant for methods. */ |
82 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
83 | | }; |
84 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
85 | | static_assert(0 < 1, "There is no slot for us"); |
86 | | |
87 | | MOZ_CAN_RUN_SCRIPT static bool |
88 | | get_meetOrSlice(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMSVGPreserveAspectRatio* self, JSJitGetterCallArgs args) |
89 | 0 | { |
90 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGPreserveAspectRatio.meetOrSlice", DOM, cx); |
91 | 0 |
|
92 | 0 | uint16_t result(self->MeetOrSlice()); |
93 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
94 | 0 | args.rval().setInt32(int32_t(result)); |
95 | 0 | return true; |
96 | 0 | } |
97 | | |
98 | | MOZ_CAN_RUN_SCRIPT static bool |
99 | | set_meetOrSlice(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMSVGPreserveAspectRatio* self, JSJitSetterCallArgs args) |
100 | 0 | { |
101 | 0 | AUTO_PROFILER_LABEL_FAST("set SVGPreserveAspectRatio.meetOrSlice", DOM, cx); |
102 | 0 |
|
103 | 0 | uint16_t arg0; |
104 | 0 | if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) { |
105 | 0 | return false; |
106 | 0 | } |
107 | 0 | FastErrorResult rv; |
108 | 0 | self->SetMeetOrSlice(arg0, rv); |
109 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
110 | 0 | return false; |
111 | 0 | } |
112 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
113 | 0 |
|
114 | 0 | return true; |
115 | 0 | } |
116 | | |
117 | | static const JSJitInfo meetOrSlice_getterinfo = { |
118 | | { (JSJitGetterOp)get_meetOrSlice }, |
119 | | { prototypes::id::SVGPreserveAspectRatio }, |
120 | | { PrototypeTraits<prototypes::id::SVGPreserveAspectRatio>::Depth }, |
121 | | JSJitInfo::Getter, |
122 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
123 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
124 | | true, /* isInfallible. False in setters. */ |
125 | | false, /* isMovable. Not relevant for setters. */ |
126 | | false, /* isEliminatable. Not relevant for setters. */ |
127 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
128 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
129 | | false, /* isTypedMethod. Only relevant for methods. */ |
130 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
131 | | }; |
132 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
133 | | static_assert(0 < 1, "There is no slot for us"); |
134 | | static const JSJitInfo meetOrSlice_setterinfo = { |
135 | | { (JSJitGetterOp)set_meetOrSlice }, |
136 | | { prototypes::id::SVGPreserveAspectRatio }, |
137 | | { PrototypeTraits<prototypes::id::SVGPreserveAspectRatio>::Depth }, |
138 | | JSJitInfo::Setter, |
139 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
140 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
141 | | false, /* isInfallible. False in setters. */ |
142 | | false, /* isMovable. Not relevant for setters. */ |
143 | | false, /* isEliminatable. Not relevant for setters. */ |
144 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
145 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
146 | | false, /* isTypedMethod. Only relevant for methods. */ |
147 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
148 | | }; |
149 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
150 | | static_assert(0 < 1, "There is no slot for us"); |
151 | | |
152 | | static bool |
153 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
154 | 0 | { |
155 | 0 | mozilla::dom::DOMSVGPreserveAspectRatio* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMSVGPreserveAspectRatio>(obj); |
156 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
157 | 0 | // obviously can't preserve if we're not initialized. |
158 | 0 | if (self && self->GetWrapperPreserveColor()) { |
159 | 0 | PreserveWrapper(self); |
160 | 0 | } |
161 | 0 | return true; |
162 | 0 | } |
163 | | |
164 | | static void |
165 | | _finalize(js::FreeOp* fop, JSObject* obj) |
166 | 0 | { |
167 | 0 | mozilla::dom::DOMSVGPreserveAspectRatio* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMSVGPreserveAspectRatio>(obj); |
168 | 0 | if (self) { |
169 | 0 | ClearWrapper(self, self, obj); |
170 | 0 | AddForDeferredFinalization<mozilla::dom::DOMSVGPreserveAspectRatio>(self); |
171 | 0 | } |
172 | 0 | } |
173 | | |
174 | | static size_t |
175 | | _objectMoved(JSObject* obj, JSObject* old) |
176 | 0 | { |
177 | 0 | mozilla::dom::DOMSVGPreserveAspectRatio* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMSVGPreserveAspectRatio>(obj); |
178 | 0 | if (self) { |
179 | 0 | UpdateWrapper(self, self, obj, old); |
180 | 0 | } |
181 | 0 |
|
182 | 0 | return 0; |
183 | 0 | } |
184 | | |
185 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
186 | | #if defined(__clang__) |
187 | | #pragma clang diagnostic push |
188 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
189 | | #endif |
190 | | static const JSPropertySpec sAttributes_specs[] = { |
191 | | { "align", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &align_getterinfo, GenericSetter<NormalThisPolicy>, &align_setterinfo }, |
192 | | { "meetOrSlice", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &meetOrSlice_getterinfo, GenericSetter<NormalThisPolicy>, &meetOrSlice_setterinfo }, |
193 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
194 | | }; |
195 | | #if defined(__clang__) |
196 | | #pragma clang diagnostic pop |
197 | | #endif |
198 | | |
199 | | |
200 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
201 | | { nullptr, &sAttributes_specs[0] }, |
202 | | { nullptr, nullptr } |
203 | | }; |
204 | | |
205 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
206 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
207 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
208 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
209 | | |
210 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
211 | | #if defined(__clang__) |
212 | | #pragma clang diagnostic push |
213 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
214 | | #endif |
215 | | static const ConstantSpec sConstants_specs[] = { |
216 | | { "SVG_PRESERVEASPECTRATIO_UNKNOWN", JS::Int32Value(0) }, |
217 | | { "SVG_PRESERVEASPECTRATIO_NONE", JS::Int32Value(1) }, |
218 | | { "SVG_PRESERVEASPECTRATIO_XMINYMIN", JS::Int32Value(2) }, |
219 | | { "SVG_PRESERVEASPECTRATIO_XMIDYMIN", JS::Int32Value(3) }, |
220 | | { "SVG_PRESERVEASPECTRATIO_XMAXYMIN", JS::Int32Value(4) }, |
221 | | { "SVG_PRESERVEASPECTRATIO_XMINYMID", JS::Int32Value(5) }, |
222 | | { "SVG_PRESERVEASPECTRATIO_XMIDYMID", JS::Int32Value(6) }, |
223 | | { "SVG_PRESERVEASPECTRATIO_XMAXYMID", JS::Int32Value(7) }, |
224 | | { "SVG_PRESERVEASPECTRATIO_XMINYMAX", JS::Int32Value(8) }, |
225 | | { "SVG_PRESERVEASPECTRATIO_XMIDYMAX", JS::Int32Value(9) }, |
226 | | { "SVG_PRESERVEASPECTRATIO_XMAXYMAX", JS::Int32Value(10) }, |
227 | | { "SVG_MEETORSLICE_UNKNOWN", JS::Int32Value(0) }, |
228 | | { "SVG_MEETORSLICE_MEET", JS::Int32Value(1) }, |
229 | | { "SVG_MEETORSLICE_SLICE", JS::Int32Value(2) }, |
230 | | { 0, JS::UndefinedValue() } |
231 | | }; |
232 | | #if defined(__clang__) |
233 | | #pragma clang diagnostic pop |
234 | | #endif |
235 | | |
236 | | |
237 | | static const Prefable<const ConstantSpec> sConstants[] = { |
238 | | { nullptr, &sConstants_specs[0] }, |
239 | | { nullptr, nullptr } |
240 | | }; |
241 | | |
242 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
243 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
244 | | static_assert(14 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
245 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
246 | | |
247 | | |
248 | | static uint16_t sNativeProperties_sortedPropertyIndices[16]; |
249 | | static PropertyInfo sNativeProperties_propertyInfos[16]; |
250 | | |
251 | | static const NativePropertiesN<2> sNativeProperties = { |
252 | | false, 0, |
253 | | false, 0, |
254 | | false, 0, |
255 | | true, 0 /* sAttributes */, |
256 | | false, 0, |
257 | | false, 0, |
258 | | true, 1 /* sConstants */, |
259 | | -1, |
260 | | 16, |
261 | | sNativeProperties_sortedPropertyIndices, |
262 | | { |
263 | | { sAttributes, &sNativeProperties_propertyInfos[0] }, |
264 | | { sConstants, &sNativeProperties_propertyInfos[2] } |
265 | | } |
266 | | }; |
267 | | static_assert(16 < 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::SVGPreserveAspectRatio, |
282 | | PrototypeTraits<prototypes::id::SVGPreserveAspectRatio>::Depth, |
283 | | sNativePropertyHooks, |
284 | | "function SVGPreserveAspectRatio() {\n [native code]\n}", |
285 | | JS::GetRealmFunctionPrototype |
286 | | }; |
287 | | |
288 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
289 | | { |
290 | | "SVGPreserveAspectRatioPrototype", |
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::SVGPreserveAspectRatio, |
300 | | PrototypeTraits<prototypes::id::SVGPreserveAspectRatio>::Depth, |
301 | | sNativePropertyHooks, |
302 | | "[object SVGPreserveAspectRatioPrototype]", |
303 | | JS::GetRealmObjectPrototype |
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 | | { "SVGPreserveAspectRatio", |
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::SVGPreserveAspectRatio, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
334 | | IsBaseOf<nsISupports, mozilla::dom::DOMSVGPreserveAspectRatio >::value, |
335 | | sNativePropertyHooks, |
336 | | FindAssociatedGlobalForNative<mozilla::dom::DOMSVGPreserveAspectRatio>::Get, |
337 | | GetProtoObjectHandle, |
338 | | GetCCParticipant<mozilla::dom::DOMSVGPreserveAspectRatio>::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::DOMSVGPreserveAspectRatio* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
353 | 0 | { |
354 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::DOMSVGPreserveAspectRatio>::value, |
355 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
356 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::DOMSVGPreserveAspectRatio*>(aObject) == |
357 | 0 | reinterpret_cast<mozilla::dom::DOMSVGPreserveAspectRatio*>(aObject), |
358 | 0 | "Multiple inheritance for mozilla::dom::DOMSVGPreserveAspectRatio is broken."); |
359 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
360 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
361 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
362 | 0 | "You should probably not be using Wrap() directly; use " |
363 | 0 | "GetOrCreateDOMReflector instead"); |
364 | 0 |
|
365 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
366 | 0 | "nsISupports must be on our primary inheritance chain"); |
367 | 0 |
|
368 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
369 | 0 | if (!global) { |
370 | 0 | return false; |
371 | 0 | } |
372 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
373 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
374 | 0 |
|
375 | 0 | // That might have ended up wrapping us already, due to the wonders |
376 | 0 | // of XBL. Check for that, and bail out as needed. |
377 | 0 | aReflector.set(aCache->GetWrapper()); |
378 | 0 | if (aReflector) { |
379 | | #ifdef DEBUG |
380 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
381 | | #endif // DEBUG |
382 | | return true; |
383 | 0 | } |
384 | 0 |
|
385 | 0 | JSAutoRealm ar(aCx, global); |
386 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
387 | 0 | if (!canonicalProto) { |
388 | 0 | return false; |
389 | 0 | } |
390 | 0 | JS::Rooted<JSObject*> proto(aCx); |
391 | 0 | if (aGivenProto) { |
392 | 0 | proto = aGivenProto; |
393 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
394 | 0 | // coming in, we changed compartments to that of "parent" so may need |
395 | 0 | // to wrap the proto here. |
396 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
397 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
398 | 0 | return false; |
399 | 0 | } |
400 | 0 | } |
401 | 0 | } else { |
402 | 0 | proto = canonicalProto; |
403 | 0 | } |
404 | 0 |
|
405 | 0 | BindingJSObjectCreator<mozilla::dom::DOMSVGPreserveAspectRatio> creator(aCx); |
406 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
407 | 0 | if (!aReflector) { |
408 | 0 | return false; |
409 | 0 | } |
410 | 0 | |
411 | 0 | aCache->SetWrapper(aReflector); |
412 | 0 | creator.InitializationSucceeded(); |
413 | 0 |
|
414 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
415 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
416 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
417 | 0 | // otherwise we won't be able to properly recreate it later, since |
418 | 0 | // we won't know what proto to use. Note that we don't check |
419 | 0 | // aGivenProto here, since it's entirely possible (and even |
420 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
421 | 0 | // same as canonicalProto. |
422 | 0 | if (proto != canonicalProto) { |
423 | 0 | PreserveWrapper(aObject); |
424 | 0 | } |
425 | 0 |
|
426 | 0 | return true; |
427 | 0 | } |
428 | | |
429 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
430 | | nullptr, |
431 | | nullptr, |
432 | | nullptr, |
433 | | { sNativeProperties.Upcast(), nullptr }, |
434 | | prototypes::id::SVGPreserveAspectRatio, |
435 | | constructors::id::SVGPreserveAspectRatio, |
436 | | nullptr, |
437 | | &DefaultXrayExpandoObjectClass |
438 | | } }; |
439 | | |
440 | | void |
441 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
442 | 0 | { |
443 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
444 | 0 | if (!parentProto) { |
445 | 0 | return; |
446 | 0 | } |
447 | 0 | |
448 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
449 | 0 | if (!constructorProto) { |
450 | 0 | return; |
451 | 0 | } |
452 | 0 | |
453 | 0 | static bool sIdsInited = false; |
454 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
455 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
456 | 0 | return; |
457 | 0 | } |
458 | 0 | sIdsInited = true; |
459 | 0 | } |
460 | 0 |
|
461 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGPreserveAspectRatio); |
462 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGPreserveAspectRatio); |
463 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
464 | 0 | &sPrototypeClass.mBase, protoCache, |
465 | 0 | nullptr, |
466 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
467 | 0 | interfaceCache, |
468 | 0 | sNativeProperties.Upcast(), |
469 | 0 | nullptr, |
470 | 0 | "SVGPreserveAspectRatio", aDefineOnGlobal, |
471 | 0 | nullptr, |
472 | 0 | false); |
473 | 0 | } |
474 | | |
475 | | JSObject* |
476 | | GetConstructorObject(JSContext* aCx) |
477 | 0 | { |
478 | 0 | return GetConstructorObjectHandle(aCx); |
479 | 0 | } |
480 | | |
481 | | } // namespace SVGPreserveAspectRatio_Binding |
482 | | |
483 | | |
484 | | |
485 | | } // namespace dom |
486 | | } // namespace mozilla |