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