/work/obj-fuzz/dom/bindings/SVGTransformBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SVGTransform.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "SVGTransformBinding.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/SVGTransform.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 SVGTransform_Binding { |
23 | | |
24 | | MOZ_CAN_RUN_SCRIPT static bool |
25 | | get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, JSJitGetterCallArgs args) |
26 | 0 | { |
27 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTransform.type", DOM, cx); |
28 | 0 |
|
29 | 0 | uint16_t result(self->Type()); |
30 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
31 | 0 | args.rval().setInt32(int32_t(result)); |
32 | 0 | return true; |
33 | 0 | } |
34 | | |
35 | | static const JSJitInfo type_getterinfo = { |
36 | | { (JSJitGetterOp)get_type }, |
37 | | { prototypes::id::SVGTransform }, |
38 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
39 | | JSJitInfo::Getter, |
40 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
41 | | JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */ |
42 | | true, /* isInfallible. False in setters. */ |
43 | | false, /* isMovable. Not relevant for setters. */ |
44 | | false, /* isEliminatable. Not relevant for setters. */ |
45 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
46 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
47 | | false, /* isTypedMethod. Only relevant for methods. */ |
48 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
49 | | }; |
50 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
51 | | static_assert(0 < 1, "There is no slot for us"); |
52 | | |
53 | | MOZ_CAN_RUN_SCRIPT static bool |
54 | | get_matrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, JSJitGetterCallArgs args) |
55 | 0 | { |
56 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTransform.matrix", DOM, cx); |
57 | 0 |
|
58 | 0 | auto result(StrongOrRawPtr<mozilla::dom::SVGMatrix>(self->GetMatrix())); |
59 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
60 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
61 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
62 | 0 | return false; |
63 | 0 | } |
64 | 0 | return true; |
65 | 0 | } |
66 | | |
67 | | static const JSJitInfo matrix_getterinfo = { |
68 | | { (JSJitGetterOp)get_matrix }, |
69 | | { prototypes::id::SVGTransform }, |
70 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
71 | | JSJitInfo::Getter, |
72 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
73 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
74 | | false, /* isInfallible. False in setters. */ |
75 | | false, /* isMovable. Not relevant for setters. */ |
76 | | false, /* isEliminatable. Not relevant for setters. */ |
77 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
78 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
79 | | false, /* isTypedMethod. Only relevant for methods. */ |
80 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
81 | | }; |
82 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
83 | | static_assert(0 < 1, "There is no slot for us"); |
84 | | |
85 | | MOZ_CAN_RUN_SCRIPT static bool |
86 | | get_angle(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, JSJitGetterCallArgs args) |
87 | 0 | { |
88 | 0 | AUTO_PROFILER_LABEL_FAST("get SVGTransform.angle", DOM, cx); |
89 | 0 |
|
90 | 0 | float result(self->Angle()); |
91 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
92 | 0 | args.rval().set(JS_NumberValue(double(result))); |
93 | 0 | return true; |
94 | 0 | } |
95 | | |
96 | | static const JSJitInfo angle_getterinfo = { |
97 | | { (JSJitGetterOp)get_angle }, |
98 | | { prototypes::id::SVGTransform }, |
99 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
100 | | JSJitInfo::Getter, |
101 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
102 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
103 | | true, /* isInfallible. False in setters. */ |
104 | | false, /* isMovable. Not relevant for setters. */ |
105 | | false, /* isEliminatable. Not relevant for setters. */ |
106 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
107 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
108 | | false, /* isTypedMethod. Only relevant for methods. */ |
109 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
110 | | }; |
111 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
112 | | static_assert(0 < 1, "There is no slot for us"); |
113 | | |
114 | | MOZ_CAN_RUN_SCRIPT static bool |
115 | | setMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, const JSJitMethodCallArgs& args) |
116 | 0 | { |
117 | 0 | AUTO_PROFILER_LABEL_FAST("SVGTransform.setMatrix", DOM, cx); |
118 | 0 |
|
119 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
120 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransform.setMatrix"); |
121 | 0 | } |
122 | 0 | NonNull<mozilla::dom::SVGMatrix> arg0; |
123 | 0 | if (args[0].isObject()) { |
124 | 0 | { |
125 | 0 | nsresult rv = UnwrapObject<prototypes::id::SVGMatrix, mozilla::dom::SVGMatrix>(args[0], arg0); |
126 | 0 | if (NS_FAILED(rv)) { |
127 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGTransform.setMatrix", "SVGMatrix"); |
128 | 0 | return false; |
129 | 0 | } |
130 | 0 | } |
131 | 0 | } else { |
132 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGTransform.setMatrix"); |
133 | 0 | return false; |
134 | 0 | } |
135 | 0 | FastErrorResult rv; |
136 | 0 | self->SetMatrix(MOZ_KnownLive(NonNullHelper(arg0)), rv); |
137 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
138 | 0 | return false; |
139 | 0 | } |
140 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
141 | 0 | args.rval().setUndefined(); |
142 | 0 | return true; |
143 | 0 | } |
144 | | |
145 | | static const JSJitInfo setMatrix_methodinfo = { |
146 | | { (JSJitGetterOp)setMatrix }, |
147 | | { prototypes::id::SVGTransform }, |
148 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
149 | | JSJitInfo::Method, |
150 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
151 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
152 | | false, /* isInfallible. False in setters. */ |
153 | | false, /* isMovable. Not relevant for setters. */ |
154 | | false, /* isEliminatable. Not relevant for setters. */ |
155 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
156 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
157 | | false, /* isTypedMethod. Only relevant for methods. */ |
158 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
159 | | }; |
160 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
161 | | static_assert(0 < 1, "There is no slot for us"); |
162 | | |
163 | | MOZ_CAN_RUN_SCRIPT static bool |
164 | | setTranslate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, const JSJitMethodCallArgs& args) |
165 | 0 | { |
166 | 0 | AUTO_PROFILER_LABEL_FAST("SVGTransform.setTranslate", DOM, cx); |
167 | 0 |
|
168 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
169 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransform.setTranslate"); |
170 | 0 | } |
171 | 0 | float arg0; |
172 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
173 | 0 | return false; |
174 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
175 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SVGTransform.setTranslate"); |
176 | 0 | return false; |
177 | 0 | } |
178 | 0 | float arg1; |
179 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
180 | 0 | return false; |
181 | 0 | } else if (!mozilla::IsFinite(arg1)) { |
182 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of SVGTransform.setTranslate"); |
183 | 0 | return false; |
184 | 0 | } |
185 | 0 | FastErrorResult rv; |
186 | 0 | self->SetTranslate(arg0, arg1, rv); |
187 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
188 | 0 | return false; |
189 | 0 | } |
190 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
191 | 0 | args.rval().setUndefined(); |
192 | 0 | return true; |
193 | 0 | } |
194 | | |
195 | | static const JSJitInfo setTranslate_methodinfo = { |
196 | | { (JSJitGetterOp)setTranslate }, |
197 | | { prototypes::id::SVGTransform }, |
198 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
199 | | JSJitInfo::Method, |
200 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
201 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
202 | | false, /* isInfallible. False in setters. */ |
203 | | false, /* isMovable. Not relevant for setters. */ |
204 | | false, /* isEliminatable. Not relevant for setters. */ |
205 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
206 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
207 | | false, /* isTypedMethod. Only relevant for methods. */ |
208 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
209 | | }; |
210 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
211 | | static_assert(0 < 1, "There is no slot for us"); |
212 | | |
213 | | MOZ_CAN_RUN_SCRIPT static bool |
214 | | setScale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, const JSJitMethodCallArgs& args) |
215 | 0 | { |
216 | 0 | AUTO_PROFILER_LABEL_FAST("SVGTransform.setScale", DOM, cx); |
217 | 0 |
|
218 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
219 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransform.setScale"); |
220 | 0 | } |
221 | 0 | float arg0; |
222 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
223 | 0 | return false; |
224 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
225 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SVGTransform.setScale"); |
226 | 0 | return false; |
227 | 0 | } |
228 | 0 | float arg1; |
229 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
230 | 0 | return false; |
231 | 0 | } else if (!mozilla::IsFinite(arg1)) { |
232 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of SVGTransform.setScale"); |
233 | 0 | return false; |
234 | 0 | } |
235 | 0 | FastErrorResult rv; |
236 | 0 | self->SetScale(arg0, arg1, rv); |
237 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
238 | 0 | return false; |
239 | 0 | } |
240 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
241 | 0 | args.rval().setUndefined(); |
242 | 0 | return true; |
243 | 0 | } |
244 | | |
245 | | static const JSJitInfo setScale_methodinfo = { |
246 | | { (JSJitGetterOp)setScale }, |
247 | | { prototypes::id::SVGTransform }, |
248 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
249 | | JSJitInfo::Method, |
250 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
251 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
252 | | false, /* isInfallible. False in setters. */ |
253 | | false, /* isMovable. Not relevant for setters. */ |
254 | | false, /* isEliminatable. Not relevant for setters. */ |
255 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
256 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
257 | | false, /* isTypedMethod. Only relevant for methods. */ |
258 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
259 | | }; |
260 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
261 | | static_assert(0 < 1, "There is no slot for us"); |
262 | | |
263 | | MOZ_CAN_RUN_SCRIPT static bool |
264 | | setRotate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, const JSJitMethodCallArgs& args) |
265 | 0 | { |
266 | 0 | AUTO_PROFILER_LABEL_FAST("SVGTransform.setRotate", DOM, cx); |
267 | 0 |
|
268 | 0 | if (MOZ_UNLIKELY(args.length() < 3)) { |
269 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransform.setRotate"); |
270 | 0 | } |
271 | 0 | float arg0; |
272 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
273 | 0 | return false; |
274 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
275 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SVGTransform.setRotate"); |
276 | 0 | return false; |
277 | 0 | } |
278 | 0 | float arg1; |
279 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) { |
280 | 0 | return false; |
281 | 0 | } else if (!mozilla::IsFinite(arg1)) { |
282 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of SVGTransform.setRotate"); |
283 | 0 | return false; |
284 | 0 | } |
285 | 0 | float arg2; |
286 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) { |
287 | 0 | return false; |
288 | 0 | } else if (!mozilla::IsFinite(arg2)) { |
289 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of SVGTransform.setRotate"); |
290 | 0 | return false; |
291 | 0 | } |
292 | 0 | FastErrorResult rv; |
293 | 0 | self->SetRotate(arg0, arg1, arg2, rv); |
294 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
295 | 0 | return false; |
296 | 0 | } |
297 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
298 | 0 | args.rval().setUndefined(); |
299 | 0 | return true; |
300 | 0 | } |
301 | | |
302 | | static const JSJitInfo setRotate_methodinfo = { |
303 | | { (JSJitGetterOp)setRotate }, |
304 | | { prototypes::id::SVGTransform }, |
305 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
306 | | JSJitInfo::Method, |
307 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
308 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
309 | | false, /* isInfallible. False in setters. */ |
310 | | false, /* isMovable. Not relevant for setters. */ |
311 | | false, /* isEliminatable. Not relevant for setters. */ |
312 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
313 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
314 | | false, /* isTypedMethod. Only relevant for methods. */ |
315 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
316 | | }; |
317 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
318 | | static_assert(0 < 1, "There is no slot for us"); |
319 | | |
320 | | MOZ_CAN_RUN_SCRIPT static bool |
321 | | setSkewX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, const JSJitMethodCallArgs& args) |
322 | 0 | { |
323 | 0 | AUTO_PROFILER_LABEL_FAST("SVGTransform.setSkewX", DOM, cx); |
324 | 0 |
|
325 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
326 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransform.setSkewX"); |
327 | 0 | } |
328 | 0 | float arg0; |
329 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
330 | 0 | return false; |
331 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
332 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SVGTransform.setSkewX"); |
333 | 0 | return false; |
334 | 0 | } |
335 | 0 | FastErrorResult rv; |
336 | 0 | self->SetSkewX(arg0, rv); |
337 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
338 | 0 | return false; |
339 | 0 | } |
340 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
341 | 0 | args.rval().setUndefined(); |
342 | 0 | return true; |
343 | 0 | } |
344 | | |
345 | | static const JSJitInfo setSkewX_methodinfo = { |
346 | | { (JSJitGetterOp)setSkewX }, |
347 | | { prototypes::id::SVGTransform }, |
348 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
349 | | JSJitInfo::Method, |
350 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
351 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
352 | | false, /* isInfallible. False in setters. */ |
353 | | false, /* isMovable. Not relevant for setters. */ |
354 | | false, /* isEliminatable. Not relevant for setters. */ |
355 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
356 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
357 | | false, /* isTypedMethod. Only relevant for methods. */ |
358 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
359 | | }; |
360 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
361 | | static_assert(0 < 1, "There is no slot for us"); |
362 | | |
363 | | MOZ_CAN_RUN_SCRIPT static bool |
364 | | setSkewY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGTransform* self, const JSJitMethodCallArgs& args) |
365 | 0 | { |
366 | 0 | AUTO_PROFILER_LABEL_FAST("SVGTransform.setSkewY", DOM, cx); |
367 | 0 |
|
368 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
369 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransform.setSkewY"); |
370 | 0 | } |
371 | 0 | float arg0; |
372 | 0 | if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) { |
373 | 0 | return false; |
374 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
375 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SVGTransform.setSkewY"); |
376 | 0 | return false; |
377 | 0 | } |
378 | 0 | FastErrorResult rv; |
379 | 0 | self->SetSkewY(arg0, rv); |
380 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
381 | 0 | return false; |
382 | 0 | } |
383 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
384 | 0 | args.rval().setUndefined(); |
385 | 0 | return true; |
386 | 0 | } |
387 | | |
388 | | static const JSJitInfo setSkewY_methodinfo = { |
389 | | { (JSJitGetterOp)setSkewY }, |
390 | | { prototypes::id::SVGTransform }, |
391 | | { PrototypeTraits<prototypes::id::SVGTransform>::Depth }, |
392 | | JSJitInfo::Method, |
393 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
394 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
395 | | false, /* isInfallible. False in setters. */ |
396 | | false, /* isMovable. Not relevant for setters. */ |
397 | | false, /* isEliminatable. Not relevant for setters. */ |
398 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
399 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
400 | | false, /* isTypedMethod. Only relevant for methods. */ |
401 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
402 | | }; |
403 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
404 | | static_assert(0 < 1, "There is no slot for us"); |
405 | | |
406 | | static bool |
407 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
408 | 0 | { |
409 | 0 | mozilla::dom::SVGTransform* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGTransform>(obj); |
410 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
411 | 0 | // obviously can't preserve if we're not initialized. |
412 | 0 | if (self && self->GetWrapperPreserveColor()) { |
413 | 0 | PreserveWrapper(self); |
414 | 0 | } |
415 | 0 | return true; |
416 | 0 | } |
417 | | |
418 | | static void |
419 | | _finalize(js::FreeOp* fop, JSObject* obj) |
420 | 0 | { |
421 | 0 | mozilla::dom::SVGTransform* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGTransform>(obj); |
422 | 0 | if (self) { |
423 | 0 | ClearWrapper(self, self, obj); |
424 | 0 | AddForDeferredFinalization<mozilla::dom::SVGTransform>(self); |
425 | 0 | } |
426 | 0 | } |
427 | | |
428 | | static size_t |
429 | | _objectMoved(JSObject* obj, JSObject* old) |
430 | 0 | { |
431 | 0 | mozilla::dom::SVGTransform* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGTransform>(obj); |
432 | 0 | if (self) { |
433 | 0 | UpdateWrapper(self, self, obj, old); |
434 | 0 | } |
435 | 0 |
|
436 | 0 | return 0; |
437 | 0 | } |
438 | | |
439 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
440 | | #if defined(__clang__) |
441 | | #pragma clang diagnostic push |
442 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
443 | | #endif |
444 | | static const JSFunctionSpec sMethods_specs[] = { |
445 | | JS_FNSPEC("setMatrix", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setMatrix_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
446 | | JS_FNSPEC("setTranslate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setTranslate_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
447 | | JS_FNSPEC("setScale", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setScale_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
448 | | JS_FNSPEC("setRotate", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setRotate_methodinfo), 3, JSPROP_ENUMERATE, nullptr), |
449 | | JS_FNSPEC("setSkewX", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setSkewX_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
450 | | JS_FNSPEC("setSkewY", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&setSkewY_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
451 | | JS_FS_END |
452 | | }; |
453 | | #if defined(__clang__) |
454 | | #pragma clang diagnostic pop |
455 | | #endif |
456 | | |
457 | | |
458 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
459 | | { nullptr, &sMethods_specs[0] }, |
460 | | { nullptr, nullptr } |
461 | | }; |
462 | | |
463 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
464 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
465 | | static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
466 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
467 | | |
468 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
469 | | #if defined(__clang__) |
470 | | #pragma clang diagnostic push |
471 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
472 | | #endif |
473 | | static const JSPropertySpec sAttributes_specs[] = { |
474 | | { "type", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &type_getterinfo, nullptr, nullptr }, |
475 | | { "matrix", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &matrix_getterinfo, nullptr, nullptr }, |
476 | | { "angle", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &angle_getterinfo, nullptr, nullptr }, |
477 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
478 | | }; |
479 | | #if defined(__clang__) |
480 | | #pragma clang diagnostic pop |
481 | | #endif |
482 | | |
483 | | |
484 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
485 | | { nullptr, &sAttributes_specs[0] }, |
486 | | { nullptr, nullptr } |
487 | | }; |
488 | | |
489 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
490 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
491 | | static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
492 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
493 | | |
494 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
495 | | #if defined(__clang__) |
496 | | #pragma clang diagnostic push |
497 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
498 | | #endif |
499 | | static const ConstantSpec sConstants_specs[] = { |
500 | | { "SVG_TRANSFORM_UNKNOWN", JS::Int32Value(0) }, |
501 | | { "SVG_TRANSFORM_MATRIX", JS::Int32Value(1) }, |
502 | | { "SVG_TRANSFORM_TRANSLATE", JS::Int32Value(2) }, |
503 | | { "SVG_TRANSFORM_SCALE", JS::Int32Value(3) }, |
504 | | { "SVG_TRANSFORM_ROTATE", JS::Int32Value(4) }, |
505 | | { "SVG_TRANSFORM_SKEWX", JS::Int32Value(5) }, |
506 | | { "SVG_TRANSFORM_SKEWY", JS::Int32Value(6) }, |
507 | | { 0, JS::UndefinedValue() } |
508 | | }; |
509 | | #if defined(__clang__) |
510 | | #pragma clang diagnostic pop |
511 | | #endif |
512 | | |
513 | | |
514 | | static const Prefable<const ConstantSpec> sConstants[] = { |
515 | | { nullptr, &sConstants_specs[0] }, |
516 | | { nullptr, nullptr } |
517 | | }; |
518 | | |
519 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
520 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
521 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
522 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
523 | | |
524 | | |
525 | | static uint16_t sNativeProperties_sortedPropertyIndices[16]; |
526 | | static PropertyInfo sNativeProperties_propertyInfos[16]; |
527 | | |
528 | | static const NativePropertiesN<3> sNativeProperties = { |
529 | | false, 0, |
530 | | false, 0, |
531 | | true, 0 /* sMethods */, |
532 | | true, 1 /* sAttributes */, |
533 | | false, 0, |
534 | | false, 0, |
535 | | true, 2 /* sConstants */, |
536 | | -1, |
537 | | 16, |
538 | | sNativeProperties_sortedPropertyIndices, |
539 | | { |
540 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
541 | | { sAttributes, &sNativeProperties_propertyInfos[6] }, |
542 | | { sConstants, &sNativeProperties_propertyInfos[9] } |
543 | | } |
544 | | }; |
545 | | static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
546 | | "We have a property info count that is oversized"); |
547 | | |
548 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
549 | | { |
550 | | "Function", |
551 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
552 | | &sBoringInterfaceObjectClassClassOps, |
553 | | JS_NULL_CLASS_SPEC, |
554 | | JS_NULL_CLASS_EXT, |
555 | | &sInterfaceObjectClassObjectOps |
556 | | }, |
557 | | eInterface, |
558 | | true, |
559 | | prototypes::id::SVGTransform, |
560 | | PrototypeTraits<prototypes::id::SVGTransform>::Depth, |
561 | | sNativePropertyHooks, |
562 | | "function SVGTransform() {\n [native code]\n}", |
563 | | JS::GetRealmFunctionPrototype |
564 | | }; |
565 | | |
566 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
567 | | { |
568 | | "SVGTransformPrototype", |
569 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
570 | | JS_NULL_CLASS_OPS, |
571 | | JS_NULL_CLASS_SPEC, |
572 | | JS_NULL_CLASS_EXT, |
573 | | JS_NULL_OBJECT_OPS |
574 | | }, |
575 | | eInterfacePrototype, |
576 | | false, |
577 | | prototypes::id::SVGTransform, |
578 | | PrototypeTraits<prototypes::id::SVGTransform>::Depth, |
579 | | sNativePropertyHooks, |
580 | | "[object SVGTransformPrototype]", |
581 | | JS::GetRealmObjectPrototype |
582 | | }; |
583 | | |
584 | | static const js::ClassOps sClassOps = { |
585 | | _addProperty, /* addProperty */ |
586 | | nullptr, /* delProperty */ |
587 | | nullptr, /* enumerate */ |
588 | | nullptr, /* newEnumerate */ |
589 | | nullptr, /* resolve */ |
590 | | nullptr, /* mayResolve */ |
591 | | _finalize, /* finalize */ |
592 | | nullptr, /* call */ |
593 | | nullptr, /* hasInstance */ |
594 | | nullptr, /* construct */ |
595 | | nullptr, /* trace */ |
596 | | }; |
597 | | |
598 | | static const js::ClassExtension sClassExtension = { |
599 | | nullptr, /* weakmapKeyDelegateOp */ |
600 | | _objectMoved /* objectMovedOp */ |
601 | | }; |
602 | | |
603 | | static const DOMJSClass sClass = { |
604 | | { "SVGTransform", |
605 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
606 | | &sClassOps, |
607 | | JS_NULL_CLASS_SPEC, |
608 | | &sClassExtension, |
609 | | JS_NULL_OBJECT_OPS |
610 | | }, |
611 | | { prototypes::id::SVGTransform, 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 }, |
612 | | IsBaseOf<nsISupports, mozilla::dom::SVGTransform >::value, |
613 | | sNativePropertyHooks, |
614 | | FindAssociatedGlobalForNative<mozilla::dom::SVGTransform>::Get, |
615 | | GetProtoObjectHandle, |
616 | | GetCCParticipant<mozilla::dom::SVGTransform>::Get() |
617 | | }; |
618 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
619 | | "Must have the right minimal number of reserved slots."); |
620 | | static_assert(1 >= 1, |
621 | | "Must have enough reserved slots."); |
622 | | |
623 | | const JSClass* |
624 | | GetJSClass() |
625 | 0 | { |
626 | 0 | return sClass.ToJSClass(); |
627 | 0 | } |
628 | | |
629 | | bool |
630 | | Wrap(JSContext* aCx, mozilla::dom::SVGTransform* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
631 | 0 | { |
632 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SVGTransform>::value, |
633 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
634 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SVGTransform*>(aObject) == |
635 | 0 | reinterpret_cast<mozilla::dom::SVGTransform*>(aObject), |
636 | 0 | "Multiple inheritance for mozilla::dom::SVGTransform is broken."); |
637 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
638 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
639 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
640 | 0 | "You should probably not be using Wrap() directly; use " |
641 | 0 | "GetOrCreateDOMReflector instead"); |
642 | 0 |
|
643 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
644 | 0 | "nsISupports must be on our primary inheritance chain"); |
645 | 0 |
|
646 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
647 | 0 | if (!global) { |
648 | 0 | return false; |
649 | 0 | } |
650 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
651 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
652 | 0 |
|
653 | 0 | // That might have ended up wrapping us already, due to the wonders |
654 | 0 | // of XBL. Check for that, and bail out as needed. |
655 | 0 | aReflector.set(aCache->GetWrapper()); |
656 | 0 | if (aReflector) { |
657 | | #ifdef DEBUG |
658 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
659 | | #endif // DEBUG |
660 | | return true; |
661 | 0 | } |
662 | 0 |
|
663 | 0 | JSAutoRealm ar(aCx, global); |
664 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
665 | 0 | if (!canonicalProto) { |
666 | 0 | return false; |
667 | 0 | } |
668 | 0 | JS::Rooted<JSObject*> proto(aCx); |
669 | 0 | if (aGivenProto) { |
670 | 0 | proto = aGivenProto; |
671 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
672 | 0 | // coming in, we changed compartments to that of "parent" so may need |
673 | 0 | // to wrap the proto here. |
674 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
675 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
676 | 0 | return false; |
677 | 0 | } |
678 | 0 | } |
679 | 0 | } else { |
680 | 0 | proto = canonicalProto; |
681 | 0 | } |
682 | 0 |
|
683 | 0 | BindingJSObjectCreator<mozilla::dom::SVGTransform> creator(aCx); |
684 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
685 | 0 | if (!aReflector) { |
686 | 0 | return false; |
687 | 0 | } |
688 | 0 | |
689 | 0 | aCache->SetWrapper(aReflector); |
690 | 0 | creator.InitializationSucceeded(); |
691 | 0 |
|
692 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
693 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
694 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
695 | 0 | // otherwise we won't be able to properly recreate it later, since |
696 | 0 | // we won't know what proto to use. Note that we don't check |
697 | 0 | // aGivenProto here, since it's entirely possible (and even |
698 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
699 | 0 | // same as canonicalProto. |
700 | 0 | if (proto != canonicalProto) { |
701 | 0 | PreserveWrapper(aObject); |
702 | 0 | } |
703 | 0 |
|
704 | 0 | return true; |
705 | 0 | } |
706 | | |
707 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
708 | | nullptr, |
709 | | nullptr, |
710 | | nullptr, |
711 | | { sNativeProperties.Upcast(), nullptr }, |
712 | | prototypes::id::SVGTransform, |
713 | | constructors::id::SVGTransform, |
714 | | nullptr, |
715 | | &DefaultXrayExpandoObjectClass |
716 | | } }; |
717 | | |
718 | | void |
719 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
720 | 0 | { |
721 | 0 | JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx)); |
722 | 0 | if (!parentProto) { |
723 | 0 | return; |
724 | 0 | } |
725 | 0 | |
726 | 0 | JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx)); |
727 | 0 | if (!constructorProto) { |
728 | 0 | return; |
729 | 0 | } |
730 | 0 | |
731 | 0 | static bool sIdsInited = false; |
732 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
733 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
734 | 0 | return; |
735 | 0 | } |
736 | 0 | sIdsInited = true; |
737 | 0 | } |
738 | 0 |
|
739 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGTransform); |
740 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGTransform); |
741 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
742 | 0 | &sPrototypeClass.mBase, protoCache, |
743 | 0 | nullptr, |
744 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
745 | 0 | interfaceCache, |
746 | 0 | sNativeProperties.Upcast(), |
747 | 0 | nullptr, |
748 | 0 | "SVGTransform", aDefineOnGlobal, |
749 | 0 | nullptr, |
750 | 0 | false); |
751 | 0 | } |
752 | | |
753 | | JSObject* |
754 | | GetConstructorObject(JSContext* aCx) |
755 | 0 | { |
756 | 0 | return GetConstructorObjectHandle(aCx); |
757 | 0 | } |
758 | | |
759 | | } // namespace SVGTransform_Binding |
760 | | |
761 | | |
762 | | |
763 | | } // namespace dom |
764 | | } // namespace mozilla |