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