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