Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM SVGTransformList.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "DOMSVGTransformList.h"
4 : #include "SVGTransformListBinding.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/DOMJSProxyHandler.h"
10 : #include "mozilla/dom/NonRefcountedDOMObject.h"
11 : #include "mozilla/dom/Nullable.h"
12 : #include "mozilla/dom/PrimitiveConversions.h"
13 : #include "mozilla/dom/SVGMatrix.h"
14 : #include "mozilla/dom/SVGTransform.h"
15 : #include "mozilla/dom/XrayExpandoClass.h"
16 : #include "nsISupports.h"
17 : #include "xpcjsid.h"
18 :
19 : namespace mozilla {
20 : namespace dom {
21 :
22 : namespace SVGTransformListBinding {
23 :
24 : static bool
25 0 : get_numberOfItems(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, JSJitGetterCallArgs args)
26 : {
27 0 : uint32_t result(self->NumberOfItems());
28 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
29 0 : args.rval().setNumber(result);
30 0 : return true;
31 : }
32 :
33 : static const JSJitInfo numberOfItems_getterinfo = {
34 : { (JSJitGetterOp)get_numberOfItems },
35 : { prototypes::id::SVGTransformList },
36 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
37 : JSJitInfo::Getter,
38 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
39 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
40 : true, /* isInfallible. False in setters. */
41 : false, /* isMovable. Not relevant for setters. */
42 : false, /* isEliminatable. Not relevant for setters. */
43 : false, /* isAlwaysInSlot. Only relevant for getters. */
44 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
45 : false, /* isTypedMethod. Only relevant for methods. */
46 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
47 : };
48 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
49 : static_assert(0 < 1, "There is no slot for us");
50 :
51 : static bool
52 0 : clear(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
53 : {
54 0 : binding_detail::FastErrorResult rv;
55 0 : self->Clear(rv);
56 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
57 0 : return false;
58 : }
59 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
60 0 : args.rval().setUndefined();
61 0 : return true;
62 : }
63 :
64 : static const JSJitInfo clear_methodinfo = {
65 : { (JSJitGetterOp)clear },
66 : { prototypes::id::SVGTransformList },
67 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
68 : JSJitInfo::Method,
69 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
70 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
71 : false, /* isInfallible. False in setters. */
72 : false, /* isMovable. Not relevant for setters. */
73 : false, /* isEliminatable. Not relevant for setters. */
74 : false, /* isAlwaysInSlot. Only relevant for getters. */
75 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
76 : false, /* isTypedMethod. Only relevant for methods. */
77 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
78 : };
79 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
80 : static_assert(0 < 1, "There is no slot for us");
81 :
82 : static bool
83 0 : initialize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
84 : {
85 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
86 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.initialize");
87 : }
88 0 : NonNull<mozilla::dom::SVGTransform> arg0;
89 0 : if (args[0].isObject()) {
90 : {
91 0 : nsresult rv = UnwrapObject<prototypes::id::SVGTransform, mozilla::dom::SVGTransform>(args[0], arg0);
92 0 : if (NS_FAILED(rv)) {
93 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGTransformList.initialize", "SVGTransform");
94 0 : return false;
95 : }
96 : }
97 : } else {
98 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGTransformList.initialize");
99 0 : return false;
100 : }
101 0 : binding_detail::FastErrorResult rv;
102 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->Initialize(NonNullHelper(arg0), rv)));
103 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
104 0 : return false;
105 : }
106 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
107 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
108 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
109 0 : return false;
110 : }
111 0 : return true;
112 : }
113 :
114 : static const JSJitInfo initialize_methodinfo = {
115 : { (JSJitGetterOp)initialize },
116 : { prototypes::id::SVGTransformList },
117 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
118 : JSJitInfo::Method,
119 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
120 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
121 : false, /* isInfallible. False in setters. */
122 : false, /* isMovable. Not relevant for setters. */
123 : false, /* isEliminatable. Not relevant for setters. */
124 : false, /* isAlwaysInSlot. Only relevant for getters. */
125 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
126 : false, /* isTypedMethod. Only relevant for methods. */
127 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
128 : };
129 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
130 : static_assert(0 < 1, "There is no slot for us");
131 :
132 : static bool
133 0 : getItem(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
134 : {
135 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
136 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.getItem");
137 : }
138 : uint32_t arg0;
139 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
140 0 : return false;
141 : }
142 0 : binding_detail::FastErrorResult rv;
143 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->GetItem(arg0, rv)));
144 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
145 0 : return false;
146 : }
147 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
148 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
149 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
150 0 : return false;
151 : }
152 0 : return true;
153 : }
154 :
155 : static const JSJitInfo getItem_methodinfo = {
156 : { (JSJitGetterOp)getItem },
157 : { prototypes::id::SVGTransformList },
158 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
159 : JSJitInfo::Method,
160 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
161 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
162 : false, /* isInfallible. False in setters. */
163 : false, /* isMovable. Not relevant for setters. */
164 : false, /* isEliminatable. Not relevant for setters. */
165 : false, /* isAlwaysInSlot. Only relevant for getters. */
166 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
167 : false, /* isTypedMethod. Only relevant for methods. */
168 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
169 : };
170 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
171 : static_assert(0 < 1, "There is no slot for us");
172 :
173 : static bool
174 0 : insertItemBefore(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
175 : {
176 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
177 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.insertItemBefore");
178 : }
179 0 : NonNull<mozilla::dom::SVGTransform> arg0;
180 0 : if (args[0].isObject()) {
181 : {
182 0 : nsresult rv = UnwrapObject<prototypes::id::SVGTransform, mozilla::dom::SVGTransform>(args[0], arg0);
183 0 : if (NS_FAILED(rv)) {
184 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGTransformList.insertItemBefore", "SVGTransform");
185 0 : return false;
186 : }
187 : }
188 : } else {
189 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGTransformList.insertItemBefore");
190 0 : return false;
191 : }
192 : uint32_t arg1;
193 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
194 0 : return false;
195 : }
196 0 : binding_detail::FastErrorResult rv;
197 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->InsertItemBefore(NonNullHelper(arg0), arg1, rv)));
198 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
199 0 : return false;
200 : }
201 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
202 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
203 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
204 0 : return false;
205 : }
206 0 : return true;
207 : }
208 :
209 : static const JSJitInfo insertItemBefore_methodinfo = {
210 : { (JSJitGetterOp)insertItemBefore },
211 : { prototypes::id::SVGTransformList },
212 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
213 : JSJitInfo::Method,
214 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
215 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
216 : false, /* isInfallible. False in setters. */
217 : false, /* isMovable. Not relevant for setters. */
218 : false, /* isEliminatable. Not relevant for setters. */
219 : false, /* isAlwaysInSlot. Only relevant for getters. */
220 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
221 : false, /* isTypedMethod. Only relevant for methods. */
222 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
223 : };
224 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
225 : static_assert(0 < 1, "There is no slot for us");
226 :
227 : static bool
228 0 : replaceItem(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
229 : {
230 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
231 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.replaceItem");
232 : }
233 0 : NonNull<mozilla::dom::SVGTransform> arg0;
234 0 : if (args[0].isObject()) {
235 : {
236 0 : nsresult rv = UnwrapObject<prototypes::id::SVGTransform, mozilla::dom::SVGTransform>(args[0], arg0);
237 0 : if (NS_FAILED(rv)) {
238 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGTransformList.replaceItem", "SVGTransform");
239 0 : return false;
240 : }
241 : }
242 : } else {
243 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGTransformList.replaceItem");
244 0 : return false;
245 : }
246 : uint32_t arg1;
247 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
248 0 : return false;
249 : }
250 0 : binding_detail::FastErrorResult rv;
251 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->ReplaceItem(NonNullHelper(arg0), arg1, rv)));
252 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
253 0 : return false;
254 : }
255 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
256 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
257 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
258 0 : return false;
259 : }
260 0 : return true;
261 : }
262 :
263 : static const JSJitInfo replaceItem_methodinfo = {
264 : { (JSJitGetterOp)replaceItem },
265 : { prototypes::id::SVGTransformList },
266 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
267 : JSJitInfo::Method,
268 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
269 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
270 : false, /* isInfallible. False in setters. */
271 : false, /* isMovable. Not relevant for setters. */
272 : false, /* isEliminatable. Not relevant for setters. */
273 : false, /* isAlwaysInSlot. Only relevant for getters. */
274 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
275 : false, /* isTypedMethod. Only relevant for methods. */
276 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
277 : };
278 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
279 : static_assert(0 < 1, "There is no slot for us");
280 :
281 : static bool
282 0 : removeItem(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
283 : {
284 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
285 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.removeItem");
286 : }
287 : uint32_t arg0;
288 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
289 0 : return false;
290 : }
291 0 : binding_detail::FastErrorResult rv;
292 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->RemoveItem(arg0, rv)));
293 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
294 0 : return false;
295 : }
296 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
297 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
298 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
299 0 : return false;
300 : }
301 0 : return true;
302 : }
303 :
304 : static const JSJitInfo removeItem_methodinfo = {
305 : { (JSJitGetterOp)removeItem },
306 : { prototypes::id::SVGTransformList },
307 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
308 : JSJitInfo::Method,
309 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
310 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
311 : false, /* isInfallible. False in setters. */
312 : false, /* isMovable. Not relevant for setters. */
313 : false, /* isEliminatable. Not relevant for setters. */
314 : false, /* isAlwaysInSlot. Only relevant for getters. */
315 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
316 : false, /* isTypedMethod. Only relevant for methods. */
317 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
318 : };
319 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
320 : static_assert(0 < 1, "There is no slot for us");
321 :
322 : static bool
323 0 : appendItem(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
324 : {
325 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
326 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.appendItem");
327 : }
328 0 : NonNull<mozilla::dom::SVGTransform> arg0;
329 0 : if (args[0].isObject()) {
330 : {
331 0 : nsresult rv = UnwrapObject<prototypes::id::SVGTransform, mozilla::dom::SVGTransform>(args[0], arg0);
332 0 : if (NS_FAILED(rv)) {
333 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGTransformList.appendItem", "SVGTransform");
334 0 : return false;
335 : }
336 : }
337 : } else {
338 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGTransformList.appendItem");
339 0 : return false;
340 : }
341 0 : binding_detail::FastErrorResult rv;
342 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->AppendItem(NonNullHelper(arg0), rv)));
343 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
344 0 : return false;
345 : }
346 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
347 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
348 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
349 0 : return false;
350 : }
351 0 : return true;
352 : }
353 :
354 : static const JSJitInfo appendItem_methodinfo = {
355 : { (JSJitGetterOp)appendItem },
356 : { prototypes::id::SVGTransformList },
357 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
358 : JSJitInfo::Method,
359 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
360 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
361 : false, /* isInfallible. False in setters. */
362 : false, /* isMovable. Not relevant for setters. */
363 : false, /* isEliminatable. Not relevant for setters. */
364 : false, /* isAlwaysInSlot. Only relevant for getters. */
365 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
366 : false, /* isTypedMethod. Only relevant for methods. */
367 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
368 : };
369 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
370 : static_assert(0 < 1, "There is no slot for us");
371 :
372 : static bool
373 0 : createSVGTransformFromMatrix(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
374 : {
375 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
376 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGTransformList.createSVGTransformFromMatrix");
377 : }
378 0 : NonNull<mozilla::dom::SVGMatrix> arg0;
379 0 : if (args[0].isObject()) {
380 : {
381 0 : nsresult rv = UnwrapObject<prototypes::id::SVGMatrix, mozilla::dom::SVGMatrix>(args[0], arg0);
382 0 : if (NS_FAILED(rv)) {
383 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of SVGTransformList.createSVGTransformFromMatrix", "SVGMatrix");
384 0 : return false;
385 : }
386 : }
387 : } else {
388 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of SVGTransformList.createSVGTransformFromMatrix");
389 0 : return false;
390 : }
391 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->CreateSVGTransformFromMatrix(NonNullHelper(arg0))));
392 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
393 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
394 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
395 0 : return false;
396 : }
397 0 : return true;
398 : }
399 :
400 : static const JSJitInfo createSVGTransformFromMatrix_methodinfo = {
401 : { (JSJitGetterOp)createSVGTransformFromMatrix },
402 : { prototypes::id::SVGTransformList },
403 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
404 : JSJitInfo::Method,
405 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
406 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
407 : false, /* isInfallible. False in setters. */
408 : false, /* isMovable. Not relevant for setters. */
409 : false, /* isEliminatable. Not relevant for setters. */
410 : false, /* isAlwaysInSlot. Only relevant for getters. */
411 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
412 : false, /* isTypedMethod. Only relevant for methods. */
413 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
414 : };
415 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
416 : static_assert(0 < 1, "There is no slot for us");
417 :
418 : static bool
419 0 : consolidate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, const JSJitMethodCallArgs& args)
420 : {
421 0 : binding_detail::FastErrorResult rv;
422 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->Consolidate(rv)));
423 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
424 0 : return false;
425 : }
426 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
427 0 : if (!result) {
428 0 : args.rval().setNull();
429 0 : return true;
430 : }
431 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
432 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
433 0 : return false;
434 : }
435 0 : return true;
436 : }
437 :
438 : static const JSJitInfo consolidate_methodinfo = {
439 : { (JSJitGetterOp)consolidate },
440 : { prototypes::id::SVGTransformList },
441 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
442 : JSJitInfo::Method,
443 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
444 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
445 : false, /* isInfallible. False in setters. */
446 : false, /* isMovable. Not relevant for setters. */
447 : false, /* isEliminatable. Not relevant for setters. */
448 : false, /* isAlwaysInSlot. Only relevant for getters. */
449 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
450 : false, /* isTypedMethod. Only relevant for methods. */
451 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
452 : };
453 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
454 : static_assert(0 < 1, "There is no slot for us");
455 :
456 : static bool
457 0 : get_length(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGTransformList* self, JSJitGetterCallArgs args)
458 : {
459 0 : uint32_t result(self->Length());
460 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
461 0 : args.rval().setNumber(result);
462 0 : return true;
463 : }
464 :
465 : static const JSJitInfo length_getterinfo = {
466 : { (JSJitGetterOp)get_length },
467 : { prototypes::id::SVGTransformList },
468 : { PrototypeTraits<prototypes::id::SVGTransformList>::Depth },
469 : JSJitInfo::Getter,
470 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
471 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
472 : true, /* isInfallible. False in setters. */
473 : false, /* isMovable. Not relevant for setters. */
474 : false, /* isEliminatable. Not relevant for setters. */
475 : false, /* isAlwaysInSlot. Only relevant for getters. */
476 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
477 : false, /* isTypedMethod. Only relevant for methods. */
478 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
479 : };
480 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
481 : static_assert(0 < 1, "There is no slot for us");
482 :
483 : static void
484 0 : _objectMoved(JSObject* obj, const JSObject* old)
485 : {
486 0 : mozilla::DOMSVGTransformList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGTransformList>(obj);
487 0 : if (self) {
488 0 : UpdateWrapper(self, self, obj, old);
489 : }
490 0 : }
491 :
492 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
493 : #if defined(__clang__)
494 : #pragma clang diagnostic push
495 : #pragma clang diagnostic ignored "-Wmissing-braces"
496 : #endif
497 : static const JSFunctionSpec sMethods_specs[] = {
498 : JS_FNSPEC("clear", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&clear_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
499 : JS_FNSPEC("initialize", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&initialize_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
500 : JS_FNSPEC("getItem", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
501 : JS_FNSPEC("insertItemBefore", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&insertItemBefore_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
502 : JS_FNSPEC("replaceItem", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&replaceItem_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
503 : JS_FNSPEC("removeItem", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
504 : JS_FNSPEC("appendItem", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&appendItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
505 : JS_FNSPEC("createSVGTransformFromMatrix", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createSVGTransformFromMatrix_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
506 : JS_FNSPEC("consolidate", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&consolidate_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
507 : JS_FS_END,
508 : JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
509 : JS_FS_END,
510 : JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
511 : JS_FS_END
512 : };
513 : #if defined(__clang__)
514 : #pragma clang diagnostic pop
515 : #endif
516 :
517 : static PrefableDisablers sMethods_disablers10 = {
518 : true, false, 0, &WantsQueryInterface<mozilla::DOMSVGTransformList>::Enabled
519 : };
520 :
521 : // Can't be const because the pref-enabled boolean needs to be writable
522 : static Prefable<const JSFunctionSpec> sMethods[] = {
523 : { nullptr, &sMethods_specs[0] },
524 : { &sMethods_disablers10, &sMethods_specs[10] },
525 : { nullptr, &sMethods_specs[12] },
526 : { nullptr, nullptr }
527 : };
528 :
529 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
530 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
531 : static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
532 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
533 :
534 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
535 : #if defined(__clang__)
536 : #pragma clang diagnostic push
537 : #pragma clang diagnostic ignored "-Wmissing-braces"
538 : #endif
539 : static const JSPropertySpec sAttributes_specs[] = {
540 : { "numberOfItems", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &numberOfItems_getterinfo, nullptr, nullptr },
541 : { "length", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &length_getterinfo, nullptr, nullptr },
542 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
543 : };
544 : #if defined(__clang__)
545 : #pragma clang diagnostic pop
546 : #endif
547 :
548 :
549 : // Can't be const because the pref-enabled boolean needs to be writable
550 : static Prefable<const JSPropertySpec> sAttributes[] = {
551 : { nullptr, &sAttributes_specs[0] },
552 : { nullptr, nullptr }
553 : };
554 :
555 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
556 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
557 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
558 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
559 :
560 :
561 : static uint16_t sNativeProperties_sortedPropertyIndices[13];
562 : static PropertyInfo sNativeProperties_propertyInfos[13];
563 :
564 : static const NativePropertiesN<2> sNativeProperties = {
565 : false, 0,
566 : false, 0,
567 : true, 0 /* sMethods */,
568 : true, 1 /* sAttributes */,
569 : false, 0,
570 : false, 0,
571 : false, 0,
572 : -1,
573 : 13,
574 : sNativeProperties_sortedPropertyIndices,
575 : {
576 : { sMethods, &sNativeProperties_propertyInfos[0] },
577 : { sAttributes, &sNativeProperties_propertyInfos[11] }
578 : }
579 : };
580 : static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
581 : "We have a property info count that is oversized");
582 :
583 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
584 : {
585 : "Function",
586 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
587 : &sBoringInterfaceObjectClassClassOps,
588 : JS_NULL_CLASS_SPEC,
589 : JS_NULL_CLASS_EXT,
590 : &sInterfaceObjectClassObjectOps
591 : },
592 : eInterface,
593 : true,
594 : prototypes::id::SVGTransformList,
595 : PrototypeTraits<prototypes::id::SVGTransformList>::Depth,
596 : sNativePropertyHooks,
597 : "function SVGTransformList() {\n [native code]\n}",
598 : JS::GetRealmFunctionPrototype
599 : };
600 :
601 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
602 : {
603 : "SVGTransformListPrototype",
604 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
605 : JS_NULL_CLASS_OPS,
606 : JS_NULL_CLASS_SPEC,
607 : JS_NULL_CLASS_EXT,
608 : JS_NULL_OBJECT_OPS
609 : },
610 : eInterfacePrototype,
611 : false,
612 : prototypes::id::SVGTransformList,
613 : PrototypeTraits<prototypes::id::SVGTransformList>::Depth,
614 : sNativePropertyHooks,
615 : "[object SVGTransformListPrototype]",
616 : JS::GetRealmObjectPrototype
617 : };
618 :
619 : JSObject*
620 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
621 : {
622 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
623 : }
624 :
625 : static_assert(IsBaseOf<nsISupports, mozilla::DOMSVGTransformList >::value,
626 : "We don't support non-nsISupports native classes for "
627 : "proxy-based bindings yet");
628 :
629 :
630 : class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
631 : {
632 : public:
633 : explicit constexpr DOMProxyHandler()
634 : {
635 : }
636 :
637 : virtual bool
638 : getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
639 :
640 : virtual bool
641 : defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
642 :
643 : using mozilla::dom::DOMProxyHandler::defineProperty;
644 :
645 : virtual bool
646 : ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
647 :
648 : virtual bool
649 : hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
650 :
651 : virtual bool
652 : get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
653 :
654 : virtual const char*
655 : className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
656 :
657 : virtual bool
658 : finalizeInBackground(const JS::Value& priv) const override;
659 :
660 : virtual void
661 : finalize(JSFreeOp* fop, JSObject* proxy) const override;
662 :
663 : static const DOMProxyHandler*
664 : getInstance();
665 :
666 : virtual bool
667 : delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
668 :
669 : virtual bool
670 : getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
671 : };
672 :
673 : MOZ_ALWAYS_INLINE bool
674 0 : IsProxy(JSObject* obj)
675 : {
676 0 : return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
677 : }
678 :
679 : MOZ_ALWAYS_INLINE mozilla::DOMSVGTransformList*
680 0 : UnwrapProxy(JSObject* obj)
681 : {
682 0 : MOZ_ASSERT(js::IsProxy(obj));
683 0 : if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
684 0 : MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
685 0 : obj = js::UncheckedUnwrap(obj);
686 : }
687 0 : MOZ_ASSERT(IsProxy(obj));
688 0 : return static_cast<mozilla::DOMSVGTransformList*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
689 : }
690 :
691 : bool
692 0 : DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
693 : {
694 0 : bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
695 0 : uint32_t index = GetArrayIndexFromId(cx, id);
696 0 : if (IsArrayIndex(index)) {
697 0 : mozilla::DOMSVGTransformList* self = UnwrapProxy(proxy);
698 0 : bool found = false;
699 0 : binding_detail::FastErrorResult rv;
700 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->IndexedGetter(index, found, rv)));
701 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
702 0 : return false;
703 : }
704 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
705 :
706 0 : if (found) {
707 0 : if (!GetOrCreateDOMReflector(cx, result, desc.value())) {
708 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
709 0 : return false;
710 : }
711 0 : FillPropertyDescriptor(desc, proxy, true);
712 0 : return true;
713 : }
714 : }
715 :
716 0 : JS::Rooted<JSObject*> expando(cx);
717 0 : if (!isXray && (expando = GetExpandoObject(proxy))) {
718 0 : if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
719 0 : return false;
720 : }
721 0 : if (desc.object()) {
722 : // Pretend the property lives on the wrapper.
723 0 : desc.object().set(proxy);
724 0 : return true;
725 : }
726 : }
727 :
728 0 : desc.object().set(nullptr);
729 0 : return true;
730 : }
731 :
732 : bool
733 0 : DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
734 : {
735 0 : if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
736 0 : *defined = true;
737 0 : return opresult.failNoIndexedSetter();
738 : }
739 0 : return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
740 : }
741 :
742 :
743 : bool
744 0 : DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
745 : {
746 0 : bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
747 :
748 0 : uint32_t length = UnwrapProxy(proxy)->Length();
749 0 : MOZ_ASSERT(int32_t(length) >= 0);
750 0 : for (int32_t i = 0; i < int32_t(length); ++i) {
751 0 : if (!props.append(INT_TO_JSID(i))) {
752 0 : return false;
753 : }
754 : }
755 :
756 0 : JS::Rooted<JSObject*> expando(cx);
757 0 : if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
758 0 : !js::GetPropertyKeys(cx, expando, flags, &props)) {
759 0 : return false;
760 : }
761 :
762 0 : return true;
763 : }
764 :
765 : bool
766 0 : DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
767 : {
768 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
769 : "Should not have a XrayWrapper here");
770 :
771 0 : uint32_t index = GetArrayIndexFromId(cx, id);
772 0 : if (IsArrayIndex(index)) {
773 0 : bool found = false;
774 0 : mozilla::DOMSVGTransformList* self = UnwrapProxy(proxy);
775 0 : binding_detail::FastErrorResult rv;
776 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->IndexedGetter(index, found, rv)));
777 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
778 0 : return false;
779 : }
780 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
781 : (void)result;
782 :
783 0 : *bp = found;
784 0 : return true;
785 : }
786 :
787 :
788 0 : JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
789 0 : if (expando) {
790 0 : bool b = true;
791 0 : bool ok = JS_HasPropertyById(cx, expando, id, &b);
792 0 : *bp = !!b;
793 0 : if (!ok || *bp) {
794 0 : return ok;
795 : }
796 : }
797 :
798 0 : *bp = false;
799 0 : return true;
800 : }
801 :
802 : bool
803 0 : DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
804 : {
805 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
806 : "Should not have a XrayWrapper here");
807 :
808 0 : uint32_t index = GetArrayIndexFromId(cx, id);
809 0 : if (IsArrayIndex(index)) {
810 0 : mozilla::DOMSVGTransformList* self = UnwrapProxy(proxy);
811 0 : bool found = false;
812 0 : binding_detail::FastErrorResult rv;
813 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->IndexedGetter(index, found, rv)));
814 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
815 0 : return false;
816 : }
817 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
818 :
819 0 : if (found) {
820 0 : if (!GetOrCreateDOMReflector(cx, result, vp)) {
821 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
822 0 : return false;
823 : }
824 0 : return true;
825 : }
826 : // Even if we don't have this index, we don't forward the
827 : // get on to our expando object.
828 : } else {
829 : { // Scope for expando
830 0 : JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
831 0 : if (expando) {
832 : bool hasProp;
833 0 : if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
834 0 : return false;
835 : }
836 :
837 0 : if (hasProp) {
838 : // Forward the get to the expando object, but our receiver is whatever our
839 : // receiver is.
840 0 : return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
841 : }
842 : }
843 : }
844 : }
845 :
846 : bool foundOnPrototype;
847 0 : if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
848 0 : return false;
849 : }
850 :
851 0 : if (foundOnPrototype) {
852 0 : return true;
853 : }
854 :
855 0 : vp.setUndefined();
856 0 : return true;
857 : }
858 :
859 : const char*
860 0 : DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
861 : {
862 0 : return "SVGTransformList";
863 : }
864 :
865 : bool
866 0 : DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
867 : {
868 0 : return false;
869 : }
870 :
871 : void
872 0 : DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
873 : {
874 0 : mozilla::DOMSVGTransformList* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGTransformList>(proxy);
875 0 : if (self) {
876 0 : ClearWrapper(self, self, proxy);
877 0 : AddForDeferredFinalization<mozilla::DOMSVGTransformList>(self);
878 : }
879 0 : }
880 :
881 : const DOMProxyHandler*
882 0 : DOMProxyHandler::getInstance()
883 : {
884 : static const DOMProxyHandler instance;
885 0 : return &instance;
886 : }
887 :
888 : bool
889 0 : DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
890 : {
891 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
892 : "Should not have a XrayWrapper here");
893 :
894 0 : uint32_t index = GetArrayIndexFromId(cx, id);
895 0 : if (IsArrayIndex(index)) {
896 : bool deleteSucceeded;
897 0 : bool found = false;
898 0 : mozilla::DOMSVGTransformList* self = UnwrapProxy(proxy);
899 0 : binding_detail::FastErrorResult rv;
900 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->IndexedGetter(index, found, rv)));
901 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
902 0 : return false;
903 : }
904 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
905 : (void)result;
906 0 : deleteSucceeded = !found;
907 0 : return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
908 : }
909 :
910 0 : return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
911 : }
912 :
913 : bool
914 0 : DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
915 : {
916 0 : JS::Rooted<JS::Value> temp(cx);
917 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
918 : "Should not have a XrayWrapper here");
919 :
920 0 : mozilla::DOMSVGTransformList* self = UnwrapProxy(proxy);
921 0 : uint32_t length = self->Length();
922 : // Compute the end of the indices we'll get ourselves
923 0 : uint32_t ourEnd = std::max(begin, std::min(end, length));
924 :
925 0 : for (uint32_t index = begin; index < ourEnd; ++index) {
926 0 : bool found = false;
927 0 : binding_detail::FastErrorResult rv;
928 0 : auto result(StrongOrRawPtr<mozilla::dom::SVGTransform>(self->IndexedGetter(index, found, rv)));
929 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
930 0 : return false;
931 : }
932 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
933 :
934 0 : MOZ_ASSERT(found);
935 0 : if (!GetOrCreateDOMReflector(cx, result, &temp)) {
936 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
937 0 : return false;
938 : }
939 0 : if (!adder->append(cx, temp)) return false;
940 0 : continue;
941 : }
942 :
943 0 : if (end > ourEnd) {
944 0 : JS::Rooted<JSObject*> proto(cx);
945 0 : if (!js::GetObjectProto(cx, proxy, &proto)) {
946 0 : return false;
947 : }
948 0 : return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
949 : }
950 :
951 0 : return true;
952 : }
953 :
954 : static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
955 : _objectMoved
956 : );
957 :
958 : static const DOMJSClass sClass = {
959 : PROXY_CLASS_WITH_EXT("SVGTransformList",
960 : JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
961 : &sClassExtension),
962 : { prototypes::id::SVGTransformList, 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 },
963 : IsBaseOf<nsISupports, mozilla::DOMSVGTransformList >::value,
964 : sNativePropertyHooks,
965 : FindAssociatedGlobalForNative<mozilla::DOMSVGTransformList>::Get,
966 : GetProtoObjectHandle,
967 : GetCCParticipant<mozilla::DOMSVGTransformList>::Get()
968 : };
969 :
970 : bool
971 0 : Wrap(JSContext* aCx, mozilla::DOMSVGTransformList* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
972 : {
973 : MOZ_ASSERT(static_cast<mozilla::DOMSVGTransformList*>(aObject) ==
974 : reinterpret_cast<mozilla::DOMSVGTransformList*>(aObject),
975 : "Multiple inheritance for mozilla::DOMSVGTransformList is broken.");
976 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
977 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
978 0 : MOZ_ASSERT(!aCache->GetWrapper(),
979 : "You should probably not be using Wrap() directly; use "
980 : "GetOrCreateDOMReflector instead");
981 :
982 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
983 : "nsISupports must be on our primary inheritance chain");
984 :
985 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
986 0 : if (!global) {
987 0 : return false;
988 : }
989 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
990 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
991 :
992 : // That might have ended up wrapping us already, due to the wonders
993 : // of XBL. Check for that, and bail out as needed.
994 0 : aReflector.set(aCache->GetWrapper());
995 0 : if (aReflector) {
996 : #ifdef DEBUG
997 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
998 : #endif // DEBUG
999 0 : return true;
1000 : }
1001 :
1002 0 : JSAutoCompartment ac(aCx, global);
1003 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1004 0 : if (!canonicalProto) {
1005 0 : return false;
1006 : }
1007 0 : JS::Rooted<JSObject*> proto(aCx);
1008 0 : if (aGivenProto) {
1009 0 : proto = aGivenProto;
1010 : // Unfortunately, while aGivenProto was in the compartment of aCx
1011 : // coming in, we changed compartments to that of "parent" so may need
1012 : // to wrap the proto here.
1013 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1014 0 : if (!JS_WrapObject(aCx, &proto)) {
1015 0 : return false;
1016 : }
1017 : }
1018 : } else {
1019 0 : proto = canonicalProto;
1020 : }
1021 :
1022 0 : BindingJSObjectCreator<mozilla::DOMSVGTransformList> creator(aCx);
1023 0 : JS::Rooted<JS::Value> expandoValue(aCx, JS::UndefinedValue());
1024 0 : creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
1025 0 : proto, aObject, expandoValue, aReflector);
1026 0 : if (!aReflector) {
1027 0 : return false;
1028 : }
1029 :
1030 :
1031 0 : aCache->SetWrapper(aReflector);
1032 0 : creator.InitializationSucceeded();
1033 :
1034 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1035 : aCache->GetWrapperPreserveColor() == aReflector);
1036 : // If proto != canonicalProto, we have to preserve our wrapper;
1037 : // otherwise we won't be able to properly recreate it later, since
1038 : // we won't know what proto to use. Note that we don't check
1039 : // aGivenProto here, since it's entirely possible (and even
1040 : // somewhat common) to have a non-null aGivenProto which is the
1041 : // same as canonicalProto.
1042 0 : if (proto != canonicalProto) {
1043 0 : PreserveWrapper(aObject);
1044 : }
1045 :
1046 0 : return true;
1047 : }
1048 :
1049 : static bool
1050 0 : ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
1051 : {
1052 0 : return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
1053 : }
1054 :
1055 : static bool
1056 0 : EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
1057 : {
1058 0 : return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
1059 : }
1060 :
1061 : const NativePropertyHooks sNativePropertyHooks[] = { {
1062 : ResolveOwnProperty,
1063 : EnumerateOwnProperties,
1064 : nullptr,
1065 : { sNativeProperties.Upcast(), nullptr },
1066 : prototypes::id::SVGTransformList,
1067 : constructors::id::SVGTransformList,
1068 : nullptr,
1069 : &DefaultXrayExpandoObjectClass
1070 : } };
1071 :
1072 : void
1073 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1074 : {
1075 0 : JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
1076 0 : if (!parentProto) {
1077 0 : return;
1078 : }
1079 :
1080 0 : JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
1081 0 : if (!constructorProto) {
1082 0 : return;
1083 : }
1084 :
1085 : static bool sIdsInited = false;
1086 0 : if (!sIdsInited && NS_IsMainThread()) {
1087 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1088 0 : return;
1089 : }
1090 0 : sIdsInited = true;
1091 : }
1092 :
1093 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGTransformList);
1094 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGTransformList);
1095 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1096 : &sPrototypeClass.mBase, protoCache,
1097 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1098 : interfaceCache,
1099 : sNativeProperties.Upcast(),
1100 : nullptr,
1101 : "SVGTransformList", aDefineOnGlobal,
1102 : nullptr,
1103 0 : false);
1104 : }
1105 :
1106 : JS::Handle<JSObject*>
1107 0 : GetProtoObjectHandle(JSContext* aCx)
1108 : {
1109 : /* Get the interface prototype object for this class. This will create the
1110 : object as needed. */
1111 0 : bool aDefineOnGlobal = true;
1112 :
1113 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1114 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1115 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1116 0 : return nullptr;
1117 : }
1118 :
1119 : /* Check to see whether the interface objects are already installed */
1120 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1121 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SVGTransformList)) {
1122 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1123 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1124 : }
1125 :
1126 : /*
1127 : * The object might _still_ be null, but that's OK.
1128 : *
1129 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1130 : * traced by TraceProtoAndIfaceCache() and its contents are never
1131 : * changed after they have been set.
1132 : *
1133 : * Calling address() avoids the read read barrier that does gray
1134 : * unmarking, but it's not possible for the object to be gray here.
1135 : */
1136 :
1137 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SVGTransformList);
1138 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1139 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1140 : }
1141 :
1142 : JS::Handle<JSObject*>
1143 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1144 : {
1145 : /* Get the interface object for this class. This will create the object as
1146 : needed. */
1147 :
1148 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1149 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1150 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1151 0 : return nullptr;
1152 : }
1153 :
1154 : /* Check to see whether the interface objects are already installed */
1155 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1156 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SVGTransformList)) {
1157 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1158 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1159 : }
1160 :
1161 : /*
1162 : * The object might _still_ be null, but that's OK.
1163 : *
1164 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1165 : * traced by TraceProtoAndIfaceCache() and its contents are never
1166 : * changed after they have been set.
1167 : *
1168 : * Calling address() avoids the read read barrier that does gray
1169 : * unmarking, but it's not possible for the object to be gray here.
1170 : */
1171 :
1172 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SVGTransformList);
1173 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1174 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1175 : }
1176 :
1177 : JSObject*
1178 0 : GetConstructorObject(JSContext* aCx)
1179 : {
1180 0 : return GetConstructorObjectHandle(aCx);
1181 : }
1182 :
1183 : } // namespace SVGTransformListBinding
1184 :
1185 :
1186 :
1187 : } // namespace dom
1188 : } // namespace mozilla
|