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