Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM OfflineResourceList.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "EventHandlerBinding.h"
4 : #include "EventTargetBinding.h"
5 : #include "OfflineResourceListBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "mozilla/OwningNonNull.h"
8 : #include "mozilla/UseCounter.h"
9 : #include "mozilla/dom/BindingUtils.h"
10 : #include "mozilla/dom/DOMJSClass.h"
11 : #include "mozilla/dom/DOMJSProxyHandler.h"
12 : #include "mozilla/dom/DOMStringList.h"
13 : #include "mozilla/dom/NonRefcountedDOMObject.h"
14 : #include "mozilla/dom/Nullable.h"
15 : #include "mozilla/dom/PrimitiveConversions.h"
16 : #include "mozilla/dom/XrayExpandoClass.h"
17 : #include "nsDOMOfflineResourceList.h"
18 : #include "nsISupports.h"
19 : #include "xpcjsid.h"
20 :
21 : namespace mozilla {
22 : namespace dom {
23 :
24 : namespace OfflineResourceListBinding {
25 :
26 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
27 : "Can't inherit from an interface with a different ownership model.");
28 :
29 : static bool
30 0 : get_status(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
31 : {
32 0 : binding_detail::FastErrorResult rv;
33 0 : uint16_t result(self->GetStatus(rv));
34 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
35 0 : return false;
36 : }
37 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
38 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_status_getter);
39 0 : args.rval().setInt32(int32_t(result));
40 0 : return true;
41 : }
42 :
43 : static const JSJitInfo status_getterinfo = {
44 : { (JSJitGetterOp)get_status },
45 : { prototypes::id::OfflineResourceList },
46 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
47 : JSJitInfo::Getter,
48 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
49 : JSVAL_TYPE_INT32, /* returnType. Not relevant for setters. */
50 : false, /* isInfallible. False in setters. */
51 : false, /* isMovable. Not relevant for setters. */
52 : false, /* isEliminatable. Not relevant for setters. */
53 : false, /* isAlwaysInSlot. Only relevant for getters. */
54 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
55 : false, /* isTypedMethod. Only relevant for methods. */
56 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
57 : };
58 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
59 : static_assert(0 < 1, "There is no slot for us");
60 :
61 : static bool
62 0 : update(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, const JSJitMethodCallArgs& args)
63 : {
64 0 : binding_detail::FastErrorResult rv;
65 0 : self->Update(rv);
66 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
67 0 : return false;
68 : }
69 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
70 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_update);
71 0 : args.rval().setUndefined();
72 0 : return true;
73 : }
74 :
75 : static const JSJitInfo update_methodinfo = {
76 : { (JSJitGetterOp)update },
77 : { prototypes::id::OfflineResourceList },
78 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
79 : JSJitInfo::Method,
80 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
81 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
82 : false, /* isInfallible. False in setters. */
83 : false, /* isMovable. Not relevant for setters. */
84 : false, /* isEliminatable. Not relevant for setters. */
85 : false, /* isAlwaysInSlot. Only relevant for getters. */
86 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
87 : false, /* isTypedMethod. Only relevant for methods. */
88 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
89 : };
90 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
91 : static_assert(0 < 1, "There is no slot for us");
92 :
93 : static bool
94 0 : swapCache(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, const JSJitMethodCallArgs& args)
95 : {
96 0 : binding_detail::FastErrorResult rv;
97 0 : self->SwapCache(rv);
98 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
99 0 : return false;
100 : }
101 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
102 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_swapCache);
103 0 : args.rval().setUndefined();
104 0 : return true;
105 : }
106 :
107 : static const JSJitInfo swapCache_methodinfo = {
108 : { (JSJitGetterOp)swapCache },
109 : { prototypes::id::OfflineResourceList },
110 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
111 : JSJitInfo::Method,
112 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
113 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
114 : false, /* isInfallible. False in setters. */
115 : false, /* isMovable. Not relevant for setters. */
116 : false, /* isEliminatable. Not relevant for setters. */
117 : false, /* isAlwaysInSlot. Only relevant for getters. */
118 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
119 : false, /* isTypedMethod. Only relevant for methods. */
120 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
121 : };
122 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
123 : static_assert(0 < 1, "There is no slot for us");
124 :
125 : static bool
126 0 : get_onchecking(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
127 : {
128 0 : RefPtr<EventHandlerNonNull> result(self->GetOnchecking());
129 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
130 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onchecking_getter);
131 0 : if (result) {
132 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
133 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
134 0 : return false;
135 : }
136 0 : return true;
137 : } else {
138 0 : args.rval().setNull();
139 0 : return true;
140 : }
141 : }
142 :
143 : static bool
144 0 : set_onchecking(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
145 : {
146 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
147 0 : if (args[0].isObject()) {
148 : { // scope for tempRoot
149 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
150 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
151 : }
152 : } else {
153 0 : arg0 = nullptr;
154 : }
155 0 : self->SetOnchecking(Constify(arg0));
156 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
157 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onchecking_setter);
158 :
159 0 : return true;
160 : }
161 :
162 : static const JSJitInfo onchecking_getterinfo = {
163 : { (JSJitGetterOp)get_onchecking },
164 : { prototypes::id::OfflineResourceList },
165 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
166 : JSJitInfo::Getter,
167 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
168 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
169 : false, /* isInfallible. False in setters. */
170 : false, /* isMovable. Not relevant for setters. */
171 : false, /* isEliminatable. Not relevant for setters. */
172 : false, /* isAlwaysInSlot. Only relevant for getters. */
173 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
174 : false, /* isTypedMethod. Only relevant for methods. */
175 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
176 : };
177 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
178 : static_assert(0 < 1, "There is no slot for us");
179 : static const JSJitInfo onchecking_setterinfo = {
180 : { (JSJitGetterOp)set_onchecking },
181 : { prototypes::id::OfflineResourceList },
182 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
183 : JSJitInfo::Setter,
184 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
185 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
186 : false, /* isInfallible. False in setters. */
187 : false, /* isMovable. Not relevant for setters. */
188 : false, /* isEliminatable. Not relevant for setters. */
189 : false, /* isAlwaysInSlot. Only relevant for getters. */
190 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
191 : false, /* isTypedMethod. Only relevant for methods. */
192 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
193 : };
194 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
195 : static_assert(0 < 1, "There is no slot for us");
196 :
197 : static bool
198 0 : get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
199 : {
200 0 : RefPtr<EventHandlerNonNull> result(self->GetOnerror());
201 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
202 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onerror_getter);
203 0 : if (result) {
204 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
205 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
206 0 : return false;
207 : }
208 0 : return true;
209 : } else {
210 0 : args.rval().setNull();
211 0 : return true;
212 : }
213 : }
214 :
215 : static bool
216 0 : set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
217 : {
218 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
219 0 : if (args[0].isObject()) {
220 : { // scope for tempRoot
221 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
222 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
223 : }
224 : } else {
225 0 : arg0 = nullptr;
226 : }
227 0 : self->SetOnerror(Constify(arg0));
228 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
229 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onerror_setter);
230 :
231 0 : return true;
232 : }
233 :
234 : static const JSJitInfo onerror_getterinfo = {
235 : { (JSJitGetterOp)get_onerror },
236 : { prototypes::id::OfflineResourceList },
237 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
238 : JSJitInfo::Getter,
239 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
240 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
241 : false, /* isInfallible. False in setters. */
242 : false, /* isMovable. Not relevant for setters. */
243 : false, /* isEliminatable. Not relevant for setters. */
244 : false, /* isAlwaysInSlot. Only relevant for getters. */
245 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
246 : false, /* isTypedMethod. Only relevant for methods. */
247 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
248 : };
249 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
250 : static_assert(0 < 1, "There is no slot for us");
251 : static const JSJitInfo onerror_setterinfo = {
252 : { (JSJitGetterOp)set_onerror },
253 : { prototypes::id::OfflineResourceList },
254 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
255 : JSJitInfo::Setter,
256 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
257 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
258 : false, /* isInfallible. False in setters. */
259 : false, /* isMovable. Not relevant for setters. */
260 : false, /* isEliminatable. Not relevant for setters. */
261 : false, /* isAlwaysInSlot. Only relevant for getters. */
262 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
263 : false, /* isTypedMethod. Only relevant for methods. */
264 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
265 : };
266 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
267 : static_assert(0 < 1, "There is no slot for us");
268 :
269 : static bool
270 0 : get_onnoupdate(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
271 : {
272 0 : RefPtr<EventHandlerNonNull> result(self->GetOnnoupdate());
273 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
274 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onnoupdate_getter);
275 0 : if (result) {
276 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
277 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
278 0 : return false;
279 : }
280 0 : return true;
281 : } else {
282 0 : args.rval().setNull();
283 0 : return true;
284 : }
285 : }
286 :
287 : static bool
288 0 : set_onnoupdate(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
289 : {
290 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
291 0 : if (args[0].isObject()) {
292 : { // scope for tempRoot
293 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
294 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
295 : }
296 : } else {
297 0 : arg0 = nullptr;
298 : }
299 0 : self->SetOnnoupdate(Constify(arg0));
300 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
301 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onnoupdate_setter);
302 :
303 0 : return true;
304 : }
305 :
306 : static const JSJitInfo onnoupdate_getterinfo = {
307 : { (JSJitGetterOp)get_onnoupdate },
308 : { prototypes::id::OfflineResourceList },
309 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
310 : JSJitInfo::Getter,
311 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
312 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
313 : false, /* isInfallible. False in setters. */
314 : false, /* isMovable. Not relevant for setters. */
315 : false, /* isEliminatable. Not relevant for setters. */
316 : false, /* isAlwaysInSlot. Only relevant for getters. */
317 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
318 : false, /* isTypedMethod. Only relevant for methods. */
319 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
320 : };
321 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
322 : static_assert(0 < 1, "There is no slot for us");
323 : static const JSJitInfo onnoupdate_setterinfo = {
324 : { (JSJitGetterOp)set_onnoupdate },
325 : { prototypes::id::OfflineResourceList },
326 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
327 : JSJitInfo::Setter,
328 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
329 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
330 : false, /* isInfallible. False in setters. */
331 : false, /* isMovable. Not relevant for setters. */
332 : false, /* isEliminatable. Not relevant for setters. */
333 : false, /* isAlwaysInSlot. Only relevant for getters. */
334 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
335 : false, /* isTypedMethod. Only relevant for methods. */
336 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
337 : };
338 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
339 : static_assert(0 < 1, "There is no slot for us");
340 :
341 : static bool
342 0 : get_ondownloading(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
343 : {
344 0 : RefPtr<EventHandlerNonNull> result(self->GetOndownloading());
345 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
346 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_ondownloading_getter);
347 0 : if (result) {
348 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
349 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
350 0 : return false;
351 : }
352 0 : return true;
353 : } else {
354 0 : args.rval().setNull();
355 0 : return true;
356 : }
357 : }
358 :
359 : static bool
360 0 : set_ondownloading(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
361 : {
362 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
363 0 : if (args[0].isObject()) {
364 : { // scope for tempRoot
365 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
366 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
367 : }
368 : } else {
369 0 : arg0 = nullptr;
370 : }
371 0 : self->SetOndownloading(Constify(arg0));
372 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
373 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_ondownloading_setter);
374 :
375 0 : return true;
376 : }
377 :
378 : static const JSJitInfo ondownloading_getterinfo = {
379 : { (JSJitGetterOp)get_ondownloading },
380 : { prototypes::id::OfflineResourceList },
381 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
382 : JSJitInfo::Getter,
383 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
384 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
385 : false, /* isInfallible. False in setters. */
386 : false, /* isMovable. Not relevant for setters. */
387 : false, /* isEliminatable. Not relevant for setters. */
388 : false, /* isAlwaysInSlot. Only relevant for getters. */
389 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
390 : false, /* isTypedMethod. Only relevant for methods. */
391 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
392 : };
393 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
394 : static_assert(0 < 1, "There is no slot for us");
395 : static const JSJitInfo ondownloading_setterinfo = {
396 : { (JSJitGetterOp)set_ondownloading },
397 : { prototypes::id::OfflineResourceList },
398 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
399 : JSJitInfo::Setter,
400 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
401 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
402 : false, /* isInfallible. False in setters. */
403 : false, /* isMovable. Not relevant for setters. */
404 : false, /* isEliminatable. Not relevant for setters. */
405 : false, /* isAlwaysInSlot. Only relevant for getters. */
406 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
407 : false, /* isTypedMethod. Only relevant for methods. */
408 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
409 : };
410 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
411 : static_assert(0 < 1, "There is no slot for us");
412 :
413 : static bool
414 0 : get_onprogress(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
415 : {
416 0 : RefPtr<EventHandlerNonNull> result(self->GetOnprogress());
417 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
418 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onprogress_getter);
419 0 : if (result) {
420 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
421 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
422 0 : return false;
423 : }
424 0 : return true;
425 : } else {
426 0 : args.rval().setNull();
427 0 : return true;
428 : }
429 : }
430 :
431 : static bool
432 0 : set_onprogress(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
433 : {
434 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
435 0 : if (args[0].isObject()) {
436 : { // scope for tempRoot
437 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
438 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
439 : }
440 : } else {
441 0 : arg0 = nullptr;
442 : }
443 0 : self->SetOnprogress(Constify(arg0));
444 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
445 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onprogress_setter);
446 :
447 0 : return true;
448 : }
449 :
450 : static const JSJitInfo onprogress_getterinfo = {
451 : { (JSJitGetterOp)get_onprogress },
452 : { prototypes::id::OfflineResourceList },
453 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
454 : JSJitInfo::Getter,
455 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
456 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
457 : false, /* isInfallible. False in setters. */
458 : false, /* isMovable. Not relevant for setters. */
459 : false, /* isEliminatable. Not relevant for setters. */
460 : false, /* isAlwaysInSlot. Only relevant for getters. */
461 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
462 : false, /* isTypedMethod. Only relevant for methods. */
463 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
464 : };
465 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
466 : static_assert(0 < 1, "There is no slot for us");
467 : static const JSJitInfo onprogress_setterinfo = {
468 : { (JSJitGetterOp)set_onprogress },
469 : { prototypes::id::OfflineResourceList },
470 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
471 : JSJitInfo::Setter,
472 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
473 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
474 : false, /* isInfallible. False in setters. */
475 : false, /* isMovable. Not relevant for setters. */
476 : false, /* isEliminatable. Not relevant for setters. */
477 : false, /* isAlwaysInSlot. Only relevant for getters. */
478 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
479 : false, /* isTypedMethod. Only relevant for methods. */
480 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
481 : };
482 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
483 : static_assert(0 < 1, "There is no slot for us");
484 :
485 : static bool
486 0 : get_onupdateready(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
487 : {
488 0 : RefPtr<EventHandlerNonNull> result(self->GetOnupdateready());
489 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
490 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onupdateready_getter);
491 0 : if (result) {
492 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
493 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
494 0 : return false;
495 : }
496 0 : return true;
497 : } else {
498 0 : args.rval().setNull();
499 0 : return true;
500 : }
501 : }
502 :
503 : static bool
504 0 : set_onupdateready(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
505 : {
506 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
507 0 : if (args[0].isObject()) {
508 : { // scope for tempRoot
509 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
510 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
511 : }
512 : } else {
513 0 : arg0 = nullptr;
514 : }
515 0 : self->SetOnupdateready(Constify(arg0));
516 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
517 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onupdateready_setter);
518 :
519 0 : return true;
520 : }
521 :
522 : static const JSJitInfo onupdateready_getterinfo = {
523 : { (JSJitGetterOp)get_onupdateready },
524 : { prototypes::id::OfflineResourceList },
525 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
526 : JSJitInfo::Getter,
527 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
528 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
529 : false, /* isInfallible. False in setters. */
530 : false, /* isMovable. Not relevant for setters. */
531 : false, /* isEliminatable. Not relevant for setters. */
532 : false, /* isAlwaysInSlot. Only relevant for getters. */
533 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
534 : false, /* isTypedMethod. Only relevant for methods. */
535 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
536 : };
537 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
538 : static_assert(0 < 1, "There is no slot for us");
539 : static const JSJitInfo onupdateready_setterinfo = {
540 : { (JSJitGetterOp)set_onupdateready },
541 : { prototypes::id::OfflineResourceList },
542 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
543 : JSJitInfo::Setter,
544 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
545 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
546 : false, /* isInfallible. False in setters. */
547 : false, /* isMovable. Not relevant for setters. */
548 : false, /* isEliminatable. Not relevant for setters. */
549 : false, /* isAlwaysInSlot. Only relevant for getters. */
550 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
551 : false, /* isTypedMethod. Only relevant for methods. */
552 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
553 : };
554 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
555 : static_assert(0 < 1, "There is no slot for us");
556 :
557 : static bool
558 0 : get_oncached(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
559 : {
560 0 : RefPtr<EventHandlerNonNull> result(self->GetOncached());
561 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
562 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_oncached_getter);
563 0 : if (result) {
564 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
565 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
566 0 : return false;
567 : }
568 0 : return true;
569 : } else {
570 0 : args.rval().setNull();
571 0 : return true;
572 : }
573 : }
574 :
575 : static bool
576 0 : set_oncached(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
577 : {
578 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
579 0 : if (args[0].isObject()) {
580 : { // scope for tempRoot
581 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
582 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
583 : }
584 : } else {
585 0 : arg0 = nullptr;
586 : }
587 0 : self->SetOncached(Constify(arg0));
588 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
589 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_oncached_setter);
590 :
591 0 : return true;
592 : }
593 :
594 : static const JSJitInfo oncached_getterinfo = {
595 : { (JSJitGetterOp)get_oncached },
596 : { prototypes::id::OfflineResourceList },
597 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
598 : JSJitInfo::Getter,
599 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
600 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
601 : false, /* isInfallible. False in setters. */
602 : false, /* isMovable. Not relevant for setters. */
603 : false, /* isEliminatable. Not relevant for setters. */
604 : false, /* isAlwaysInSlot. Only relevant for getters. */
605 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
606 : false, /* isTypedMethod. Only relevant for methods. */
607 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
608 : };
609 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
610 : static_assert(0 < 1, "There is no slot for us");
611 : static const JSJitInfo oncached_setterinfo = {
612 : { (JSJitGetterOp)set_oncached },
613 : { prototypes::id::OfflineResourceList },
614 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
615 : JSJitInfo::Setter,
616 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
617 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
618 : false, /* isInfallible. False in setters. */
619 : false, /* isMovable. Not relevant for setters. */
620 : false, /* isEliminatable. Not relevant for setters. */
621 : false, /* isAlwaysInSlot. Only relevant for getters. */
622 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
623 : false, /* isTypedMethod. Only relevant for methods. */
624 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
625 : };
626 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
627 : static_assert(0 < 1, "There is no slot for us");
628 :
629 : static bool
630 0 : get_onobsolete(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
631 : {
632 0 : RefPtr<EventHandlerNonNull> result(self->GetOnobsolete());
633 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
634 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onobsolete_getter);
635 0 : if (result) {
636 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
637 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
638 0 : return false;
639 : }
640 0 : return true;
641 : } else {
642 0 : args.rval().setNull();
643 0 : return true;
644 : }
645 : }
646 :
647 : static bool
648 0 : set_onobsolete(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitSetterCallArgs args)
649 : {
650 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
651 0 : if (args[0].isObject()) {
652 : { // scope for tempRoot
653 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
654 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
655 : }
656 : } else {
657 0 : arg0 = nullptr;
658 : }
659 0 : self->SetOnobsolete(Constify(arg0));
660 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
661 0 : SetDocumentAndPageUseCounter(cx, obj, eUseCounter_OfflineResourceList_onobsolete_setter);
662 :
663 0 : return true;
664 : }
665 :
666 : static const JSJitInfo onobsolete_getterinfo = {
667 : { (JSJitGetterOp)get_onobsolete },
668 : { prototypes::id::OfflineResourceList },
669 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
670 : JSJitInfo::Getter,
671 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
672 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
673 : false, /* isInfallible. False in setters. */
674 : false, /* isMovable. Not relevant for setters. */
675 : false, /* isEliminatable. Not relevant for setters. */
676 : false, /* isAlwaysInSlot. Only relevant for getters. */
677 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
678 : false, /* isTypedMethod. Only relevant for methods. */
679 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
680 : };
681 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
682 : static_assert(0 < 1, "There is no slot for us");
683 : static const JSJitInfo onobsolete_setterinfo = {
684 : { (JSJitGetterOp)set_onobsolete },
685 : { prototypes::id::OfflineResourceList },
686 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
687 : JSJitInfo::Setter,
688 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
689 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
690 : false, /* isInfallible. False in setters. */
691 : false, /* isMovable. Not relevant for setters. */
692 : false, /* isEliminatable. Not relevant for setters. */
693 : false, /* isAlwaysInSlot. Only relevant for getters. */
694 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
695 : false, /* isTypedMethod. Only relevant for methods. */
696 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
697 : };
698 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
699 : static_assert(0 < 1, "There is no slot for us");
700 :
701 : static bool
702 0 : get_mozItems(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
703 : {
704 0 : binding_detail::FastErrorResult rv;
705 0 : auto result(StrongOrRawPtr<mozilla::dom::DOMStringList>(self->GetMozItems(rv)));
706 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
707 0 : return false;
708 : }
709 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
710 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
711 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
712 0 : return false;
713 : }
714 0 : return true;
715 : }
716 :
717 : static const JSJitInfo mozItems_getterinfo = {
718 : { (JSJitGetterOp)get_mozItems },
719 : { prototypes::id::OfflineResourceList },
720 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
721 : JSJitInfo::Getter,
722 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
723 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
724 : false, /* isInfallible. False in setters. */
725 : false, /* isMovable. Not relevant for setters. */
726 : false, /* isEliminatable. Not relevant for setters. */
727 : false, /* isAlwaysInSlot. Only relevant for getters. */
728 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
729 : false, /* isTypedMethod. Only relevant for methods. */
730 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
731 : };
732 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
733 : static_assert(0 < 1, "There is no slot for us");
734 :
735 : static bool
736 0 : mozHasItem(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, const JSJitMethodCallArgs& args)
737 : {
738 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
739 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OfflineResourceList.mozHasItem");
740 : }
741 0 : binding_detail::FakeString arg0;
742 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
743 0 : return false;
744 : }
745 0 : binding_detail::FastErrorResult rv;
746 0 : bool result(self->MozHasItem(NonNullHelper(Constify(arg0)), rv));
747 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
748 0 : return false;
749 : }
750 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
751 0 : args.rval().setBoolean(result);
752 0 : return true;
753 : }
754 :
755 : static const JSJitInfo mozHasItem_methodinfo = {
756 : { (JSJitGetterOp)mozHasItem },
757 : { prototypes::id::OfflineResourceList },
758 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
759 : JSJitInfo::Method,
760 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
761 : JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */
762 : false, /* isInfallible. False in setters. */
763 : false, /* isMovable. Not relevant for setters. */
764 : false, /* isEliminatable. Not relevant for setters. */
765 : false, /* isAlwaysInSlot. Only relevant for getters. */
766 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
767 : false, /* isTypedMethod. Only relevant for methods. */
768 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
769 : };
770 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
771 : static_assert(0 < 1, "There is no slot for us");
772 :
773 : static bool
774 0 : get_mozLength(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
775 : {
776 0 : binding_detail::FastErrorResult rv;
777 0 : uint32_t result(self->GetMozLength(rv));
778 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
779 0 : return false;
780 : }
781 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
782 0 : args.rval().setNumber(result);
783 0 : return true;
784 : }
785 :
786 : static const JSJitInfo mozLength_getterinfo = {
787 : { (JSJitGetterOp)get_mozLength },
788 : { prototypes::id::OfflineResourceList },
789 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
790 : JSJitInfo::Getter,
791 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
792 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
793 : false, /* isInfallible. False in setters. */
794 : false, /* isMovable. Not relevant for setters. */
795 : false, /* isEliminatable. Not relevant for setters. */
796 : false, /* isAlwaysInSlot. Only relevant for getters. */
797 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
798 : false, /* isTypedMethod. Only relevant for methods. */
799 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
800 : };
801 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
802 : static_assert(0 < 1, "There is no slot for us");
803 :
804 : static bool
805 0 : mozItem(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, const JSJitMethodCallArgs& args)
806 : {
807 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
808 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OfflineResourceList.mozItem");
809 : }
810 : uint32_t arg0;
811 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
812 0 : return false;
813 : }
814 0 : binding_detail::FastErrorResult rv;
815 0 : DOMString result;
816 0 : self->MozItem(arg0, result, rv);
817 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
818 0 : return false;
819 : }
820 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
821 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
822 0 : return false;
823 : }
824 0 : return true;
825 : }
826 :
827 : static const JSJitInfo mozItem_methodinfo = {
828 : { (JSJitGetterOp)mozItem },
829 : { prototypes::id::OfflineResourceList },
830 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
831 : JSJitInfo::Method,
832 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
833 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
834 : false, /* isInfallible. False in setters. */
835 : false, /* isMovable. Not relevant for setters. */
836 : false, /* isEliminatable. Not relevant for setters. */
837 : false, /* isAlwaysInSlot. Only relevant for getters. */
838 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
839 : false, /* isTypedMethod. Only relevant for methods. */
840 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
841 : };
842 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
843 : static_assert(0 < 1, "There is no slot for us");
844 :
845 : static bool
846 0 : get_length(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, JSJitGetterCallArgs args)
847 : {
848 0 : uint32_t result(self->Length());
849 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
850 0 : args.rval().setNumber(result);
851 0 : return true;
852 : }
853 :
854 : static const JSJitInfo length_getterinfo = {
855 : { (JSJitGetterOp)get_length },
856 : { prototypes::id::OfflineResourceList },
857 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
858 : JSJitInfo::Getter,
859 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
860 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
861 : true, /* isInfallible. False in setters. */
862 : false, /* isMovable. Not relevant for setters. */
863 : false, /* isEliminatable. Not relevant for setters. */
864 : false, /* isAlwaysInSlot. Only relevant for getters. */
865 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
866 : false, /* isTypedMethod. Only relevant for methods. */
867 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
868 : };
869 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
870 : static_assert(0 < 1, "There is no slot for us");
871 :
872 : static bool
873 0 : mozAdd(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, const JSJitMethodCallArgs& args)
874 : {
875 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
876 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OfflineResourceList.mozAdd");
877 : }
878 0 : binding_detail::FakeString arg0;
879 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
880 0 : return false;
881 : }
882 0 : binding_detail::FastErrorResult rv;
883 0 : self->MozAdd(NonNullHelper(Constify(arg0)), rv);
884 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
885 0 : return false;
886 : }
887 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
888 0 : args.rval().setUndefined();
889 0 : return true;
890 : }
891 :
892 : static const JSJitInfo mozAdd_methodinfo = {
893 : { (JSJitGetterOp)mozAdd },
894 : { prototypes::id::OfflineResourceList },
895 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
896 : JSJitInfo::Method,
897 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
898 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
899 : false, /* isInfallible. False in setters. */
900 : false, /* isMovable. Not relevant for setters. */
901 : false, /* isEliminatable. Not relevant for setters. */
902 : false, /* isAlwaysInSlot. Only relevant for getters. */
903 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
904 : false, /* isTypedMethod. Only relevant for methods. */
905 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
906 : };
907 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
908 : static_assert(0 < 1, "There is no slot for us");
909 :
910 : static bool
911 0 : mozRemove(JSContext* cx, JS::Handle<JSObject*> obj, nsDOMOfflineResourceList* self, const JSJitMethodCallArgs& args)
912 : {
913 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
914 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "OfflineResourceList.mozRemove");
915 : }
916 0 : binding_detail::FakeString arg0;
917 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
918 0 : return false;
919 : }
920 0 : binding_detail::FastErrorResult rv;
921 0 : self->MozRemove(NonNullHelper(Constify(arg0)), rv);
922 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
923 0 : return false;
924 : }
925 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
926 0 : args.rval().setUndefined();
927 0 : return true;
928 : }
929 :
930 : static const JSJitInfo mozRemove_methodinfo = {
931 : { (JSJitGetterOp)mozRemove },
932 : { prototypes::id::OfflineResourceList },
933 : { PrototypeTraits<prototypes::id::OfflineResourceList>::Depth },
934 : JSJitInfo::Method,
935 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
936 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
937 : false, /* isInfallible. False in setters. */
938 : false, /* isMovable. Not relevant for setters. */
939 : false, /* isEliminatable. Not relevant for setters. */
940 : false, /* isAlwaysInSlot. Only relevant for getters. */
941 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
942 : false, /* isTypedMethod. Only relevant for methods. */
943 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
944 : };
945 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
946 : static_assert(0 < 1, "There is no slot for us");
947 :
948 : static void
949 0 : _objectMoved(JSObject* obj, const JSObject* old)
950 : {
951 0 : nsDOMOfflineResourceList* self = UnwrapPossiblyNotInitializedDOMObject<nsDOMOfflineResourceList>(obj);
952 0 : if (self) {
953 0 : UpdateWrapper(self, self, obj, old);
954 : }
955 0 : }
956 :
957 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
958 : #if defined(__clang__)
959 : #pragma clang diagnostic push
960 : #pragma clang diagnostic ignored "-Wmissing-braces"
961 : #endif
962 : static const JSFunctionSpec sMethods_specs[] = {
963 : JS_FNSPEC("update", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&update_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
964 : JS_FNSPEC("swapCache", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&swapCache_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
965 : JS_FNSPEC("mozHasItem", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozHasItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
966 : JS_FNSPEC("mozItem", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozItem_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
967 : JS_FNSPEC("mozAdd", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozAdd_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
968 : JS_FNSPEC("mozRemove", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozRemove_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
969 : JS_FS_END,
970 : JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
971 : JS_FS_END,
972 : JS_SYM_FNSPEC(iterator, nullptr, nullptr, 0, 0, "ArrayValues"),
973 : JS_FS_END
974 : };
975 : #if defined(__clang__)
976 : #pragma clang diagnostic pop
977 : #endif
978 :
979 : static PrefableDisablers sMethods_disablers7 = {
980 : true, false, 0, &WantsQueryInterface<nsDOMOfflineResourceList>::Enabled
981 : };
982 :
983 : // Can't be const because the pref-enabled boolean needs to be writable
984 : static Prefable<const JSFunctionSpec> sMethods[] = {
985 : { nullptr, &sMethods_specs[0] },
986 : { &sMethods_disablers7, &sMethods_specs[7] },
987 : { nullptr, &sMethods_specs[9] },
988 : { nullptr, nullptr }
989 : };
990 :
991 : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
992 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
993 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
994 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
995 :
996 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
997 : #if defined(__clang__)
998 : #pragma clang diagnostic push
999 : #pragma clang diagnostic ignored "-Wmissing-braces"
1000 : #endif
1001 : static const JSPropertySpec sAttributes_specs[] = {
1002 : { "status", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &status_getterinfo, nullptr, nullptr },
1003 : { "onchecking", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onchecking_getterinfo, GenericBindingSetter, &onchecking_setterinfo },
1004 : { "onerror", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onerror_getterinfo, GenericBindingSetter, &onerror_setterinfo },
1005 : { "onnoupdate", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onnoupdate_getterinfo, GenericBindingSetter, &onnoupdate_setterinfo },
1006 : { "ondownloading", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ondownloading_getterinfo, GenericBindingSetter, &ondownloading_setterinfo },
1007 : { "onprogress", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onprogress_getterinfo, GenericBindingSetter, &onprogress_setterinfo },
1008 : { "onupdateready", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onupdateready_getterinfo, GenericBindingSetter, &onupdateready_setterinfo },
1009 : { "oncached", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &oncached_getterinfo, GenericBindingSetter, &oncached_setterinfo },
1010 : { "onobsolete", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onobsolete_getterinfo, GenericBindingSetter, &onobsolete_setterinfo },
1011 : { "mozItems", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozItems_getterinfo, nullptr, nullptr },
1012 : { "mozLength", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozLength_getterinfo, nullptr, nullptr },
1013 : { "length", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &length_getterinfo, nullptr, nullptr },
1014 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1015 : };
1016 : #if defined(__clang__)
1017 : #pragma clang diagnostic pop
1018 : #endif
1019 :
1020 :
1021 : // Can't be const because the pref-enabled boolean needs to be writable
1022 : static Prefable<const JSPropertySpec> sAttributes[] = {
1023 : { nullptr, &sAttributes_specs[0] },
1024 : { nullptr, nullptr }
1025 : };
1026 :
1027 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1028 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1029 : static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1030 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1031 :
1032 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1033 : #if defined(__clang__)
1034 : #pragma clang diagnostic push
1035 : #pragma clang diagnostic ignored "-Wmissing-braces"
1036 : #endif
1037 : static const ConstantSpec sConstants_specs[] = {
1038 : { "UNCACHED", JS::Int32Value(0) },
1039 : { "IDLE", JS::Int32Value(1) },
1040 : { "CHECKING", JS::Int32Value(2) },
1041 : { "DOWNLOADING", JS::Int32Value(3) },
1042 : { "UPDATEREADY", JS::Int32Value(4) },
1043 : { "OBSOLETE", JS::Int32Value(5) },
1044 : { 0, JS::UndefinedValue() }
1045 : };
1046 : #if defined(__clang__)
1047 : #pragma clang diagnostic pop
1048 : #endif
1049 :
1050 :
1051 : // Can't be const because the pref-enabled boolean needs to be writable
1052 : static Prefable<const ConstantSpec> sConstants[] = {
1053 : { nullptr, &sConstants_specs[0] },
1054 : { nullptr, nullptr }
1055 : };
1056 :
1057 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1058 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1059 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1060 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1061 :
1062 :
1063 : static uint16_t sNativeProperties_sortedPropertyIndices[26];
1064 : static PropertyInfo sNativeProperties_propertyInfos[26];
1065 :
1066 : static const NativePropertiesN<3> sNativeProperties = {
1067 : false, 0,
1068 : false, 0,
1069 : true, 0 /* sMethods */,
1070 : true, 1 /* sAttributes */,
1071 : false, 0,
1072 : false, 0,
1073 : true, 2 /* sConstants */,
1074 : -1,
1075 : 26,
1076 : sNativeProperties_sortedPropertyIndices,
1077 : {
1078 : { sMethods, &sNativeProperties_propertyInfos[0] },
1079 : { sAttributes, &sNativeProperties_propertyInfos[8] },
1080 : { sConstants, &sNativeProperties_propertyInfos[20] }
1081 : }
1082 : };
1083 : static_assert(26 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1084 : "We have a property info count that is oversized");
1085 :
1086 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1087 : {
1088 : "Function",
1089 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1090 : &sBoringInterfaceObjectClassClassOps,
1091 : JS_NULL_CLASS_SPEC,
1092 : JS_NULL_CLASS_EXT,
1093 : &sInterfaceObjectClassObjectOps
1094 : },
1095 : eInterface,
1096 : true,
1097 : prototypes::id::OfflineResourceList,
1098 : PrototypeTraits<prototypes::id::OfflineResourceList>::Depth,
1099 : sNativePropertyHooks,
1100 : "function OfflineResourceList() {\n [native code]\n}",
1101 : EventTargetBinding::GetConstructorObject
1102 : };
1103 :
1104 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1105 : {
1106 : "OfflineResourceListPrototype",
1107 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1108 : JS_NULL_CLASS_OPS,
1109 : JS_NULL_CLASS_SPEC,
1110 : JS_NULL_CLASS_EXT,
1111 : JS_NULL_OBJECT_OPS
1112 : },
1113 : eInterfacePrototype,
1114 : false,
1115 : prototypes::id::OfflineResourceList,
1116 : PrototypeTraits<prototypes::id::OfflineResourceList>::Depth,
1117 : sNativePropertyHooks,
1118 : "[object OfflineResourceListPrototype]",
1119 : EventTargetBinding::GetProtoObject
1120 : };
1121 :
1122 : JSObject*
1123 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1124 : {
1125 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1126 : }
1127 :
1128 : static_assert(IsBaseOf<nsISupports, nsDOMOfflineResourceList >::value,
1129 : "We don't support non-nsISupports native classes for "
1130 : "proxy-based bindings yet");
1131 :
1132 :
1133 : class DOMProxyHandler : public mozilla::dom::DOMProxyHandler
1134 : {
1135 : public:
1136 : explicit constexpr DOMProxyHandler()
1137 : {
1138 : }
1139 :
1140 : virtual bool
1141 : getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const override;
1142 :
1143 : virtual bool
1144 : defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const override;
1145 :
1146 : using mozilla::dom::DOMProxyHandler::defineProperty;
1147 :
1148 : virtual bool
1149 : ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const override;
1150 :
1151 : virtual bool
1152 : hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const override;
1153 :
1154 : virtual bool
1155 : get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const override;
1156 :
1157 : virtual const char*
1158 : className(JSContext* cx, JS::Handle<JSObject*> proxy) const override;
1159 :
1160 : virtual bool
1161 : finalizeInBackground(const JS::Value& priv) const override;
1162 :
1163 : virtual void
1164 : finalize(JSFreeOp* fop, JSObject* proxy) const override;
1165 :
1166 : static const DOMProxyHandler*
1167 : getInstance();
1168 :
1169 : virtual bool
1170 : delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const override;
1171 :
1172 : virtual bool
1173 : getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const override;
1174 : };
1175 :
1176 : MOZ_ALWAYS_INLINE bool
1177 0 : IsProxy(JSObject* obj)
1178 : {
1179 0 : return js::IsProxy(obj) && js::GetProxyHandler(obj) == DOMProxyHandler::getInstance();
1180 : }
1181 :
1182 : MOZ_ALWAYS_INLINE nsDOMOfflineResourceList*
1183 0 : UnwrapProxy(JSObject* obj)
1184 : {
1185 0 : MOZ_ASSERT(js::IsProxy(obj));
1186 0 : if (js::GetProxyHandler(obj) != DOMProxyHandler::getInstance()) {
1187 0 : MOZ_ASSERT(xpc::WrapperFactory::IsXrayWrapper(obj));
1188 0 : obj = js::UncheckedUnwrap(obj);
1189 : }
1190 0 : MOZ_ASSERT(IsProxy(obj));
1191 0 : return static_cast<nsDOMOfflineResourceList*>(js::GetProxyReservedSlot(obj, DOM_OBJECT_SLOT).toPrivate());
1192 : }
1193 :
1194 : bool
1195 0 : DOMProxyHandler::getOwnPropDescriptor(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool ignoreNamedProps, JS::MutableHandle<JS::PropertyDescriptor> desc) const
1196 : {
1197 0 : bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
1198 0 : uint32_t index = GetArrayIndexFromId(cx, id);
1199 0 : if (IsArrayIndex(index)) {
1200 0 : nsDOMOfflineResourceList* self = UnwrapProxy(proxy);
1201 0 : bool found = false;
1202 0 : binding_detail::FastErrorResult rv;
1203 0 : DOMString result;
1204 0 : self->IndexedGetter(index, found, result, rv);
1205 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1206 0 : return false;
1207 : }
1208 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1209 :
1210 0 : if (found) {
1211 0 : if (!xpc::NonVoidStringToJsval(cx, result, desc.value())) {
1212 0 : return false;
1213 : }
1214 0 : FillPropertyDescriptor(desc, proxy, true);
1215 0 : return true;
1216 : }
1217 : }
1218 :
1219 0 : JS::Rooted<JSObject*> expando(cx);
1220 0 : if (!isXray && (expando = GetExpandoObject(proxy))) {
1221 0 : if (!JS_GetOwnPropertyDescriptorById(cx, expando, id, desc)) {
1222 0 : return false;
1223 : }
1224 0 : if (desc.object()) {
1225 : // Pretend the property lives on the wrapper.
1226 0 : desc.object().set(proxy);
1227 0 : return true;
1228 : }
1229 : }
1230 :
1231 0 : desc.object().set(nullptr);
1232 0 : return true;
1233 : }
1234 :
1235 : bool
1236 0 : DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::Handle<JS::PropertyDescriptor> desc, JS::ObjectOpResult& opresult, bool* defined) const
1237 : {
1238 0 : if (IsArrayIndex(GetArrayIndexFromId(cx, id))) {
1239 0 : *defined = true;
1240 0 : return opresult.failNoIndexedSetter();
1241 : }
1242 0 : return mozilla::dom::DOMProxyHandler::defineProperty(cx, proxy, id, desc, opresult, defined);
1243 : }
1244 :
1245 :
1246 : bool
1247 0 : DOMProxyHandler::ownPropNames(JSContext* cx, JS::Handle<JSObject*> proxy, unsigned flags, JS::AutoIdVector& props) const
1248 : {
1249 0 : bool isXray = xpc::WrapperFactory::IsXrayWrapper(proxy);
1250 :
1251 0 : uint32_t length = UnwrapProxy(proxy)->Length();
1252 0 : MOZ_ASSERT(int32_t(length) >= 0);
1253 0 : for (int32_t i = 0; i < int32_t(length); ++i) {
1254 0 : if (!props.append(INT_TO_JSID(i))) {
1255 0 : return false;
1256 : }
1257 : }
1258 :
1259 0 : JS::Rooted<JSObject*> expando(cx);
1260 0 : if (!isXray && (expando = DOMProxyHandler::GetExpandoObject(proxy)) &&
1261 0 : !js::GetPropertyKeys(cx, expando, flags, &props)) {
1262 0 : return false;
1263 : }
1264 :
1265 0 : return true;
1266 : }
1267 :
1268 : bool
1269 0 : DOMProxyHandler::hasOwn(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
1270 : {
1271 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1272 : "Should not have a XrayWrapper here");
1273 :
1274 0 : uint32_t index = GetArrayIndexFromId(cx, id);
1275 0 : if (IsArrayIndex(index)) {
1276 0 : bool found = false;
1277 0 : nsDOMOfflineResourceList* self = UnwrapProxy(proxy);
1278 0 : binding_detail::FastErrorResult rv;
1279 0 : DOMString result;
1280 0 : self->IndexedGetter(index, found, result, rv);
1281 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1282 0 : return false;
1283 : }
1284 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1285 : (void)result;
1286 :
1287 0 : *bp = found;
1288 0 : return true;
1289 : }
1290 :
1291 :
1292 0 : JS::Rooted<JSObject*> expando(cx, GetExpandoObject(proxy));
1293 0 : if (expando) {
1294 0 : bool b = true;
1295 0 : bool ok = JS_HasPropertyById(cx, expando, id, &b);
1296 0 : *bp = !!b;
1297 0 : if (!ok || *bp) {
1298 0 : return ok;
1299 : }
1300 : }
1301 :
1302 0 : *bp = false;
1303 0 : return true;
1304 : }
1305 :
1306 : bool
1307 0 : DOMProxyHandler::get(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<JS::Value> receiver, JS::Handle<jsid> id, JS::MutableHandle<JS::Value> vp) const
1308 : {
1309 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1310 : "Should not have a XrayWrapper here");
1311 :
1312 0 : uint32_t index = GetArrayIndexFromId(cx, id);
1313 0 : if (IsArrayIndex(index)) {
1314 0 : nsDOMOfflineResourceList* self = UnwrapProxy(proxy);
1315 0 : bool found = false;
1316 0 : binding_detail::FastErrorResult rv;
1317 0 : DOMString result;
1318 0 : self->IndexedGetter(index, found, result, rv);
1319 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1320 0 : return false;
1321 : }
1322 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1323 :
1324 0 : if (found) {
1325 0 : if (!xpc::NonVoidStringToJsval(cx, result, vp)) {
1326 0 : return false;
1327 : }
1328 0 : return true;
1329 : }
1330 : // Even if we don't have this index, we don't forward the
1331 : // get on to our expando object.
1332 : } else {
1333 : { // Scope for expando
1334 0 : JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
1335 0 : if (expando) {
1336 : bool hasProp;
1337 0 : if (!JS_HasPropertyById(cx, expando, id, &hasProp)) {
1338 0 : return false;
1339 : }
1340 :
1341 0 : if (hasProp) {
1342 : // Forward the get to the expando object, but our receiver is whatever our
1343 : // receiver is.
1344 0 : return JS_ForwardGetPropertyTo(cx, expando, id, receiver, vp);
1345 : }
1346 : }
1347 : }
1348 : }
1349 :
1350 : bool foundOnPrototype;
1351 0 : if (!GetPropertyOnPrototype(cx, proxy, receiver, id, &foundOnPrototype, vp)) {
1352 0 : return false;
1353 : }
1354 :
1355 0 : if (foundOnPrototype) {
1356 0 : return true;
1357 : }
1358 :
1359 0 : vp.setUndefined();
1360 0 : return true;
1361 : }
1362 :
1363 : const char*
1364 0 : DOMProxyHandler::className(JSContext* cx, JS::Handle<JSObject*> proxy) const
1365 : {
1366 0 : return "OfflineResourceList";
1367 : }
1368 :
1369 : bool
1370 0 : DOMProxyHandler::finalizeInBackground(const JS::Value& priv) const
1371 : {
1372 0 : return false;
1373 : }
1374 :
1375 : void
1376 0 : DOMProxyHandler::finalize(JSFreeOp* fop, JSObject* proxy) const
1377 : {
1378 0 : nsDOMOfflineResourceList* self = UnwrapPossiblyNotInitializedDOMObject<nsDOMOfflineResourceList>(proxy);
1379 0 : if (self) {
1380 0 : ClearWrapper(self, self, proxy);
1381 0 : AddForDeferredFinalization<nsDOMOfflineResourceList>(self);
1382 : }
1383 0 : }
1384 :
1385 : const DOMProxyHandler*
1386 0 : DOMProxyHandler::getInstance()
1387 : {
1388 : static const DOMProxyHandler instance;
1389 0 : return &instance;
1390 : }
1391 :
1392 : bool
1393 0 : DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, JS::ObjectOpResult& opresult) const
1394 : {
1395 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1396 : "Should not have a XrayWrapper here");
1397 :
1398 0 : uint32_t index = GetArrayIndexFromId(cx, id);
1399 0 : if (IsArrayIndex(index)) {
1400 : bool deleteSucceeded;
1401 0 : bool found = false;
1402 0 : nsDOMOfflineResourceList* self = UnwrapProxy(proxy);
1403 0 : binding_detail::FastErrorResult rv;
1404 0 : DOMString result;
1405 0 : self->IndexedGetter(index, found, result, rv);
1406 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1407 0 : return false;
1408 : }
1409 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1410 : (void)result;
1411 0 : deleteSucceeded = !found;
1412 0 : return deleteSucceeded ? opresult.succeed() : opresult.failCantDelete();
1413 : }
1414 :
1415 0 : return dom::DOMProxyHandler::delete_(cx, proxy, id, opresult);
1416 : }
1417 :
1418 : bool
1419 0 : DOMProxyHandler::getElements(JSContext* cx, JS::Handle<JSObject*> proxy, uint32_t begin, uint32_t end, js::ElementAdder* adder) const
1420 : {
1421 0 : JS::Rooted<JS::Value> temp(cx);
1422 0 : MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
1423 : "Should not have a XrayWrapper here");
1424 :
1425 0 : nsDOMOfflineResourceList* self = UnwrapProxy(proxy);
1426 0 : uint32_t length = self->Length();
1427 : // Compute the end of the indices we'll get ourselves
1428 0 : uint32_t ourEnd = std::max(begin, std::min(end, length));
1429 :
1430 0 : for (uint32_t index = begin; index < ourEnd; ++index) {
1431 0 : bool found = false;
1432 0 : binding_detail::FastErrorResult rv;
1433 0 : DOMString result;
1434 0 : self->IndexedGetter(index, found, result, rv);
1435 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1436 0 : return false;
1437 : }
1438 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1439 :
1440 0 : MOZ_ASSERT(found);
1441 0 : if (!xpc::NonVoidStringToJsval(cx, result, &temp)) {
1442 0 : return false;
1443 : }
1444 0 : if (!adder->append(cx, temp)) return false;
1445 0 : continue;
1446 : }
1447 :
1448 0 : if (end > ourEnd) {
1449 0 : JS::Rooted<JSObject*> proto(cx);
1450 0 : if (!js::GetObjectProto(cx, proxy, &proto)) {
1451 0 : return false;
1452 : }
1453 0 : return js::GetElementsWithAdder(cx, proto, proxy, ourEnd, end, adder);
1454 : }
1455 :
1456 0 : return true;
1457 : }
1458 :
1459 : static const js::ClassExtension sClassExtension = PROXY_MAKE_EXT(
1460 : _objectMoved
1461 : );
1462 :
1463 : static const DOMJSClass sClass = {
1464 : PROXY_CLASS_WITH_EXT("OfflineResourceList",
1465 : JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
1466 : &sClassExtension),
1467 : { prototypes::id::EventTarget, prototypes::id::OfflineResourceList, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1468 : IsBaseOf<nsISupports, nsDOMOfflineResourceList >::value,
1469 : sNativePropertyHooks,
1470 : FindAssociatedGlobalForNative<nsDOMOfflineResourceList>::Get,
1471 : GetProtoObjectHandle,
1472 : GetCCParticipant<nsDOMOfflineResourceList>::Get()
1473 : };
1474 :
1475 : bool
1476 0 : Wrap(JSContext* aCx, nsDOMOfflineResourceList* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1477 : {
1478 : MOZ_ASSERT(static_cast<nsDOMOfflineResourceList*>(aObject) ==
1479 : reinterpret_cast<nsDOMOfflineResourceList*>(aObject),
1480 : "Multiple inheritance for nsDOMOfflineResourceList is broken.");
1481 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1482 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1483 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1484 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1485 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1486 0 : MOZ_ASSERT(!aCache->GetWrapper(),
1487 : "You should probably not be using Wrap() directly; use "
1488 : "GetOrCreateDOMReflector instead");
1489 :
1490 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1491 : "nsISupports must be on our primary inheritance chain");
1492 :
1493 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1494 0 : if (!global) {
1495 0 : return false;
1496 : }
1497 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
1498 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1499 :
1500 : // That might have ended up wrapping us already, due to the wonders
1501 : // of XBL. Check for that, and bail out as needed.
1502 0 : aReflector.set(aCache->GetWrapper());
1503 0 : if (aReflector) {
1504 : #ifdef DEBUG
1505 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1506 : #endif // DEBUG
1507 0 : return true;
1508 : }
1509 :
1510 0 : JSAutoCompartment ac(aCx, global);
1511 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1512 0 : if (!canonicalProto) {
1513 0 : return false;
1514 : }
1515 0 : JS::Rooted<JSObject*> proto(aCx);
1516 0 : if (aGivenProto) {
1517 0 : proto = aGivenProto;
1518 : // Unfortunately, while aGivenProto was in the compartment of aCx
1519 : // coming in, we changed compartments to that of "parent" so may need
1520 : // to wrap the proto here.
1521 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1522 0 : if (!JS_WrapObject(aCx, &proto)) {
1523 0 : return false;
1524 : }
1525 : }
1526 : } else {
1527 0 : proto = canonicalProto;
1528 : }
1529 :
1530 0 : BindingJSObjectCreator<nsDOMOfflineResourceList> creator(aCx);
1531 0 : JS::Rooted<JS::Value> expandoValue(aCx, JS::UndefinedValue());
1532 0 : creator.CreateProxyObject(aCx, &sClass.mBase, DOMProxyHandler::getInstance(),
1533 0 : proto, aObject, expandoValue, aReflector);
1534 0 : if (!aReflector) {
1535 0 : return false;
1536 : }
1537 :
1538 :
1539 0 : aCache->SetWrapper(aReflector);
1540 0 : creator.InitializationSucceeded();
1541 :
1542 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1543 : aCache->GetWrapperPreserveColor() == aReflector);
1544 : // If proto != canonicalProto, we have to preserve our wrapper;
1545 : // otherwise we won't be able to properly recreate it later, since
1546 : // we won't know what proto to use. Note that we don't check
1547 : // aGivenProto here, since it's entirely possible (and even
1548 : // somewhat common) to have a non-null aGivenProto which is the
1549 : // same as canonicalProto.
1550 0 : if (proto != canonicalProto) {
1551 0 : PreserveWrapper(aObject);
1552 : }
1553 :
1554 0 : return true;
1555 : }
1556 :
1557 : static bool
1558 0 : ResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::MutableHandle<JS::PropertyDescriptor> desc)
1559 : {
1560 0 : return js::GetProxyHandler(obj)->getOwnPropertyDescriptor(cx, wrapper, id, desc);
1561 : }
1562 :
1563 : static bool
1564 0 : EnumerateOwnProperties(JSContext* cx, JS::Handle<JSObject*> wrapper, JS::Handle<JSObject*> obj, JS::AutoIdVector& props)
1565 : {
1566 0 : return js::GetProxyHandler(obj)->ownPropertyKeys(cx, wrapper, props);
1567 : }
1568 :
1569 : const NativePropertyHooks sNativePropertyHooks[] = { {
1570 : ResolveOwnProperty,
1571 : EnumerateOwnProperties,
1572 : nullptr,
1573 : { sNativeProperties.Upcast(), nullptr },
1574 : prototypes::id::OfflineResourceList,
1575 : constructors::id::OfflineResourceList,
1576 : EventTargetBinding::sNativePropertyHooks,
1577 : &DefaultXrayExpandoObjectClass
1578 : } };
1579 :
1580 : void
1581 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1582 : {
1583 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
1584 0 : if (!parentProto) {
1585 0 : return;
1586 : }
1587 :
1588 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
1589 0 : if (!constructorProto) {
1590 0 : return;
1591 : }
1592 :
1593 : static bool sIdsInited = false;
1594 0 : if (!sIdsInited && NS_IsMainThread()) {
1595 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1596 0 : return;
1597 : }
1598 0 : sIdsInited = true;
1599 : }
1600 :
1601 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::OfflineResourceList);
1602 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::OfflineResourceList);
1603 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1604 : &sPrototypeClass.mBase, protoCache,
1605 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1606 : interfaceCache,
1607 : sNativeProperties.Upcast(),
1608 : nullptr,
1609 : "OfflineResourceList", aDefineOnGlobal,
1610 : nullptr,
1611 0 : false);
1612 : }
1613 :
1614 : JS::Handle<JSObject*>
1615 0 : GetProtoObjectHandle(JSContext* aCx)
1616 : {
1617 : /* Get the interface prototype object for this class. This will create the
1618 : object as needed. */
1619 0 : bool aDefineOnGlobal = true;
1620 :
1621 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1622 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1623 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1624 0 : return nullptr;
1625 : }
1626 :
1627 : /* Check to see whether the interface objects are already installed */
1628 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1629 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::OfflineResourceList)) {
1630 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1631 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1632 : }
1633 :
1634 : /*
1635 : * The object might _still_ be null, but that's OK.
1636 : *
1637 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1638 : * traced by TraceProtoAndIfaceCache() and its contents are never
1639 : * changed after they have been set.
1640 : *
1641 : * Calling address() avoids the read read barrier that does gray
1642 : * unmarking, but it's not possible for the object to be gray here.
1643 : */
1644 :
1645 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::OfflineResourceList);
1646 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1647 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1648 : }
1649 :
1650 : JS::Handle<JSObject*>
1651 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1652 : {
1653 : /* Get the interface object for this class. This will create the object as
1654 : needed. */
1655 :
1656 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1657 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1658 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1659 0 : return nullptr;
1660 : }
1661 :
1662 : /* Check to see whether the interface objects are already installed */
1663 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1664 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::OfflineResourceList)) {
1665 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1666 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1667 : }
1668 :
1669 : /*
1670 : * The object might _still_ be null, but that's OK.
1671 : *
1672 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1673 : * traced by TraceProtoAndIfaceCache() and its contents are never
1674 : * changed after they have been set.
1675 : *
1676 : * Calling address() avoids the read read barrier that does gray
1677 : * unmarking, but it's not possible for the object to be gray here.
1678 : */
1679 :
1680 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::OfflineResourceList);
1681 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1682 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1683 : }
1684 :
1685 : JSObject*
1686 0 : GetConstructorObject(JSContext* aCx)
1687 : {
1688 0 : return GetConstructorObjectHandle(aCx);
1689 : }
1690 :
1691 : } // namespace OfflineResourceListBinding
1692 :
1693 :
1694 :
1695 : } // namespace dom
1696 : } // namespace mozilla
|