/work/obj-fuzz/dom/bindings/SourceBufferBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM SourceBuffer.webidl BY Codegen.py - DO NOT EDIT */ |
2 | | |
3 | | #include "EventHandlerBinding.h" |
4 | | #include "EventTargetBinding.h" |
5 | | #include "SourceBufferBinding.h" |
6 | | #include "WrapperFactory.h" |
7 | | #include "jsapi.h" |
8 | | #include "jsfriendapi.h" |
9 | | #include "mozilla/FloatingPoint.h" |
10 | | #include "mozilla/OwningNonNull.h" |
11 | | #include "mozilla/dom/BindingUtils.h" |
12 | | #include "mozilla/dom/DOMJSClass.h" |
13 | | #include "mozilla/dom/MediaSource.h" |
14 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
15 | | #include "mozilla/dom/Nullable.h" |
16 | | #include "mozilla/dom/PrimitiveConversions.h" |
17 | | #include "mozilla/dom/Promise.h" |
18 | | #include "mozilla/dom/SourceBuffer.h" |
19 | | #include "mozilla/dom/TimeRanges.h" |
20 | | #include "mozilla/dom/ToJSValue.h" |
21 | | #include "mozilla/dom/TypedArray.h" |
22 | | #include "mozilla/dom/XrayExpandoClass.h" |
23 | | |
24 | | namespace mozilla { |
25 | | namespace dom { |
26 | | |
27 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
28 | | using namespace mozilla::dom::binding_detail; |
29 | | |
30 | | |
31 | | namespace SourceBufferAppendModeValues { |
32 | | extern const EnumEntry strings[3] = { |
33 | | {"segments", 8}, |
34 | | {"sequence", 8}, |
35 | | { nullptr, 0 } |
36 | | }; |
37 | | } // namespace SourceBufferAppendModeValues |
38 | | |
39 | | bool |
40 | | ToJSValue(JSContext* aCx, SourceBufferAppendMode aArgument, JS::MutableHandle<JS::Value> aValue) |
41 | 0 | { |
42 | 0 | MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(SourceBufferAppendModeValues::strings)); |
43 | 0 | JSString* resultStr = |
44 | 0 | JS_NewStringCopyN(aCx, SourceBufferAppendModeValues::strings[uint32_t(aArgument)].value, |
45 | 0 | SourceBufferAppendModeValues::strings[uint32_t(aArgument)].length); |
46 | 0 | if (!resultStr) { |
47 | 0 | return false; |
48 | 0 | } |
49 | 0 | aValue.setString(resultStr); |
50 | 0 | return true; |
51 | 0 | } |
52 | | |
53 | | |
54 | | namespace SourceBuffer_Binding { |
55 | | |
56 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
57 | | "Can't inherit from an interface with a different ownership model."); |
58 | | |
59 | | MOZ_CAN_RUN_SCRIPT static bool |
60 | | get_mode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
61 | 0 | { |
62 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.mode", DOM, cx); |
63 | 0 |
|
64 | 0 | SourceBufferAppendMode result(self->Mode()); |
65 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
66 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
67 | 0 | return false; |
68 | 0 | } |
69 | 0 | return true; |
70 | 0 | } |
71 | | |
72 | | MOZ_CAN_RUN_SCRIPT static bool |
73 | | set_mode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
74 | 0 | { |
75 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.mode", DOM, cx); |
76 | 0 |
|
77 | 0 | SourceBufferAppendMode arg0; |
78 | 0 | { |
79 | 0 | int index; |
80 | 0 | if (!FindEnumStringIndex<false>(cx, args[0], SourceBufferAppendModeValues::strings, "SourceBufferAppendMode", "Value being assigned to SourceBuffer.mode", &index)) { |
81 | 0 | return false; |
82 | 0 | } |
83 | 0 | if (index < 0) { |
84 | 0 | return true; |
85 | 0 | } |
86 | 0 | arg0 = static_cast<SourceBufferAppendMode>(index); |
87 | 0 | } |
88 | 0 | FastErrorResult rv; |
89 | 0 | self->SetMode(arg0, rv); |
90 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
91 | 0 | return false; |
92 | 0 | } |
93 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
94 | 0 |
|
95 | 0 | return true; |
96 | 0 | } |
97 | | |
98 | | static const JSJitInfo mode_getterinfo = { |
99 | | { (JSJitGetterOp)get_mode }, |
100 | | { prototypes::id::SourceBuffer }, |
101 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
102 | | JSJitInfo::Getter, |
103 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
104 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
105 | | false, /* isInfallible. False in setters. */ |
106 | | false, /* isMovable. Not relevant for setters. */ |
107 | | false, /* isEliminatable. Not relevant for setters. */ |
108 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
109 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
110 | | false, /* isTypedMethod. Only relevant for methods. */ |
111 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
112 | | }; |
113 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
114 | | static_assert(0 < 1, "There is no slot for us"); |
115 | | static const JSJitInfo mode_setterinfo = { |
116 | | { (JSJitGetterOp)set_mode }, |
117 | | { prototypes::id::SourceBuffer }, |
118 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
119 | | JSJitInfo::Setter, |
120 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
121 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
122 | | false, /* isInfallible. False in setters. */ |
123 | | false, /* isMovable. Not relevant for setters. */ |
124 | | false, /* isEliminatable. Not relevant for setters. */ |
125 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
126 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
127 | | false, /* isTypedMethod. Only relevant for methods. */ |
128 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
129 | | }; |
130 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
131 | | static_assert(0 < 1, "There is no slot for us"); |
132 | | |
133 | | MOZ_CAN_RUN_SCRIPT static bool |
134 | | get_updating(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
135 | 0 | { |
136 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.updating", DOM, cx); |
137 | 0 |
|
138 | 0 | bool result(self->Updating()); |
139 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
140 | 0 | args.rval().setBoolean(result); |
141 | 0 | return true; |
142 | 0 | } |
143 | | |
144 | | static const JSJitInfo updating_getterinfo = { |
145 | | { (JSJitGetterOp)get_updating }, |
146 | | { prototypes::id::SourceBuffer }, |
147 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
148 | | JSJitInfo::Getter, |
149 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
150 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
151 | | true, /* isInfallible. False in setters. */ |
152 | | false, /* isMovable. Not relevant for setters. */ |
153 | | false, /* isEliminatable. Not relevant for setters. */ |
154 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
155 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
156 | | false, /* isTypedMethod. Only relevant for methods. */ |
157 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
158 | | }; |
159 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
160 | | static_assert(0 < 1, "There is no slot for us"); |
161 | | |
162 | | MOZ_CAN_RUN_SCRIPT static bool |
163 | | get_buffered(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
164 | 0 | { |
165 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.buffered", DOM, cx); |
166 | 0 |
|
167 | 0 | FastErrorResult rv; |
168 | 0 | auto result(StrongOrRawPtr<mozilla::dom::TimeRanges>(self->GetBuffered(rv))); |
169 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
170 | 0 | return false; |
171 | 0 | } |
172 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
173 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
174 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
175 | 0 | return false; |
176 | 0 | } |
177 | 0 | return true; |
178 | 0 | } |
179 | | |
180 | | static const JSJitInfo buffered_getterinfo = { |
181 | | { (JSJitGetterOp)get_buffered }, |
182 | | { prototypes::id::SourceBuffer }, |
183 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
184 | | JSJitInfo::Getter, |
185 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
186 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
187 | | false, /* isInfallible. False in setters. */ |
188 | | false, /* isMovable. Not relevant for setters. */ |
189 | | false, /* isEliminatable. Not relevant for setters. */ |
190 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
191 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
192 | | false, /* isTypedMethod. Only relevant for methods. */ |
193 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
194 | | }; |
195 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
196 | | static_assert(0 < 1, "There is no slot for us"); |
197 | | |
198 | | MOZ_CAN_RUN_SCRIPT static bool |
199 | | get_timestampOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
200 | 0 | { |
201 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.timestampOffset", DOM, cx); |
202 | 0 |
|
203 | 0 | double result(self->TimestampOffset()); |
204 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
205 | 0 | args.rval().set(JS_NumberValue(double(result))); |
206 | 0 | return true; |
207 | 0 | } |
208 | | |
209 | | MOZ_CAN_RUN_SCRIPT static bool |
210 | | set_timestampOffset(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
211 | 0 | { |
212 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.timestampOffset", DOM, cx); |
213 | 0 |
|
214 | 0 | double arg0; |
215 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
216 | 0 | return false; |
217 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
218 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SourceBuffer.timestampOffset"); |
219 | 0 | return false; |
220 | 0 | } |
221 | 0 | FastErrorResult rv; |
222 | 0 | self->SetTimestampOffset(arg0, rv); |
223 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
224 | 0 | return false; |
225 | 0 | } |
226 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
227 | 0 |
|
228 | 0 | return true; |
229 | 0 | } |
230 | | |
231 | | static const JSJitInfo timestampOffset_getterinfo = { |
232 | | { (JSJitGetterOp)get_timestampOffset }, |
233 | | { prototypes::id::SourceBuffer }, |
234 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
235 | | JSJitInfo::Getter, |
236 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
237 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
238 | | true, /* isInfallible. False in setters. */ |
239 | | false, /* isMovable. Not relevant for setters. */ |
240 | | false, /* isEliminatable. Not relevant for setters. */ |
241 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
242 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
243 | | false, /* isTypedMethod. Only relevant for methods. */ |
244 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
245 | | }; |
246 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
247 | | static_assert(0 < 1, "There is no slot for us"); |
248 | | static const JSJitInfo timestampOffset_setterinfo = { |
249 | | { (JSJitGetterOp)set_timestampOffset }, |
250 | | { prototypes::id::SourceBuffer }, |
251 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
252 | | JSJitInfo::Setter, |
253 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
254 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
255 | | false, /* isInfallible. False in setters. */ |
256 | | false, /* isMovable. Not relevant for setters. */ |
257 | | false, /* isEliminatable. Not relevant for setters. */ |
258 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
259 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
260 | | false, /* isTypedMethod. Only relevant for methods. */ |
261 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
262 | | }; |
263 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
264 | | static_assert(0 < 1, "There is no slot for us"); |
265 | | |
266 | | MOZ_CAN_RUN_SCRIPT static bool |
267 | | get_appendWindowStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
268 | 0 | { |
269 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.appendWindowStart", DOM, cx); |
270 | 0 |
|
271 | 0 | double result(self->AppendWindowStart()); |
272 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
273 | 0 | args.rval().set(JS_NumberValue(double(result))); |
274 | 0 | return true; |
275 | 0 | } |
276 | | |
277 | | MOZ_CAN_RUN_SCRIPT static bool |
278 | | set_appendWindowStart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
279 | 0 | { |
280 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.appendWindowStart", DOM, cx); |
281 | 0 |
|
282 | 0 | double arg0; |
283 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
284 | 0 | return false; |
285 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
286 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SourceBuffer.appendWindowStart"); |
287 | 0 | return false; |
288 | 0 | } |
289 | 0 | FastErrorResult rv; |
290 | 0 | self->SetAppendWindowStart(arg0, rv); |
291 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
292 | 0 | return false; |
293 | 0 | } |
294 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
295 | 0 |
|
296 | 0 | return true; |
297 | 0 | } |
298 | | |
299 | | static const JSJitInfo appendWindowStart_getterinfo = { |
300 | | { (JSJitGetterOp)get_appendWindowStart }, |
301 | | { prototypes::id::SourceBuffer }, |
302 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
303 | | JSJitInfo::Getter, |
304 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
305 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
306 | | true, /* isInfallible. False in setters. */ |
307 | | false, /* isMovable. Not relevant for setters. */ |
308 | | false, /* isEliminatable. Not relevant for setters. */ |
309 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
310 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
311 | | false, /* isTypedMethod. Only relevant for methods. */ |
312 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
313 | | }; |
314 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
315 | | static_assert(0 < 1, "There is no slot for us"); |
316 | | static const JSJitInfo appendWindowStart_setterinfo = { |
317 | | { (JSJitGetterOp)set_appendWindowStart }, |
318 | | { prototypes::id::SourceBuffer }, |
319 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
320 | | JSJitInfo::Setter, |
321 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
322 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
323 | | false, /* isInfallible. False in setters. */ |
324 | | false, /* isMovable. Not relevant for setters. */ |
325 | | false, /* isEliminatable. Not relevant for setters. */ |
326 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
327 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
328 | | false, /* isTypedMethod. Only relevant for methods. */ |
329 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
330 | | }; |
331 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
332 | | static_assert(0 < 1, "There is no slot for us"); |
333 | | |
334 | | MOZ_CAN_RUN_SCRIPT static bool |
335 | | get_appendWindowEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
336 | 0 | { |
337 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.appendWindowEnd", DOM, cx); |
338 | 0 |
|
339 | 0 | double result(self->AppendWindowEnd()); |
340 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
341 | 0 | args.rval().set(JS_NumberValue(double(result))); |
342 | 0 | return true; |
343 | 0 | } |
344 | | |
345 | | MOZ_CAN_RUN_SCRIPT static bool |
346 | | set_appendWindowEnd(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
347 | 0 | { |
348 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.appendWindowEnd", DOM, cx); |
349 | 0 |
|
350 | 0 | double arg0; |
351 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
352 | 0 | return false; |
353 | 0 | } |
354 | 0 | FastErrorResult rv; |
355 | 0 | self->SetAppendWindowEnd(arg0, rv); |
356 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
357 | 0 | return false; |
358 | 0 | } |
359 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
360 | 0 |
|
361 | 0 | return true; |
362 | 0 | } |
363 | | |
364 | | static const JSJitInfo appendWindowEnd_getterinfo = { |
365 | | { (JSJitGetterOp)get_appendWindowEnd }, |
366 | | { prototypes::id::SourceBuffer }, |
367 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
368 | | JSJitInfo::Getter, |
369 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
370 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
371 | | true, /* isInfallible. False in setters. */ |
372 | | false, /* isMovable. Not relevant for setters. */ |
373 | | false, /* isEliminatable. Not relevant for setters. */ |
374 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
375 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
376 | | false, /* isTypedMethod. Only relevant for methods. */ |
377 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
378 | | }; |
379 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
380 | | static_assert(0 < 1, "There is no slot for us"); |
381 | | static const JSJitInfo appendWindowEnd_setterinfo = { |
382 | | { (JSJitGetterOp)set_appendWindowEnd }, |
383 | | { prototypes::id::SourceBuffer }, |
384 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
385 | | JSJitInfo::Setter, |
386 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
387 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
388 | | false, /* isInfallible. False in setters. */ |
389 | | false, /* isMovable. Not relevant for setters. */ |
390 | | false, /* isEliminatable. Not relevant for setters. */ |
391 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
392 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
393 | | false, /* isTypedMethod. Only relevant for methods. */ |
394 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
395 | | }; |
396 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
397 | | static_assert(0 < 1, "There is no slot for us"); |
398 | | |
399 | | MOZ_CAN_RUN_SCRIPT static bool |
400 | | get_onupdatestart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
401 | 0 | { |
402 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.onupdatestart", DOM, cx); |
403 | 0 |
|
404 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnupdatestart()); |
405 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
406 | 0 | if (result) { |
407 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
408 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
409 | 0 | return false; |
410 | 0 | } |
411 | 0 | return true; |
412 | 0 | } else { |
413 | 0 | args.rval().setNull(); |
414 | 0 | return true; |
415 | 0 | } |
416 | 0 | } |
417 | | |
418 | | MOZ_CAN_RUN_SCRIPT static bool |
419 | | set_onupdatestart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
420 | 0 | { |
421 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.onupdatestart", DOM, cx); |
422 | 0 |
|
423 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
424 | 0 | if (args[0].isObject()) { |
425 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
426 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
427 | 0 | } |
428 | 0 | } else { |
429 | 0 | arg0 = nullptr; |
430 | 0 | } |
431 | 0 | self->SetOnupdatestart(Constify(arg0)); |
432 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
433 | 0 |
|
434 | 0 | return true; |
435 | 0 | } |
436 | | |
437 | | static const JSJitInfo onupdatestart_getterinfo = { |
438 | | { (JSJitGetterOp)get_onupdatestart }, |
439 | | { prototypes::id::SourceBuffer }, |
440 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
441 | | JSJitInfo::Getter, |
442 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
443 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
444 | | false, /* isInfallible. False in setters. */ |
445 | | false, /* isMovable. Not relevant for setters. */ |
446 | | false, /* isEliminatable. Not relevant for setters. */ |
447 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
448 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
449 | | false, /* isTypedMethod. Only relevant for methods. */ |
450 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
451 | | }; |
452 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
453 | | static_assert(0 < 1, "There is no slot for us"); |
454 | | static const JSJitInfo onupdatestart_setterinfo = { |
455 | | { (JSJitGetterOp)set_onupdatestart }, |
456 | | { prototypes::id::SourceBuffer }, |
457 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
458 | | JSJitInfo::Setter, |
459 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
460 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
461 | | false, /* isInfallible. False in setters. */ |
462 | | false, /* isMovable. Not relevant for setters. */ |
463 | | false, /* isEliminatable. Not relevant for setters. */ |
464 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
465 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
466 | | false, /* isTypedMethod. Only relevant for methods. */ |
467 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
468 | | }; |
469 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
470 | | static_assert(0 < 1, "There is no slot for us"); |
471 | | |
472 | | MOZ_CAN_RUN_SCRIPT static bool |
473 | | get_onupdate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
474 | 0 | { |
475 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.onupdate", DOM, cx); |
476 | 0 |
|
477 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnupdate()); |
478 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
479 | 0 | if (result) { |
480 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
481 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
482 | 0 | return false; |
483 | 0 | } |
484 | 0 | return true; |
485 | 0 | } else { |
486 | 0 | args.rval().setNull(); |
487 | 0 | return true; |
488 | 0 | } |
489 | 0 | } |
490 | | |
491 | | MOZ_CAN_RUN_SCRIPT static bool |
492 | | set_onupdate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
493 | 0 | { |
494 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.onupdate", DOM, cx); |
495 | 0 |
|
496 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
497 | 0 | if (args[0].isObject()) { |
498 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
499 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
500 | 0 | } |
501 | 0 | } else { |
502 | 0 | arg0 = nullptr; |
503 | 0 | } |
504 | 0 | self->SetOnupdate(Constify(arg0)); |
505 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
506 | 0 |
|
507 | 0 | return true; |
508 | 0 | } |
509 | | |
510 | | static const JSJitInfo onupdate_getterinfo = { |
511 | | { (JSJitGetterOp)get_onupdate }, |
512 | | { prototypes::id::SourceBuffer }, |
513 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
514 | | JSJitInfo::Getter, |
515 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
516 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
517 | | false, /* isInfallible. False in setters. */ |
518 | | false, /* isMovable. Not relevant for setters. */ |
519 | | false, /* isEliminatable. Not relevant for setters. */ |
520 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
521 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
522 | | false, /* isTypedMethod. Only relevant for methods. */ |
523 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
524 | | }; |
525 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
526 | | static_assert(0 < 1, "There is no slot for us"); |
527 | | static const JSJitInfo onupdate_setterinfo = { |
528 | | { (JSJitGetterOp)set_onupdate }, |
529 | | { prototypes::id::SourceBuffer }, |
530 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
531 | | JSJitInfo::Setter, |
532 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
533 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
534 | | false, /* isInfallible. False in setters. */ |
535 | | false, /* isMovable. Not relevant for setters. */ |
536 | | false, /* isEliminatable. Not relevant for setters. */ |
537 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
538 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
539 | | false, /* isTypedMethod. Only relevant for methods. */ |
540 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
541 | | }; |
542 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
543 | | static_assert(0 < 1, "There is no slot for us"); |
544 | | |
545 | | MOZ_CAN_RUN_SCRIPT static bool |
546 | | get_onupdateend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
547 | 0 | { |
548 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.onupdateend", DOM, cx); |
549 | 0 |
|
550 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnupdateend()); |
551 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
552 | 0 | if (result) { |
553 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
554 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
555 | 0 | return false; |
556 | 0 | } |
557 | 0 | return true; |
558 | 0 | } else { |
559 | 0 | args.rval().setNull(); |
560 | 0 | return true; |
561 | 0 | } |
562 | 0 | } |
563 | | |
564 | | MOZ_CAN_RUN_SCRIPT static bool |
565 | | set_onupdateend(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
566 | 0 | { |
567 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.onupdateend", DOM, cx); |
568 | 0 |
|
569 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
570 | 0 | if (args[0].isObject()) { |
571 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
572 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
573 | 0 | } |
574 | 0 | } else { |
575 | 0 | arg0 = nullptr; |
576 | 0 | } |
577 | 0 | self->SetOnupdateend(Constify(arg0)); |
578 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
579 | 0 |
|
580 | 0 | return true; |
581 | 0 | } |
582 | | |
583 | | static const JSJitInfo onupdateend_getterinfo = { |
584 | | { (JSJitGetterOp)get_onupdateend }, |
585 | | { prototypes::id::SourceBuffer }, |
586 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
587 | | JSJitInfo::Getter, |
588 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
589 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
590 | | false, /* isInfallible. False in setters. */ |
591 | | false, /* isMovable. Not relevant for setters. */ |
592 | | false, /* isEliminatable. Not relevant for setters. */ |
593 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
594 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
595 | | false, /* isTypedMethod. Only relevant for methods. */ |
596 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
597 | | }; |
598 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
599 | | static_assert(0 < 1, "There is no slot for us"); |
600 | | static const JSJitInfo onupdateend_setterinfo = { |
601 | | { (JSJitGetterOp)set_onupdateend }, |
602 | | { prototypes::id::SourceBuffer }, |
603 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
604 | | JSJitInfo::Setter, |
605 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
606 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
607 | | false, /* isInfallible. False in setters. */ |
608 | | false, /* isMovable. Not relevant for setters. */ |
609 | | false, /* isEliminatable. Not relevant for setters. */ |
610 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
611 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
612 | | false, /* isTypedMethod. Only relevant for methods. */ |
613 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
614 | | }; |
615 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
616 | | static_assert(0 < 1, "There is no slot for us"); |
617 | | |
618 | | MOZ_CAN_RUN_SCRIPT static bool |
619 | | get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
620 | 0 | { |
621 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.onerror", DOM, cx); |
622 | 0 |
|
623 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnerror()); |
624 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
625 | 0 | if (result) { |
626 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
627 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
628 | 0 | return false; |
629 | 0 | } |
630 | 0 | return true; |
631 | 0 | } else { |
632 | 0 | args.rval().setNull(); |
633 | 0 | return true; |
634 | 0 | } |
635 | 0 | } |
636 | | |
637 | | MOZ_CAN_RUN_SCRIPT static bool |
638 | | set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
639 | 0 | { |
640 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.onerror", DOM, cx); |
641 | 0 |
|
642 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
643 | 0 | if (args[0].isObject()) { |
644 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
645 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
646 | 0 | } |
647 | 0 | } else { |
648 | 0 | arg0 = nullptr; |
649 | 0 | } |
650 | 0 | self->SetOnerror(Constify(arg0)); |
651 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
652 | 0 |
|
653 | 0 | return true; |
654 | 0 | } |
655 | | |
656 | | static const JSJitInfo onerror_getterinfo = { |
657 | | { (JSJitGetterOp)get_onerror }, |
658 | | { prototypes::id::SourceBuffer }, |
659 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
660 | | JSJitInfo::Getter, |
661 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
662 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
663 | | false, /* isInfallible. False in setters. */ |
664 | | false, /* isMovable. Not relevant for setters. */ |
665 | | false, /* isEliminatable. Not relevant for setters. */ |
666 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
667 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
668 | | false, /* isTypedMethod. Only relevant for methods. */ |
669 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
670 | | }; |
671 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
672 | | static_assert(0 < 1, "There is no slot for us"); |
673 | | static const JSJitInfo onerror_setterinfo = { |
674 | | { (JSJitGetterOp)set_onerror }, |
675 | | { prototypes::id::SourceBuffer }, |
676 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
677 | | JSJitInfo::Setter, |
678 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
679 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
680 | | false, /* isInfallible. False in setters. */ |
681 | | false, /* isMovable. Not relevant for setters. */ |
682 | | false, /* isEliminatable. Not relevant for setters. */ |
683 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
684 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
685 | | false, /* isTypedMethod. Only relevant for methods. */ |
686 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
687 | | }; |
688 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
689 | | static_assert(0 < 1, "There is no slot for us"); |
690 | | |
691 | | MOZ_CAN_RUN_SCRIPT static bool |
692 | | get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitGetterCallArgs args) |
693 | 0 | { |
694 | 0 | AUTO_PROFILER_LABEL_FAST("get SourceBuffer.onabort", DOM, cx); |
695 | 0 |
|
696 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnabort()); |
697 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
698 | 0 | if (result) { |
699 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
700 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
701 | 0 | return false; |
702 | 0 | } |
703 | 0 | return true; |
704 | 0 | } else { |
705 | 0 | args.rval().setNull(); |
706 | 0 | return true; |
707 | 0 | } |
708 | 0 | } |
709 | | |
710 | | MOZ_CAN_RUN_SCRIPT static bool |
711 | | set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, JSJitSetterCallArgs args) |
712 | 0 | { |
713 | 0 | AUTO_PROFILER_LABEL_FAST("set SourceBuffer.onabort", DOM, cx); |
714 | 0 |
|
715 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
716 | 0 | if (args[0].isObject()) { |
717 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
718 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
719 | 0 | } |
720 | 0 | } else { |
721 | 0 | arg0 = nullptr; |
722 | 0 | } |
723 | 0 | self->SetOnabort(Constify(arg0)); |
724 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
725 | 0 |
|
726 | 0 | return true; |
727 | 0 | } |
728 | | |
729 | | static const JSJitInfo onabort_getterinfo = { |
730 | | { (JSJitGetterOp)get_onabort }, |
731 | | { prototypes::id::SourceBuffer }, |
732 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
733 | | JSJitInfo::Getter, |
734 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
735 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
736 | | false, /* isInfallible. False in setters. */ |
737 | | false, /* isMovable. Not relevant for setters. */ |
738 | | false, /* isEliminatable. Not relevant for setters. */ |
739 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
740 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
741 | | false, /* isTypedMethod. Only relevant for methods. */ |
742 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
743 | | }; |
744 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
745 | | static_assert(0 < 1, "There is no slot for us"); |
746 | | static const JSJitInfo onabort_setterinfo = { |
747 | | { (JSJitGetterOp)set_onabort }, |
748 | | { prototypes::id::SourceBuffer }, |
749 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
750 | | JSJitInfo::Setter, |
751 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
752 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
753 | | false, /* isInfallible. False in setters. */ |
754 | | false, /* isMovable. Not relevant for setters. */ |
755 | | false, /* isEliminatable. Not relevant for setters. */ |
756 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
757 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
758 | | false, /* isTypedMethod. Only relevant for methods. */ |
759 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
760 | | }; |
761 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
762 | | static_assert(0 < 1, "There is no slot for us"); |
763 | | |
764 | | MOZ_CAN_RUN_SCRIPT static bool |
765 | | appendBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
766 | 0 | { |
767 | 0 | AUTO_PROFILER_LABEL_FAST("SourceBuffer.appendBuffer", DOM, cx); |
768 | 0 |
|
769 | 0 | unsigned argcount = std::min(args.length(), 1u); |
770 | 0 | switch (argcount) { |
771 | 0 | case 1: { |
772 | 0 | if (args[0].isObject()) { |
773 | 0 | do { |
774 | 0 | RootedSpiderMonkeyInterface<ArrayBuffer> arg0(cx); |
775 | 0 | if (!arg0.Init(&args[0].toObject())) { |
776 | 0 | break; |
777 | 0 | } |
778 | 0 | FastErrorResult rv; |
779 | 0 | self->AppendBuffer(Constify(arg0), rv); |
780 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
781 | 0 | return false; |
782 | 0 | } |
783 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
784 | 0 | args.rval().setUndefined(); |
785 | 0 | return true; |
786 | 0 | } while (false); |
787 | 0 | do { |
788 | 0 | RootedSpiderMonkeyInterface<ArrayBufferView> arg0(cx); |
789 | 0 | if (!arg0.Init(&args[0].toObject())) { |
790 | 0 | break; |
791 | 0 | } |
792 | 0 | FastErrorResult rv; |
793 | 0 | self->AppendBuffer(Constify(arg0), rv); |
794 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
795 | 0 | return false; |
796 | 0 | } |
797 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
798 | 0 | args.rval().setUndefined(); |
799 | 0 | return true; |
800 | 0 | } while (false); |
801 | 0 | } |
802 | 0 | return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "1", "SourceBuffer.appendBuffer"); |
803 | 0 | break; |
804 | 0 | } |
805 | 0 | default: { |
806 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SourceBuffer.appendBuffer"); |
807 | 0 | break; |
808 | 0 | } |
809 | 0 | } |
810 | 0 | MOZ_CRASH("We have an always-returning default case"); |
811 | 0 | return false; |
812 | 0 | } |
813 | | |
814 | | static const JSJitInfo appendBuffer_methodinfo = { |
815 | | { (JSJitGetterOp)appendBuffer }, |
816 | | { prototypes::id::SourceBuffer }, |
817 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
818 | | JSJitInfo::Method, |
819 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
820 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
821 | | false, /* isInfallible. False in setters. */ |
822 | | false, /* isMovable. Not relevant for setters. */ |
823 | | false, /* isEliminatable. Not relevant for setters. */ |
824 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
825 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
826 | | false, /* isTypedMethod. Only relevant for methods. */ |
827 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
828 | | }; |
829 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
830 | | static_assert(0 < 1, "There is no slot for us"); |
831 | | |
832 | | MOZ_CAN_RUN_SCRIPT static bool |
833 | | appendBufferAsync(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
834 | 0 | { |
835 | 0 | AUTO_PROFILER_LABEL_FAST("SourceBuffer.appendBufferAsync", DOM, cx); |
836 | 0 |
|
837 | 0 | unsigned argcount = std::min(args.length(), 1u); |
838 | 0 | switch (argcount) { |
839 | 0 | case 1: { |
840 | 0 | if (args[0].isObject()) { |
841 | 0 | do { |
842 | 0 | RootedSpiderMonkeyInterface<ArrayBuffer> arg0(cx); |
843 | 0 | if (!arg0.Init(&args[0].toObject())) { |
844 | 0 | break; |
845 | 0 | } |
846 | 0 | FastErrorResult rv; |
847 | 0 | auto result(StrongOrRawPtr<Promise>(self->AppendBufferAsync(Constify(arg0), rv))); |
848 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
849 | 0 | return false; |
850 | 0 | } |
851 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
852 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
853 | 0 | return false; |
854 | 0 | } |
855 | 0 | return true; |
856 | 0 | } while (false); |
857 | 0 | do { |
858 | 0 | RootedSpiderMonkeyInterface<ArrayBufferView> arg0(cx); |
859 | 0 | if (!arg0.Init(&args[0].toObject())) { |
860 | 0 | break; |
861 | 0 | } |
862 | 0 | FastErrorResult rv; |
863 | 0 | auto result(StrongOrRawPtr<Promise>(self->AppendBufferAsync(Constify(arg0), rv))); |
864 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
865 | 0 | return false; |
866 | 0 | } |
867 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
868 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
869 | 0 | return false; |
870 | 0 | } |
871 | 0 | return true; |
872 | 0 | } while (false); |
873 | 0 | } |
874 | 0 | return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "1", "SourceBuffer.appendBufferAsync"); |
875 | 0 | break; |
876 | 0 | } |
877 | 0 | default: { |
878 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SourceBuffer.appendBufferAsync"); |
879 | 0 | break; |
880 | 0 | } |
881 | 0 | } |
882 | 0 | MOZ_CRASH("We have an always-returning default case"); |
883 | 0 | return false; |
884 | 0 | } |
885 | | |
886 | | MOZ_CAN_RUN_SCRIPT static bool |
887 | | appendBufferAsync_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
888 | 0 | { |
889 | 0 | bool ok = appendBufferAsync(cx, obj, self, args); |
890 | 0 | if (ok) { |
891 | 0 | return true; |
892 | 0 | } |
893 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
894 | 0 | } |
895 | | |
896 | | static const JSJitInfo appendBufferAsync_methodinfo = { |
897 | | { (JSJitGetterOp)appendBufferAsync_promiseWrapper }, |
898 | | { prototypes::id::SourceBuffer }, |
899 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
900 | | JSJitInfo::Method, |
901 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
902 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
903 | | false, /* isInfallible. False in setters. */ |
904 | | false, /* isMovable. Not relevant for setters. */ |
905 | | false, /* isEliminatable. Not relevant for setters. */ |
906 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
907 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
908 | | false, /* isTypedMethod. Only relevant for methods. */ |
909 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
910 | | }; |
911 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
912 | | static_assert(0 < 1, "There is no slot for us"); |
913 | | |
914 | | MOZ_CAN_RUN_SCRIPT static bool |
915 | | abort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
916 | 0 | { |
917 | 0 | AUTO_PROFILER_LABEL_FAST("SourceBuffer.abort", DOM, cx); |
918 | 0 |
|
919 | 0 | FastErrorResult rv; |
920 | 0 | self->Abort(rv); |
921 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
922 | 0 | return false; |
923 | 0 | } |
924 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
925 | 0 | args.rval().setUndefined(); |
926 | 0 | return true; |
927 | 0 | } |
928 | | |
929 | | static const JSJitInfo abort_methodinfo = { |
930 | | { (JSJitGetterOp)abort }, |
931 | | { prototypes::id::SourceBuffer }, |
932 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
933 | | JSJitInfo::Method, |
934 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
935 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
936 | | false, /* isInfallible. False in setters. */ |
937 | | false, /* isMovable. Not relevant for setters. */ |
938 | | false, /* isEliminatable. Not relevant for setters. */ |
939 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
940 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
941 | | false, /* isTypedMethod. Only relevant for methods. */ |
942 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
943 | | }; |
944 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
945 | | static_assert(0 < 1, "There is no slot for us"); |
946 | | |
947 | | MOZ_CAN_RUN_SCRIPT static bool |
948 | | remove(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
949 | 0 | { |
950 | 0 | AUTO_PROFILER_LABEL_FAST("SourceBuffer.remove", DOM, cx); |
951 | 0 |
|
952 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
953 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SourceBuffer.remove"); |
954 | 0 | } |
955 | 0 | double arg0; |
956 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
957 | 0 | return false; |
958 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
959 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SourceBuffer.remove"); |
960 | 0 | return false; |
961 | 0 | } |
962 | 0 | double arg1; |
963 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) { |
964 | 0 | return false; |
965 | 0 | } |
966 | 0 | FastErrorResult rv; |
967 | 0 | self->Remove(arg0, arg1, rv); |
968 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
969 | 0 | return false; |
970 | 0 | } |
971 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
972 | 0 | args.rval().setUndefined(); |
973 | 0 | return true; |
974 | 0 | } |
975 | | |
976 | | static const JSJitInfo remove_methodinfo = { |
977 | | { (JSJitGetterOp)remove }, |
978 | | { prototypes::id::SourceBuffer }, |
979 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
980 | | JSJitInfo::Method, |
981 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
982 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
983 | | false, /* isInfallible. False in setters. */ |
984 | | false, /* isMovable. Not relevant for setters. */ |
985 | | false, /* isEliminatable. Not relevant for setters. */ |
986 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
987 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
988 | | false, /* isTypedMethod. Only relevant for methods. */ |
989 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
990 | | }; |
991 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
992 | | static_assert(0 < 1, "There is no slot for us"); |
993 | | |
994 | | MOZ_CAN_RUN_SCRIPT static bool |
995 | | removeAsync(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
996 | 0 | { |
997 | 0 | AUTO_PROFILER_LABEL_FAST("SourceBuffer.removeAsync", DOM, cx); |
998 | 0 |
|
999 | 0 | if (MOZ_UNLIKELY(args.length() < 2)) { |
1000 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SourceBuffer.removeAsync"); |
1001 | 0 | } |
1002 | 0 | double arg0; |
1003 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) { |
1004 | 0 | return false; |
1005 | 0 | } else if (!mozilla::IsFinite(arg0)) { |
1006 | 0 | ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of SourceBuffer.removeAsync"); |
1007 | 0 | return false; |
1008 | 0 | } |
1009 | 0 | double arg1; |
1010 | 0 | if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) { |
1011 | 0 | return false; |
1012 | 0 | } |
1013 | 0 | FastErrorResult rv; |
1014 | 0 | auto result(StrongOrRawPtr<Promise>(self->RemoveAsync(arg0, arg1, rv))); |
1015 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1016 | 0 | return false; |
1017 | 0 | } |
1018 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1019 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1020 | 0 | return false; |
1021 | 0 | } |
1022 | 0 | return true; |
1023 | 0 | } |
1024 | | |
1025 | | MOZ_CAN_RUN_SCRIPT static bool |
1026 | | removeAsync_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
1027 | 0 | { |
1028 | 0 | bool ok = removeAsync(cx, obj, self, args); |
1029 | 0 | if (ok) { |
1030 | 0 | return true; |
1031 | 0 | } |
1032 | 0 | return ConvertExceptionToPromise(cx, args.rval()); |
1033 | 0 | } |
1034 | | |
1035 | | static const JSJitInfo removeAsync_methodinfo = { |
1036 | | { (JSJitGetterOp)removeAsync_promiseWrapper }, |
1037 | | { prototypes::id::SourceBuffer }, |
1038 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
1039 | | JSJitInfo::Method, |
1040 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1041 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
1042 | | false, /* isInfallible. False in setters. */ |
1043 | | false, /* isMovable. Not relevant for setters. */ |
1044 | | false, /* isEliminatable. Not relevant for setters. */ |
1045 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1046 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1047 | | false, /* isTypedMethod. Only relevant for methods. */ |
1048 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1049 | | }; |
1050 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1051 | | static_assert(0 < 1, "There is no slot for us"); |
1052 | | |
1053 | | MOZ_CAN_RUN_SCRIPT static bool |
1054 | | changeType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SourceBuffer* self, const JSJitMethodCallArgs& args) |
1055 | 0 | { |
1056 | 0 | AUTO_PROFILER_LABEL_FAST("SourceBuffer.changeType", DOM, cx); |
1057 | 0 |
|
1058 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1059 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SourceBuffer.changeType"); |
1060 | 0 | } |
1061 | 0 | binding_detail::FakeString arg0; |
1062 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1063 | 0 | return false; |
1064 | 0 | } |
1065 | 0 | FastErrorResult rv; |
1066 | 0 | self->ChangeType(NonNullHelper(Constify(arg0)), rv); |
1067 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1068 | 0 | return false; |
1069 | 0 | } |
1070 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1071 | 0 | args.rval().setUndefined(); |
1072 | 0 | return true; |
1073 | 0 | } |
1074 | | |
1075 | | static const JSJitInfo changeType_methodinfo = { |
1076 | | { (JSJitGetterOp)changeType }, |
1077 | | { prototypes::id::SourceBuffer }, |
1078 | | { PrototypeTraits<prototypes::id::SourceBuffer>::Depth }, |
1079 | | JSJitInfo::Method, |
1080 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1081 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1082 | | false, /* isInfallible. False in setters. */ |
1083 | | false, /* isMovable. Not relevant for setters. */ |
1084 | | false, /* isEliminatable. Not relevant for setters. */ |
1085 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1086 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1087 | | false, /* isTypedMethod. Only relevant for methods. */ |
1088 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1089 | | }; |
1090 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1091 | | static_assert(0 < 1, "There is no slot for us"); |
1092 | | |
1093 | | static bool |
1094 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1095 | 0 | { |
1096 | 0 | mozilla::dom::SourceBuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SourceBuffer>(obj); |
1097 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1098 | 0 | // obviously can't preserve if we're not initialized. |
1099 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1100 | 0 | PreserveWrapper(self); |
1101 | 0 | } |
1102 | 0 | return true; |
1103 | 0 | } |
1104 | | |
1105 | | static void |
1106 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1107 | 0 | { |
1108 | 0 | mozilla::dom::SourceBuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SourceBuffer>(obj); |
1109 | 0 | if (self) { |
1110 | 0 | ClearWrapper(self, self, obj); |
1111 | 0 | AddForDeferredFinalization<mozilla::dom::SourceBuffer>(self); |
1112 | 0 | } |
1113 | 0 | } |
1114 | | |
1115 | | static size_t |
1116 | | _objectMoved(JSObject* obj, JSObject* old) |
1117 | 0 | { |
1118 | 0 | mozilla::dom::SourceBuffer* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SourceBuffer>(obj); |
1119 | 0 | if (self) { |
1120 | 0 | UpdateWrapper(self, self, obj, old); |
1121 | 0 | } |
1122 | 0 |
|
1123 | 0 | return 0; |
1124 | 0 | } |
1125 | | |
1126 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1127 | | #if defined(__clang__) |
1128 | | #pragma clang diagnostic push |
1129 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1130 | | #endif |
1131 | | static const JSFunctionSpec sMethods_specs[] = { |
1132 | | JS_FNSPEC("appendBuffer", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&appendBuffer_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1133 | | JS_FS_END, |
1134 | | JS_FNSPEC("appendBufferAsync", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&appendBufferAsync_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1135 | | JS_FS_END, |
1136 | | JS_FNSPEC("abort", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&abort_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1137 | | JS_FNSPEC("remove", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&remove_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1138 | | JS_FS_END, |
1139 | | JS_FNSPEC("removeAsync", (GenericMethod<NormalThisPolicy, ConvertExceptionsToPromises>), reinterpret_cast<const JSJitInfo*>(&removeAsync_methodinfo), 2, JSPROP_ENUMERATE, nullptr), |
1140 | | JS_FS_END, |
1141 | | JS_FNSPEC("changeType", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&changeType_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1142 | | JS_FS_END |
1143 | | }; |
1144 | | #if defined(__clang__) |
1145 | | #pragma clang diagnostic pop |
1146 | | #endif |
1147 | | |
1148 | | // Can't be const because the pref-enabled boolean needs to be writable |
1149 | | static PrefableDisablers sMethods_disablers2 = { |
1150 | | true, false, 0, &mozilla::dom::MediaSource::ExperimentalEnabled |
1151 | | }; |
1152 | | |
1153 | | // Can't be const because the pref-enabled boolean needs to be writable |
1154 | | static PrefableDisablers sMethods_disablers7 = { |
1155 | | true, false, 0, &mozilla::dom::MediaSource::ExperimentalEnabled |
1156 | | }; |
1157 | | |
1158 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1159 | | { nullptr, &sMethods_specs[0] }, |
1160 | | { &sMethods_disablers2, &sMethods_specs[2] }, |
1161 | | { nullptr, &sMethods_specs[4] }, |
1162 | | { &sMethods_disablers7, &sMethods_specs[7] }, |
1163 | | { nullptr, &sMethods_specs[9] }, |
1164 | | { nullptr, nullptr } |
1165 | | }; |
1166 | | |
1167 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1168 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1169 | | static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1170 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1171 | | |
1172 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1173 | | #if defined(__clang__) |
1174 | | #pragma clang diagnostic push |
1175 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1176 | | #endif |
1177 | | static const JSPropertySpec sAttributes_specs[] = { |
1178 | | { "mode", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &mode_getterinfo, GenericSetter<NormalThisPolicy>, &mode_setterinfo }, |
1179 | | { "updating", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &updating_getterinfo, nullptr, nullptr }, |
1180 | | { "buffered", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &buffered_getterinfo, nullptr, nullptr }, |
1181 | | { "timestampOffset", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, ×tampOffset_getterinfo, GenericSetter<NormalThisPolicy>, ×tampOffset_setterinfo }, |
1182 | | { "appendWindowStart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &appendWindowStart_getterinfo, GenericSetter<NormalThisPolicy>, &appendWindowStart_setterinfo }, |
1183 | | { "appendWindowEnd", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &appendWindowEnd_getterinfo, GenericSetter<NormalThisPolicy>, &appendWindowEnd_setterinfo }, |
1184 | | { "onupdatestart", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onupdatestart_getterinfo, GenericSetter<NormalThisPolicy>, &onupdatestart_setterinfo }, |
1185 | | { "onupdate", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onupdate_getterinfo, GenericSetter<NormalThisPolicy>, &onupdate_setterinfo }, |
1186 | | { "onupdateend", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onupdateend_getterinfo, GenericSetter<NormalThisPolicy>, &onupdateend_setterinfo }, |
1187 | | { "onerror", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onerror_getterinfo, GenericSetter<NormalThisPolicy>, &onerror_setterinfo }, |
1188 | | { "onabort", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onabort_getterinfo, GenericSetter<NormalThisPolicy>, &onabort_setterinfo }, |
1189 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1190 | | }; |
1191 | | #if defined(__clang__) |
1192 | | #pragma clang diagnostic pop |
1193 | | #endif |
1194 | | |
1195 | | |
1196 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1197 | | { nullptr, &sAttributes_specs[0] }, |
1198 | | { nullptr, nullptr } |
1199 | | }; |
1200 | | |
1201 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1202 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1203 | | static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1204 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1205 | | |
1206 | | |
1207 | | static uint16_t sNativeProperties_sortedPropertyIndices[17]; |
1208 | | static PropertyInfo sNativeProperties_propertyInfos[17]; |
1209 | | |
1210 | | static const NativePropertiesN<2> sNativeProperties = { |
1211 | | false, 0, |
1212 | | false, 0, |
1213 | | true, 0 /* sMethods */, |
1214 | | true, 1 /* sAttributes */, |
1215 | | false, 0, |
1216 | | false, 0, |
1217 | | false, 0, |
1218 | | -1, |
1219 | | 17, |
1220 | | sNativeProperties_sortedPropertyIndices, |
1221 | | { |
1222 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1223 | | { sAttributes, &sNativeProperties_propertyInfos[6] } |
1224 | | } |
1225 | | }; |
1226 | | static_assert(17 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1227 | | "We have a property info count that is oversized"); |
1228 | | |
1229 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1230 | | { |
1231 | | "Function", |
1232 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1233 | | &sBoringInterfaceObjectClassClassOps, |
1234 | | JS_NULL_CLASS_SPEC, |
1235 | | JS_NULL_CLASS_EXT, |
1236 | | &sInterfaceObjectClassObjectOps |
1237 | | }, |
1238 | | eInterface, |
1239 | | true, |
1240 | | prototypes::id::SourceBuffer, |
1241 | | PrototypeTraits<prototypes::id::SourceBuffer>::Depth, |
1242 | | sNativePropertyHooks, |
1243 | | "function SourceBuffer() {\n [native code]\n}", |
1244 | | EventTarget_Binding::GetConstructorObject |
1245 | | }; |
1246 | | |
1247 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1248 | | { |
1249 | | "SourceBufferPrototype", |
1250 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1251 | | JS_NULL_CLASS_OPS, |
1252 | | JS_NULL_CLASS_SPEC, |
1253 | | JS_NULL_CLASS_EXT, |
1254 | | JS_NULL_OBJECT_OPS |
1255 | | }, |
1256 | | eInterfacePrototype, |
1257 | | false, |
1258 | | prototypes::id::SourceBuffer, |
1259 | | PrototypeTraits<prototypes::id::SourceBuffer>::Depth, |
1260 | | sNativePropertyHooks, |
1261 | | "[object SourceBufferPrototype]", |
1262 | | EventTarget_Binding::GetProtoObject |
1263 | | }; |
1264 | | |
1265 | | bool |
1266 | | ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj) |
1267 | 0 | { |
1268 | 0 | return mozilla::dom::MediaSource::Enabled(aCx, aObj); |
1269 | 0 | } |
1270 | | |
1271 | | static const js::ClassOps sClassOps = { |
1272 | | _addProperty, /* addProperty */ |
1273 | | nullptr, /* delProperty */ |
1274 | | nullptr, /* enumerate */ |
1275 | | nullptr, /* newEnumerate */ |
1276 | | nullptr, /* resolve */ |
1277 | | nullptr, /* mayResolve */ |
1278 | | _finalize, /* finalize */ |
1279 | | nullptr, /* call */ |
1280 | | nullptr, /* hasInstance */ |
1281 | | nullptr, /* construct */ |
1282 | | nullptr, /* trace */ |
1283 | | }; |
1284 | | |
1285 | | static const js::ClassExtension sClassExtension = { |
1286 | | nullptr, /* weakmapKeyDelegateOp */ |
1287 | | _objectMoved /* objectMovedOp */ |
1288 | | }; |
1289 | | |
1290 | | static const DOMJSClass sClass = { |
1291 | | { "SourceBuffer", |
1292 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1293 | | &sClassOps, |
1294 | | JS_NULL_CLASS_SPEC, |
1295 | | &sClassExtension, |
1296 | | JS_NULL_OBJECT_OPS |
1297 | | }, |
1298 | | { prototypes::id::EventTarget, prototypes::id::SourceBuffer, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1299 | | IsBaseOf<nsISupports, mozilla::dom::SourceBuffer >::value, |
1300 | | sNativePropertyHooks, |
1301 | | FindAssociatedGlobalForNative<mozilla::dom::SourceBuffer>::Get, |
1302 | | GetProtoObjectHandle, |
1303 | | GetCCParticipant<mozilla::dom::SourceBuffer>::Get() |
1304 | | }; |
1305 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1306 | | "Must have the right minimal number of reserved slots."); |
1307 | | static_assert(1 >= 1, |
1308 | | "Must have enough reserved slots."); |
1309 | | |
1310 | | const JSClass* |
1311 | | GetJSClass() |
1312 | 0 | { |
1313 | 0 | return sClass.ToJSClass(); |
1314 | 0 | } |
1315 | | |
1316 | | bool |
1317 | | Wrap(JSContext* aCx, mozilla::dom::SourceBuffer* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1318 | 0 | { |
1319 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::SourceBuffer>::value, |
1320 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1321 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::SourceBuffer*>(aObject) == |
1322 | 0 | reinterpret_cast<mozilla::dom::SourceBuffer*>(aObject), |
1323 | 0 | "Multiple inheritance for mozilla::dom::SourceBuffer is broken."); |
1324 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1325 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1326 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1327 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1328 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1329 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1330 | 0 | "You should probably not be using Wrap() directly; use " |
1331 | 0 | "GetOrCreateDOMReflector instead"); |
1332 | 0 |
|
1333 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1334 | 0 | "nsISupports must be on our primary inheritance chain"); |
1335 | 0 |
|
1336 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1337 | 0 | if (!global) { |
1338 | 0 | return false; |
1339 | 0 | } |
1340 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1341 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1342 | 0 |
|
1343 | 0 | // That might have ended up wrapping us already, due to the wonders |
1344 | 0 | // of XBL. Check for that, and bail out as needed. |
1345 | 0 | aReflector.set(aCache->GetWrapper()); |
1346 | 0 | if (aReflector) { |
1347 | | #ifdef DEBUG |
1348 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1349 | | #endif // DEBUG |
1350 | | return true; |
1351 | 0 | } |
1352 | 0 |
|
1353 | 0 | JSAutoRealm ar(aCx, global); |
1354 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1355 | 0 | if (!canonicalProto) { |
1356 | 0 | return false; |
1357 | 0 | } |
1358 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1359 | 0 | if (aGivenProto) { |
1360 | 0 | proto = aGivenProto; |
1361 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1362 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1363 | 0 | // to wrap the proto here. |
1364 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1365 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1366 | 0 | return false; |
1367 | 0 | } |
1368 | 0 | } |
1369 | 0 | } else { |
1370 | 0 | proto = canonicalProto; |
1371 | 0 | } |
1372 | 0 |
|
1373 | 0 | BindingJSObjectCreator<mozilla::dom::SourceBuffer> creator(aCx); |
1374 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1375 | 0 | if (!aReflector) { |
1376 | 0 | return false; |
1377 | 0 | } |
1378 | 0 | |
1379 | 0 | aCache->SetWrapper(aReflector); |
1380 | 0 | creator.InitializationSucceeded(); |
1381 | 0 |
|
1382 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1383 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1384 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1385 | 0 | // otherwise we won't be able to properly recreate it later, since |
1386 | 0 | // we won't know what proto to use. Note that we don't check |
1387 | 0 | // aGivenProto here, since it's entirely possible (and even |
1388 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1389 | 0 | // same as canonicalProto. |
1390 | 0 | if (proto != canonicalProto) { |
1391 | 0 | PreserveWrapper(aObject); |
1392 | 0 | } |
1393 | 0 |
|
1394 | 0 | return true; |
1395 | 0 | } |
1396 | | |
1397 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1398 | | nullptr, |
1399 | | nullptr, |
1400 | | nullptr, |
1401 | | { sNativeProperties.Upcast(), nullptr }, |
1402 | | prototypes::id::SourceBuffer, |
1403 | | constructors::id::SourceBuffer, |
1404 | | EventTarget_Binding::sNativePropertyHooks, |
1405 | | &DefaultXrayExpandoObjectClass |
1406 | | } }; |
1407 | | |
1408 | | void |
1409 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1410 | 0 | { |
1411 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
1412 | 0 | if (!parentProto) { |
1413 | 0 | return; |
1414 | 0 | } |
1415 | 0 | |
1416 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
1417 | 0 | if (!constructorProto) { |
1418 | 0 | return; |
1419 | 0 | } |
1420 | 0 | |
1421 | 0 | static bool sIdsInited = false; |
1422 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1423 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1424 | 0 | return; |
1425 | 0 | } |
1426 | 0 | sIdsInited = true; |
1427 | 0 | } |
1428 | 0 |
|
1429 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SourceBuffer); |
1430 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SourceBuffer); |
1431 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1432 | 0 | &sPrototypeClass.mBase, protoCache, |
1433 | 0 | nullptr, |
1434 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1435 | 0 | interfaceCache, |
1436 | 0 | sNativeProperties.Upcast(), |
1437 | 0 | nullptr, |
1438 | 0 | "SourceBuffer", aDefineOnGlobal, |
1439 | 0 | nullptr, |
1440 | 0 | false); |
1441 | 0 | } |
1442 | | |
1443 | | JSObject* |
1444 | | GetConstructorObject(JSContext* aCx) |
1445 | 0 | { |
1446 | 0 | return GetConstructorObjectHandle(aCx); |
1447 | 0 | } |
1448 | | |
1449 | | } // namespace SourceBuffer_Binding |
1450 | | |
1451 | | |
1452 | | |
1453 | | } // namespace dom |
1454 | | } // namespace mozilla |