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