Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM MediaRecorder.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "DOMMediaStream.h"
5 : #include "EventHandlerBinding.h"
6 : #include "EventTargetBinding.h"
7 : #include "MediaRecorder.h"
8 : #include "MediaRecorderBinding.h"
9 : #include "WrapperFactory.h"
10 : #include "jsapi.h"
11 : #include "mozilla/OwningNonNull.h"
12 : #include "mozilla/dom/AudioNode.h"
13 : #include "mozilla/dom/BindingUtils.h"
14 : #include "mozilla/dom/DOMJSClass.h"
15 : #include "mozilla/dom/NonRefcountedDOMObject.h"
16 : #include "mozilla/dom/Nullable.h"
17 : #include "mozilla/dom/PrimitiveConversions.h"
18 : #include "mozilla/dom/ScriptSettings.h"
19 : #include "mozilla/dom/SimpleGlobalObject.h"
20 : #include "mozilla/dom/XrayExpandoClass.h"
21 :
22 : namespace mozilla {
23 : namespace dom {
24 :
25 : namespace RecordingStateValues {
26 : extern const EnumEntry strings[4] = {
27 : {"inactive", 8},
28 : {"recording", 9},
29 : {"paused", 6},
30 : { nullptr, 0 }
31 : };
32 : } // namespace RecordingStateValues
33 :
34 : bool
35 0 : ToJSValue(JSContext* aCx, RecordingState aArgument, JS::MutableHandle<JS::Value> aValue)
36 : {
37 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(RecordingStateValues::strings));
38 : JSString* resultStr =
39 0 : JS_NewStringCopyN(aCx, RecordingStateValues::strings[uint32_t(aArgument)].value,
40 0 : RecordingStateValues::strings[uint32_t(aArgument)].length);
41 0 : if (!resultStr) {
42 0 : return false;
43 : }
44 0 : aValue.setString(resultStr);
45 0 : return true;
46 : }
47 :
48 :
49 :
50 0 : MediaRecorderOptions::MediaRecorderOptions()
51 : {
52 : // Safe to pass a null context if we pass a null value
53 0 : Init(nullptr, JS::NullHandleValue);
54 0 : }
55 :
56 :
57 :
58 : bool
59 0 : MediaRecorderOptions::InitIds(JSContext* cx, MediaRecorderOptionsAtoms* atomsCache)
60 : {
61 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
62 :
63 : // Initialize these in reverse order so that any failure leaves the first one
64 : // uninitialized.
65 0 : if (!atomsCache->videoBitsPerSecond_id.init(cx, "videoBitsPerSecond") ||
66 0 : !atomsCache->mimeType_id.init(cx, "mimeType") ||
67 0 : !atomsCache->bitsPerSecond_id.init(cx, "bitsPerSecond") ||
68 0 : !atomsCache->audioBitsPerSecond_id.init(cx, "audioBitsPerSecond")) {
69 0 : return false;
70 : }
71 0 : return true;
72 : }
73 :
74 : bool
75 0 : MediaRecorderOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
76 : {
77 : // Passing a null JSContext is OK only if we're initing from null,
78 : // Since in that case we will not have to do any property gets
79 : // Also evaluate isNullOrUndefined in order to avoid false-positive
80 : // checkers by static analysis tools
81 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
82 0 : MediaRecorderOptionsAtoms* atomsCache = nullptr;
83 0 : if (cx) {
84 0 : atomsCache = GetAtomCache<MediaRecorderOptionsAtoms>(cx);
85 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
86 0 : return false;
87 : }
88 : }
89 :
90 0 : if (!IsConvertibleToDictionary(val)) {
91 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
92 : }
93 :
94 0 : bool isNull = val.isNullOrUndefined();
95 : // We only need these if !isNull, in which case we have |cx|.
96 0 : Maybe<JS::Rooted<JSObject *> > object;
97 0 : Maybe<JS::Rooted<JS::Value> > temp;
98 0 : if (!isNull) {
99 0 : MOZ_ASSERT(cx);
100 0 : object.emplace(cx, &val.toObject());
101 0 : temp.emplace(cx);
102 : }
103 0 : if (!isNull) {
104 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->audioBitsPerSecond_id, temp.ptr())) {
105 0 : return false;
106 : }
107 : }
108 0 : if (!isNull && !temp->isUndefined()) {
109 0 : mAudioBitsPerSecond.Construct();
110 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mAudioBitsPerSecond.Value()))) {
111 0 : return false;
112 : }
113 0 : mIsAnyMemberPresent = true;
114 : }
115 :
116 0 : if (!isNull) {
117 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->bitsPerSecond_id, temp.ptr())) {
118 0 : return false;
119 : }
120 : }
121 0 : if (!isNull && !temp->isUndefined()) {
122 0 : mBitsPerSecond.Construct();
123 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mBitsPerSecond.Value()))) {
124 0 : return false;
125 : }
126 0 : mIsAnyMemberPresent = true;
127 : }
128 :
129 0 : if (!isNull) {
130 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->mimeType_id, temp.ptr())) {
131 0 : return false;
132 : }
133 : }
134 0 : if (!isNull && !temp->isUndefined()) {
135 0 : if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mMimeType)) {
136 0 : return false;
137 : }
138 : } else {
139 : static const char16_t data[] = { 0 };
140 0 : mMimeType.Rebind(data, ArrayLength(data) - 1);
141 : }
142 0 : mIsAnyMemberPresent = true;
143 :
144 0 : if (!isNull) {
145 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->videoBitsPerSecond_id, temp.ptr())) {
146 0 : return false;
147 : }
148 : }
149 0 : if (!isNull && !temp->isUndefined()) {
150 0 : mVideoBitsPerSecond.Construct();
151 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mVideoBitsPerSecond.Value()))) {
152 0 : return false;
153 : }
154 0 : mIsAnyMemberPresent = true;
155 : }
156 0 : return true;
157 : }
158 :
159 : bool
160 0 : MediaRecorderOptions::Init(const nsAString& aJSON)
161 : {
162 0 : AutoJSAPI jsapi;
163 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
164 0 : if (!cleanGlobal) {
165 0 : return false;
166 : }
167 0 : if (!jsapi.Init(cleanGlobal)) {
168 0 : return false;
169 : }
170 0 : JSContext* cx = jsapi.cx();
171 0 : JS::Rooted<JS::Value> json(cx);
172 0 : bool ok = ParseJSON(cx, aJSON, &json);
173 0 : NS_ENSURE_TRUE(ok, false);
174 0 : return Init(cx, json);
175 : }
176 :
177 : bool
178 0 : MediaRecorderOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
179 : {
180 0 : MediaRecorderOptionsAtoms* atomsCache = GetAtomCache<MediaRecorderOptionsAtoms>(cx);
181 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
182 0 : return false;
183 : }
184 :
185 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
186 0 : if (!obj) {
187 0 : return false;
188 : }
189 0 : rval.set(JS::ObjectValue(*obj));
190 :
191 0 : if (mAudioBitsPerSecond.WasPassed()) {
192 : do {
193 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
194 0 : JS::Rooted<JS::Value> temp(cx);
195 0 : uint32_t const & currentValue = mAudioBitsPerSecond.InternalValue();
196 0 : temp.setNumber(currentValue);
197 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->audioBitsPerSecond_id, temp, JSPROP_ENUMERATE)) {
198 0 : return false;
199 : }
200 0 : break;
201 : } while(0);
202 : }
203 :
204 0 : if (mBitsPerSecond.WasPassed()) {
205 : do {
206 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
207 0 : JS::Rooted<JS::Value> temp(cx);
208 0 : uint32_t const & currentValue = mBitsPerSecond.InternalValue();
209 0 : temp.setNumber(currentValue);
210 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->bitsPerSecond_id, temp, JSPROP_ENUMERATE)) {
211 0 : return false;
212 : }
213 0 : break;
214 : } while(0);
215 : }
216 :
217 : do {
218 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
219 0 : JS::Rooted<JS::Value> temp(cx);
220 0 : nsString const & currentValue = mMimeType;
221 0 : if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
222 0 : return false;
223 : }
224 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->mimeType_id, temp, JSPROP_ENUMERATE)) {
225 0 : return false;
226 : }
227 0 : break;
228 : } while(0);
229 :
230 0 : if (mVideoBitsPerSecond.WasPassed()) {
231 : do {
232 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
233 0 : JS::Rooted<JS::Value> temp(cx);
234 0 : uint32_t const & currentValue = mVideoBitsPerSecond.InternalValue();
235 0 : temp.setNumber(currentValue);
236 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->videoBitsPerSecond_id, temp, JSPROP_ENUMERATE)) {
237 0 : return false;
238 : }
239 0 : break;
240 : } while(0);
241 : }
242 :
243 0 : return true;
244 : }
245 :
246 : bool
247 0 : MediaRecorderOptions::ToJSON(nsAString& aJSON) const
248 : {
249 0 : AutoJSAPI jsapi;
250 0 : jsapi.Init();
251 0 : JSContext *cx = jsapi.cx();
252 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
253 : // because we'll only be creating objects, in ways that have no
254 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
255 : // which likewise guarantees no side-effects for the sorts of
256 : // things we will pass it.
257 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
258 0 : JS::Rooted<JS::Value> val(cx);
259 0 : if (!ToObjectInternal(cx, &val)) {
260 0 : return false;
261 : }
262 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
263 0 : return StringifyToJSON(cx, obj, aJSON);
264 : }
265 :
266 : void
267 0 : MediaRecorderOptions::TraceDictionary(JSTracer* trc)
268 : {
269 0 : }
270 :
271 : MediaRecorderOptions&
272 0 : MediaRecorderOptions::operator=(const MediaRecorderOptions& aOther)
273 : {
274 0 : mAudioBitsPerSecond.Reset();
275 0 : if (aOther.mAudioBitsPerSecond.WasPassed()) {
276 0 : mAudioBitsPerSecond.Construct(aOther.mAudioBitsPerSecond.Value());
277 : }
278 0 : mBitsPerSecond.Reset();
279 0 : if (aOther.mBitsPerSecond.WasPassed()) {
280 0 : mBitsPerSecond.Construct(aOther.mBitsPerSecond.Value());
281 : }
282 0 : mMimeType = aOther.mMimeType;
283 0 : mVideoBitsPerSecond.Reset();
284 0 : if (aOther.mVideoBitsPerSecond.WasPassed()) {
285 0 : mVideoBitsPerSecond.Construct(aOther.mVideoBitsPerSecond.Value());
286 : }
287 0 : return *this;
288 : }
289 :
290 : namespace binding_detail {
291 : } // namespace binding_detail
292 :
293 :
294 : namespace MediaRecorderBinding {
295 :
296 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
297 : "Can't inherit from an interface with a different ownership model.");
298 :
299 : static bool
300 0 : get_stream(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
301 : {
302 0 : auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->Stream()));
303 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
304 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
305 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
306 0 : return false;
307 : }
308 0 : return true;
309 : }
310 :
311 : static const JSJitInfo stream_getterinfo = {
312 : { (JSJitGetterOp)get_stream },
313 : { prototypes::id::MediaRecorder },
314 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
315 : JSJitInfo::Getter,
316 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
317 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
318 : false, /* isInfallible. False in setters. */
319 : false, /* isMovable. Not relevant for setters. */
320 : false, /* isEliminatable. Not relevant for setters. */
321 : false, /* isAlwaysInSlot. Only relevant for getters. */
322 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
323 : false, /* isTypedMethod. Only relevant for methods. */
324 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
325 : };
326 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
327 : static_assert(0 < 1, "There is no slot for us");
328 :
329 : static bool
330 0 : get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
331 : {
332 0 : RecordingState result(self->State());
333 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
334 0 : if (!ToJSValue(cx, result, args.rval())) {
335 0 : return false;
336 : }
337 0 : return true;
338 : }
339 :
340 : static const JSJitInfo state_getterinfo = {
341 : { (JSJitGetterOp)get_state },
342 : { prototypes::id::MediaRecorder },
343 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
344 : JSJitInfo::Getter,
345 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
346 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
347 : false, /* isInfallible. False in setters. */
348 : false, /* isMovable. Not relevant for setters. */
349 : false, /* isEliminatable. Not relevant for setters. */
350 : false, /* isAlwaysInSlot. Only relevant for getters. */
351 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
352 : false, /* isTypedMethod. Only relevant for methods. */
353 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
354 : };
355 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
356 : static_assert(0 < 1, "There is no slot for us");
357 :
358 : static bool
359 0 : get_mimeType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
360 : {
361 0 : DOMString result;
362 0 : self->GetMimeType(result);
363 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
364 0 : if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
365 0 : return false;
366 : }
367 0 : return true;
368 : }
369 :
370 : static const JSJitInfo mimeType_getterinfo = {
371 : { (JSJitGetterOp)get_mimeType },
372 : { prototypes::id::MediaRecorder },
373 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
374 : JSJitInfo::Getter,
375 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
376 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
377 : false, /* isInfallible. False in setters. */
378 : false, /* isMovable. Not relevant for setters. */
379 : false, /* isEliminatable. Not relevant for setters. */
380 : false, /* isAlwaysInSlot. Only relevant for getters. */
381 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
382 : false, /* isTypedMethod. Only relevant for methods. */
383 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
384 : };
385 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
386 : static_assert(0 < 1, "There is no slot for us");
387 :
388 : static bool
389 0 : get_ondataavailable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
390 : {
391 0 : RefPtr<EventHandlerNonNull> result(self->GetOndataavailable());
392 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
393 0 : if (result) {
394 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
395 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
396 0 : return false;
397 : }
398 0 : return true;
399 : } else {
400 0 : args.rval().setNull();
401 0 : return true;
402 : }
403 : }
404 :
405 : static bool
406 0 : set_ondataavailable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitSetterCallArgs args)
407 : {
408 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
409 0 : if (args[0].isObject()) {
410 : { // scope for tempRoot
411 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
412 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
413 : }
414 : } else {
415 0 : arg0 = nullptr;
416 : }
417 0 : self->SetOndataavailable(Constify(arg0));
418 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
419 :
420 0 : return true;
421 : }
422 :
423 : static const JSJitInfo ondataavailable_getterinfo = {
424 : { (JSJitGetterOp)get_ondataavailable },
425 : { prototypes::id::MediaRecorder },
426 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
427 : JSJitInfo::Getter,
428 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
429 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
430 : false, /* isInfallible. False in setters. */
431 : false, /* isMovable. Not relevant for setters. */
432 : false, /* isEliminatable. Not relevant for setters. */
433 : false, /* isAlwaysInSlot. Only relevant for getters. */
434 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
435 : false, /* isTypedMethod. Only relevant for methods. */
436 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
437 : };
438 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
439 : static_assert(0 < 1, "There is no slot for us");
440 : static const JSJitInfo ondataavailable_setterinfo = {
441 : { (JSJitGetterOp)set_ondataavailable },
442 : { prototypes::id::MediaRecorder },
443 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
444 : JSJitInfo::Setter,
445 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
446 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
447 : false, /* isInfallible. False in setters. */
448 : false, /* isMovable. Not relevant for setters. */
449 : false, /* isEliminatable. Not relevant for setters. */
450 : false, /* isAlwaysInSlot. Only relevant for getters. */
451 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
452 : false, /* isTypedMethod. Only relevant for methods. */
453 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
454 : };
455 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
456 : static_assert(0 < 1, "There is no slot for us");
457 :
458 : static bool
459 0 : get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
460 : {
461 0 : RefPtr<EventHandlerNonNull> result(self->GetOnerror());
462 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
463 0 : if (result) {
464 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
465 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
466 0 : return false;
467 : }
468 0 : return true;
469 : } else {
470 0 : args.rval().setNull();
471 0 : return true;
472 : }
473 : }
474 :
475 : static bool
476 0 : set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitSetterCallArgs args)
477 : {
478 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
479 0 : if (args[0].isObject()) {
480 : { // scope for tempRoot
481 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
482 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
483 : }
484 : } else {
485 0 : arg0 = nullptr;
486 : }
487 0 : self->SetOnerror(Constify(arg0));
488 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
489 :
490 0 : return true;
491 : }
492 :
493 : static const JSJitInfo onerror_getterinfo = {
494 : { (JSJitGetterOp)get_onerror },
495 : { prototypes::id::MediaRecorder },
496 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
497 : JSJitInfo::Getter,
498 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
499 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
500 : false, /* isInfallible. False in setters. */
501 : false, /* isMovable. Not relevant for setters. */
502 : false, /* isEliminatable. Not relevant for setters. */
503 : false, /* isAlwaysInSlot. Only relevant for getters. */
504 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
505 : false, /* isTypedMethod. Only relevant for methods. */
506 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
507 : };
508 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
509 : static_assert(0 < 1, "There is no slot for us");
510 : static const JSJitInfo onerror_setterinfo = {
511 : { (JSJitGetterOp)set_onerror },
512 : { prototypes::id::MediaRecorder },
513 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
514 : JSJitInfo::Setter,
515 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
516 : JSVAL_TYPE_UNDEFINED, /* 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 :
528 : static bool
529 0 : get_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
530 : {
531 0 : RefPtr<EventHandlerNonNull> result(self->GetOnstart());
532 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
533 0 : if (result) {
534 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
535 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
536 0 : return false;
537 : }
538 0 : return true;
539 : } else {
540 0 : args.rval().setNull();
541 0 : return true;
542 : }
543 : }
544 :
545 : static bool
546 0 : set_onstart(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitSetterCallArgs args)
547 : {
548 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
549 0 : if (args[0].isObject()) {
550 : { // scope for tempRoot
551 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
552 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
553 : }
554 : } else {
555 0 : arg0 = nullptr;
556 : }
557 0 : self->SetOnstart(Constify(arg0));
558 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
559 :
560 0 : return true;
561 : }
562 :
563 : static const JSJitInfo onstart_getterinfo = {
564 : { (JSJitGetterOp)get_onstart },
565 : { prototypes::id::MediaRecorder },
566 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
567 : JSJitInfo::Getter,
568 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
569 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
570 : false, /* isInfallible. False in setters. */
571 : false, /* isMovable. Not relevant for setters. */
572 : false, /* isEliminatable. Not relevant for setters. */
573 : false, /* isAlwaysInSlot. Only relevant for getters. */
574 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
575 : false, /* isTypedMethod. Only relevant for methods. */
576 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
577 : };
578 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
579 : static_assert(0 < 1, "There is no slot for us");
580 : static const JSJitInfo onstart_setterinfo = {
581 : { (JSJitGetterOp)set_onstart },
582 : { prototypes::id::MediaRecorder },
583 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
584 : JSJitInfo::Setter,
585 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
586 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
587 : false, /* isInfallible. False in setters. */
588 : false, /* isMovable. Not relevant for setters. */
589 : false, /* isEliminatable. Not relevant for setters. */
590 : false, /* isAlwaysInSlot. Only relevant for getters. */
591 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
592 : false, /* isTypedMethod. Only relevant for methods. */
593 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
594 : };
595 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
596 : static_assert(0 < 1, "There is no slot for us");
597 :
598 : static bool
599 0 : get_onstop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
600 : {
601 0 : RefPtr<EventHandlerNonNull> result(self->GetOnstop());
602 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
603 0 : if (result) {
604 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
605 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
606 0 : return false;
607 : }
608 0 : return true;
609 : } else {
610 0 : args.rval().setNull();
611 0 : return true;
612 : }
613 : }
614 :
615 : static bool
616 0 : set_onstop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitSetterCallArgs args)
617 : {
618 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
619 0 : if (args[0].isObject()) {
620 : { // scope for tempRoot
621 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
622 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
623 : }
624 : } else {
625 0 : arg0 = nullptr;
626 : }
627 0 : self->SetOnstop(Constify(arg0));
628 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
629 :
630 0 : return true;
631 : }
632 :
633 : static const JSJitInfo onstop_getterinfo = {
634 : { (JSJitGetterOp)get_onstop },
635 : { prototypes::id::MediaRecorder },
636 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
637 : JSJitInfo::Getter,
638 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
639 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
640 : false, /* isInfallible. False in setters. */
641 : false, /* isMovable. Not relevant for setters. */
642 : false, /* isEliminatable. Not relevant for setters. */
643 : false, /* isAlwaysInSlot. Only relevant for getters. */
644 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
645 : false, /* isTypedMethod. Only relevant for methods. */
646 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
647 : };
648 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
649 : static_assert(0 < 1, "There is no slot for us");
650 : static const JSJitInfo onstop_setterinfo = {
651 : { (JSJitGetterOp)set_onstop },
652 : { prototypes::id::MediaRecorder },
653 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
654 : JSJitInfo::Setter,
655 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
656 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
657 : false, /* isInfallible. False in setters. */
658 : false, /* isMovable. Not relevant for setters. */
659 : false, /* isEliminatable. Not relevant for setters. */
660 : false, /* isAlwaysInSlot. Only relevant for getters. */
661 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
662 : false, /* isTypedMethod. Only relevant for methods. */
663 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
664 : };
665 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
666 : static_assert(0 < 1, "There is no slot for us");
667 :
668 : static bool
669 0 : get_onwarning(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitGetterCallArgs args)
670 : {
671 0 : RefPtr<EventHandlerNonNull> result(self->GetOnwarning());
672 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
673 0 : if (result) {
674 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
675 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
676 0 : return false;
677 : }
678 0 : return true;
679 : } else {
680 0 : args.rval().setNull();
681 0 : return true;
682 : }
683 : }
684 :
685 : static bool
686 0 : set_onwarning(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, JSJitSetterCallArgs args)
687 : {
688 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
689 0 : if (args[0].isObject()) {
690 : { // scope for tempRoot
691 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
692 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
693 : }
694 : } else {
695 0 : arg0 = nullptr;
696 : }
697 0 : self->SetOnwarning(Constify(arg0));
698 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
699 :
700 0 : return true;
701 : }
702 :
703 : static const JSJitInfo onwarning_getterinfo = {
704 : { (JSJitGetterOp)get_onwarning },
705 : { prototypes::id::MediaRecorder },
706 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
707 : JSJitInfo::Getter,
708 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
709 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
710 : false, /* isInfallible. False in setters. */
711 : false, /* isMovable. Not relevant for setters. */
712 : false, /* isEliminatable. Not relevant for setters. */
713 : false, /* isAlwaysInSlot. Only relevant for getters. */
714 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
715 : false, /* isTypedMethod. Only relevant for methods. */
716 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
717 : };
718 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
719 : static_assert(0 < 1, "There is no slot for us");
720 : static const JSJitInfo onwarning_setterinfo = {
721 : { (JSJitGetterOp)set_onwarning },
722 : { prototypes::id::MediaRecorder },
723 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
724 : JSJitInfo::Setter,
725 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
726 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
727 : false, /* isInfallible. False in setters. */
728 : false, /* isMovable. Not relevant for setters. */
729 : false, /* isEliminatable. Not relevant for setters. */
730 : false, /* isAlwaysInSlot. Only relevant for getters. */
731 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
732 : false, /* isTypedMethod. Only relevant for methods. */
733 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
734 : };
735 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
736 : static_assert(0 < 1, "There is no slot for us");
737 :
738 : static bool
739 0 : start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, const JSJitMethodCallArgs& args)
740 : {
741 0 : Optional<int32_t> arg0;
742 0 : if (args.hasDefined(0)) {
743 0 : arg0.Construct();
744 0 : if (!ValueToPrimitive<int32_t, eDefault>(cx, args[0], &arg0.Value())) {
745 0 : return false;
746 : }
747 : }
748 0 : binding_detail::FastErrorResult rv;
749 0 : self->Start(Constify(arg0), rv);
750 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
751 0 : return false;
752 : }
753 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
754 0 : args.rval().setUndefined();
755 0 : return true;
756 : }
757 :
758 : static const JSJitInfo start_methodinfo = {
759 : { (JSJitGetterOp)start },
760 : { prototypes::id::MediaRecorder },
761 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
762 : JSJitInfo::Method,
763 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
764 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
765 : false, /* isInfallible. False in setters. */
766 : false, /* isMovable. Not relevant for setters. */
767 : false, /* isEliminatable. Not relevant for setters. */
768 : false, /* isAlwaysInSlot. Only relevant for getters. */
769 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
770 : false, /* isTypedMethod. Only relevant for methods. */
771 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
772 : };
773 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
774 : static_assert(0 < 1, "There is no slot for us");
775 :
776 : static bool
777 0 : stop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, const JSJitMethodCallArgs& args)
778 : {
779 0 : binding_detail::FastErrorResult rv;
780 0 : self->Stop(rv);
781 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
782 0 : return false;
783 : }
784 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
785 0 : args.rval().setUndefined();
786 0 : return true;
787 : }
788 :
789 : static const JSJitInfo stop_methodinfo = {
790 : { (JSJitGetterOp)stop },
791 : { prototypes::id::MediaRecorder },
792 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
793 : JSJitInfo::Method,
794 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
795 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
796 : false, /* isInfallible. False in setters. */
797 : false, /* isMovable. Not relevant for setters. */
798 : false, /* isEliminatable. Not relevant for setters. */
799 : false, /* isAlwaysInSlot. Only relevant for getters. */
800 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
801 : false, /* isTypedMethod. Only relevant for methods. */
802 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
803 : };
804 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
805 : static_assert(0 < 1, "There is no slot for us");
806 :
807 : static bool
808 0 : pause(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, const JSJitMethodCallArgs& args)
809 : {
810 0 : binding_detail::FastErrorResult rv;
811 0 : self->Pause(rv);
812 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
813 0 : return false;
814 : }
815 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
816 0 : args.rval().setUndefined();
817 0 : return true;
818 : }
819 :
820 : static const JSJitInfo pause_methodinfo = {
821 : { (JSJitGetterOp)pause },
822 : { prototypes::id::MediaRecorder },
823 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
824 : JSJitInfo::Method,
825 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
826 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
827 : false, /* isInfallible. False in setters. */
828 : false, /* isMovable. Not relevant for setters. */
829 : false, /* isEliminatable. Not relevant for setters. */
830 : false, /* isAlwaysInSlot. Only relevant for getters. */
831 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
832 : false, /* isTypedMethod. Only relevant for methods. */
833 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
834 : };
835 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
836 : static_assert(0 < 1, "There is no slot for us");
837 :
838 : static bool
839 0 : resume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, const JSJitMethodCallArgs& args)
840 : {
841 0 : binding_detail::FastErrorResult rv;
842 0 : self->Resume(rv);
843 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
844 0 : return false;
845 : }
846 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
847 0 : args.rval().setUndefined();
848 0 : return true;
849 : }
850 :
851 : static const JSJitInfo resume_methodinfo = {
852 : { (JSJitGetterOp)resume },
853 : { prototypes::id::MediaRecorder },
854 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
855 : JSJitInfo::Method,
856 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
857 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
858 : false, /* isInfallible. False in setters. */
859 : false, /* isMovable. Not relevant for setters. */
860 : false, /* isEliminatable. Not relevant for setters. */
861 : false, /* isAlwaysInSlot. Only relevant for getters. */
862 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
863 : false, /* isTypedMethod. Only relevant for methods. */
864 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
865 : };
866 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
867 : static_assert(0 < 1, "There is no slot for us");
868 :
869 : static bool
870 0 : requestData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::MediaRecorder* self, const JSJitMethodCallArgs& args)
871 : {
872 0 : binding_detail::FastErrorResult rv;
873 0 : self->RequestData(rv);
874 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
875 0 : return false;
876 : }
877 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
878 0 : args.rval().setUndefined();
879 0 : return true;
880 : }
881 :
882 : static const JSJitInfo requestData_methodinfo = {
883 : { (JSJitGetterOp)requestData },
884 : { prototypes::id::MediaRecorder },
885 : { PrototypeTraits<prototypes::id::MediaRecorder>::Depth },
886 : JSJitInfo::Method,
887 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
888 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
889 : false, /* isInfallible. False in setters. */
890 : false, /* isMovable. Not relevant for setters. */
891 : false, /* isEliminatable. Not relevant for setters. */
892 : false, /* isAlwaysInSlot. Only relevant for getters. */
893 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
894 : false, /* isTypedMethod. Only relevant for methods. */
895 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
896 : };
897 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
898 : static_assert(0 < 1, "There is no slot for us");
899 :
900 : static bool
901 0 : isTypeSupported(JSContext* cx, unsigned argc, JS::Value* vp)
902 : {
903 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
904 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
905 :
906 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
907 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaRecorder.isTypeSupported");
908 : }
909 0 : GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj));
910 0 : if (global.Failed()) {
911 0 : return false;
912 : }
913 :
914 0 : binding_detail::FakeString arg0;
915 0 : if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
916 0 : return false;
917 : }
918 0 : bool result(mozilla::dom::MediaRecorder::IsTypeSupported(global, NonNullHelper(Constify(arg0))));
919 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
920 0 : args.rval().setBoolean(result);
921 0 : return true;
922 : }
923 :
924 : static bool
925 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
926 : {
927 0 : mozilla::dom::MediaRecorder* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaRecorder>(obj);
928 : // We don't want to preserve if we don't have a wrapper, and we
929 : // obviously can't preserve if we're not initialized.
930 0 : if (self && self->GetWrapperPreserveColor()) {
931 0 : PreserveWrapper(self);
932 : }
933 0 : return true;
934 : }
935 :
936 : static void
937 0 : _finalize(js::FreeOp* fop, JSObject* obj)
938 : {
939 0 : mozilla::dom::MediaRecorder* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaRecorder>(obj);
940 0 : if (self) {
941 0 : ClearWrapper(self, self, obj);
942 0 : AddForDeferredFinalization<mozilla::dom::MediaRecorder>(self);
943 : }
944 0 : }
945 :
946 : static void
947 0 : _objectMoved(JSObject* obj, const JSObject* old)
948 : {
949 0 : mozilla::dom::MediaRecorder* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::MediaRecorder>(obj);
950 0 : if (self) {
951 0 : UpdateWrapper(self, self, obj, old);
952 : }
953 0 : }
954 :
955 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
956 : #if defined(__clang__)
957 : #pragma clang diagnostic push
958 : #pragma clang diagnostic ignored "-Wmissing-braces"
959 : #endif
960 : static const JSFunctionSpec sStaticMethods_specs[] = {
961 : JS_FNSPEC("isTypeSupported", isTypeSupported, nullptr, 1, JSPROP_ENUMERATE, nullptr),
962 : JS_FS_END
963 : };
964 : #if defined(__clang__)
965 : #pragma clang diagnostic pop
966 : #endif
967 :
968 :
969 : // Can't be const because the pref-enabled boolean needs to be writable
970 : static Prefable<const JSFunctionSpec> sStaticMethods[] = {
971 : { nullptr, &sStaticMethods_specs[0] },
972 : { nullptr, nullptr }
973 : };
974 :
975 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
976 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
977 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
978 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
979 :
980 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
981 : #if defined(__clang__)
982 : #pragma clang diagnostic push
983 : #pragma clang diagnostic ignored "-Wmissing-braces"
984 : #endif
985 : static const JSFunctionSpec sMethods_specs[] = {
986 : JS_FNSPEC("start", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&start_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
987 : JS_FNSPEC("stop", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&stop_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
988 : JS_FNSPEC("pause", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&pause_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
989 : JS_FNSPEC("resume", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&resume_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
990 : JS_FNSPEC("requestData", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&requestData_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
991 : JS_FS_END
992 : };
993 : #if defined(__clang__)
994 : #pragma clang diagnostic pop
995 : #endif
996 :
997 :
998 : // Can't be const because the pref-enabled boolean needs to be writable
999 : static Prefable<const JSFunctionSpec> sMethods[] = {
1000 : { nullptr, &sMethods_specs[0] },
1001 : { nullptr, nullptr }
1002 : };
1003 :
1004 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1005 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1006 : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1007 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1008 :
1009 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1010 : #if defined(__clang__)
1011 : #pragma clang diagnostic push
1012 : #pragma clang diagnostic ignored "-Wmissing-braces"
1013 : #endif
1014 : static const JSPropertySpec sAttributes_specs[] = {
1015 : { "stream", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &stream_getterinfo, nullptr, nullptr },
1016 : { "state", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &state_getterinfo, nullptr, nullptr },
1017 : { "mimeType", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mimeType_getterinfo, nullptr, nullptr },
1018 : { "ondataavailable", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ondataavailable_getterinfo, GenericBindingSetter, &ondataavailable_setterinfo },
1019 : { "onerror", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onerror_getterinfo, GenericBindingSetter, &onerror_setterinfo },
1020 : { "onstart", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onstart_getterinfo, GenericBindingSetter, &onstart_setterinfo },
1021 : { "onstop", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onstop_getterinfo, GenericBindingSetter, &onstop_setterinfo },
1022 : { "onwarning", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onwarning_getterinfo, GenericBindingSetter, &onwarning_setterinfo },
1023 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1024 : };
1025 : #if defined(__clang__)
1026 : #pragma clang diagnostic pop
1027 : #endif
1028 :
1029 :
1030 : // Can't be const because the pref-enabled boolean needs to be writable
1031 : static Prefable<const JSPropertySpec> sAttributes[] = {
1032 : { nullptr, &sAttributes_specs[0] },
1033 : { nullptr, nullptr }
1034 : };
1035 :
1036 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1037 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1038 : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1039 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1040 :
1041 :
1042 : static uint16_t sNativeProperties_sortedPropertyIndices[14];
1043 : static PropertyInfo sNativeProperties_propertyInfos[14];
1044 :
1045 : static const NativePropertiesN<3> sNativeProperties = {
1046 : true, 0 /* sStaticMethods */,
1047 : false, 0,
1048 : true, 1 /* sMethods */,
1049 : true, 2 /* sAttributes */,
1050 : false, 0,
1051 : false, 0,
1052 : false, 0,
1053 : -1,
1054 : 14,
1055 : sNativeProperties_sortedPropertyIndices,
1056 : {
1057 : { sStaticMethods, &sNativeProperties_propertyInfos[0] },
1058 : { sMethods, &sNativeProperties_propertyInfos[1] },
1059 : { sAttributes, &sNativeProperties_propertyInfos[6] }
1060 : }
1061 : };
1062 : static_assert(14 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1063 : "We have a property info count that is oversized");
1064 :
1065 : static bool
1066 0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
1067 : {
1068 0 : JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
1069 0 : JS::Rooted<JSObject*> obj(cx, &args.callee());
1070 0 : if (!args.isConstructing()) {
1071 : // XXXbz wish I could get the name from the callee instead of
1072 : // Adding more relocations
1073 0 : return ThrowConstructorWithoutNew(cx, "MediaRecorder");
1074 : }
1075 :
1076 0 : GlobalObject global(cx, obj);
1077 0 : if (global.Failed()) {
1078 0 : return false;
1079 : }
1080 :
1081 0 : JS::Rooted<JSObject*> desiredProto(cx);
1082 0 : if (!GetDesiredProto(cx, args, &desiredProto)) {
1083 0 : return false;
1084 : }
1085 :
1086 0 : unsigned argcount = std::min(args.length(), 3u);
1087 0 : switch (argcount) {
1088 : case 1: {
1089 : MOZ_FALLTHROUGH;
1090 : }
1091 : case 2: {
1092 0 : if (args[0].isObject()) {
1093 : do {
1094 0 : NonNull<mozilla::DOMMediaStream> arg0;
1095 : {
1096 0 : nsresult rv = UnwrapObject<prototypes::id::MediaStream, mozilla::DOMMediaStream>(args[0], arg0);
1097 0 : if (NS_FAILED(rv)) {
1098 0 : break;
1099 : }
1100 : }
1101 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1102 0 : binding_detail::FastMediaRecorderOptions arg1;
1103 0 : if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue, "Argument 2 of MediaRecorder.constructor", false)) {
1104 0 : return false;
1105 : }
1106 0 : Maybe<JSAutoCompartment> ac;
1107 0 : if (objIsXray) {
1108 0 : obj = js::CheckedUnwrap(obj);
1109 0 : if (!obj) {
1110 0 : return false;
1111 : }
1112 0 : ac.emplace(cx, obj);
1113 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1114 0 : return false;
1115 : }
1116 : }
1117 0 : binding_detail::FastErrorResult rv;
1118 0 : auto result(StrongOrRawPtr<mozilla::dom::MediaRecorder>(mozilla::dom::MediaRecorder::Constructor(global, NonNullHelper(arg0), Constify(arg1), rv)));
1119 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1120 0 : return false;
1121 : }
1122 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1123 : static_assert(!IsPointer<decltype(result)>::value,
1124 : "NewObject implies that we need to keep the object alive with a strong reference.");
1125 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1126 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1127 0 : return false;
1128 : }
1129 0 : return true;
1130 : } while (0);
1131 : do {
1132 0 : NonNull<mozilla::dom::AudioNode> arg0;
1133 : {
1134 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
1135 0 : if (NS_FAILED(rv)) {
1136 0 : break;
1137 : }
1138 : }
1139 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1140 : uint32_t arg1;
1141 0 : if (args.hasDefined(1)) {
1142 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
1143 0 : return false;
1144 : }
1145 : } else {
1146 0 : arg1 = 0U;
1147 : }
1148 0 : binding_detail::FastMediaRecorderOptions arg2;
1149 0 : if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of MediaRecorder.constructor", false)) {
1150 0 : return false;
1151 : }
1152 0 : Maybe<JSAutoCompartment> ac;
1153 0 : if (objIsXray) {
1154 0 : obj = js::CheckedUnwrap(obj);
1155 0 : if (!obj) {
1156 0 : return false;
1157 : }
1158 0 : ac.emplace(cx, obj);
1159 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1160 0 : return false;
1161 : }
1162 : }
1163 0 : binding_detail::FastErrorResult rv;
1164 0 : auto result(StrongOrRawPtr<mozilla::dom::MediaRecorder>(mozilla::dom::MediaRecorder::Constructor(global, NonNullHelper(arg0), arg1, Constify(arg2), rv)));
1165 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1166 0 : return false;
1167 : }
1168 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1169 : static_assert(!IsPointer<decltype(result)>::value,
1170 : "NewObject implies that we need to keep the object alive with a strong reference.");
1171 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1172 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1173 0 : return false;
1174 : }
1175 0 : return true;
1176 : } while (0);
1177 : }
1178 0 : return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "2", "MediaRecorder");
1179 : break;
1180 : }
1181 : case 3: {
1182 0 : bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
1183 0 : NonNull<mozilla::dom::AudioNode> arg0;
1184 0 : if (args[0].isObject()) {
1185 : {
1186 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
1187 0 : if (NS_FAILED(rv)) {
1188 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of MediaRecorder.constructor", "AudioNode");
1189 0 : return false;
1190 : }
1191 : }
1192 : } else {
1193 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MediaRecorder.constructor");
1194 0 : return false;
1195 : }
1196 : uint32_t arg1;
1197 0 : if (args.hasDefined(1)) {
1198 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
1199 0 : return false;
1200 : }
1201 : } else {
1202 0 : arg1 = 0U;
1203 : }
1204 0 : binding_detail::FastMediaRecorderOptions arg2;
1205 0 : if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of MediaRecorder.constructor", false)) {
1206 0 : return false;
1207 : }
1208 0 : Maybe<JSAutoCompartment> ac;
1209 0 : if (objIsXray) {
1210 0 : obj = js::CheckedUnwrap(obj);
1211 0 : if (!obj) {
1212 0 : return false;
1213 : }
1214 0 : ac.emplace(cx, obj);
1215 0 : if (!JS_WrapObject(cx, &desiredProto)) {
1216 0 : return false;
1217 : }
1218 : }
1219 0 : binding_detail::FastErrorResult rv;
1220 0 : auto result(StrongOrRawPtr<mozilla::dom::MediaRecorder>(mozilla::dom::MediaRecorder::Constructor(global, NonNullHelper(arg0), arg1, Constify(arg2), rv)));
1221 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1222 0 : return false;
1223 : }
1224 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1225 : static_assert(!IsPointer<decltype(result)>::value,
1226 : "NewObject implies that we need to keep the object alive with a strong reference.");
1227 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
1228 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1229 0 : return false;
1230 : }
1231 0 : return true;
1232 : break;
1233 : }
1234 : default: {
1235 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaRecorder");
1236 : break;
1237 : }
1238 : }
1239 : MOZ_CRASH("We have an always-returning default case");
1240 : return false;
1241 : }
1242 :
1243 : static const js::ClassOps sInterfaceObjectClassOps = {
1244 : nullptr, /* addProperty */
1245 : nullptr, /* delProperty */
1246 : nullptr, /* getProperty */
1247 : nullptr, /* setProperty */
1248 : nullptr, /* enumerate */
1249 : nullptr, /* newEnumerate */
1250 : nullptr, /* resolve */
1251 : nullptr, /* mayResolve */
1252 : nullptr, /* finalize */
1253 : _constructor, /* call */
1254 : nullptr, /* hasInstance */
1255 : _constructor, /* construct */
1256 : nullptr, /* trace */
1257 : };
1258 :
1259 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1260 : {
1261 : "Function",
1262 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1263 : &sInterfaceObjectClassOps,
1264 : JS_NULL_CLASS_SPEC,
1265 : JS_NULL_CLASS_EXT,
1266 : &sInterfaceObjectClassObjectOps
1267 : },
1268 : eInterface,
1269 : true,
1270 : prototypes::id::MediaRecorder,
1271 : PrototypeTraits<prototypes::id::MediaRecorder>::Depth,
1272 : sNativePropertyHooks,
1273 : "function MediaRecorder() {\n [native code]\n}",
1274 : EventTargetBinding::GetConstructorObject
1275 : };
1276 :
1277 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1278 : {
1279 : "MediaRecorderPrototype",
1280 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1281 : JS_NULL_CLASS_OPS,
1282 : JS_NULL_CLASS_SPEC,
1283 : JS_NULL_CLASS_EXT,
1284 : JS_NULL_OBJECT_OPS
1285 : },
1286 : eInterfacePrototype,
1287 : false,
1288 : prototypes::id::MediaRecorder,
1289 : PrototypeTraits<prototypes::id::MediaRecorder>::Depth,
1290 : sNativePropertyHooks,
1291 : "[object MediaRecorderPrototype]",
1292 : EventTargetBinding::GetProtoObject
1293 : };
1294 :
1295 : JSObject*
1296 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1297 : {
1298 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1299 : }
1300 :
1301 : static const js::ClassOps sClassOps = {
1302 : _addProperty, /* addProperty */
1303 : nullptr, /* delProperty */
1304 : nullptr, /* getProperty */
1305 : nullptr, /* setProperty */
1306 : nullptr, /* enumerate */
1307 : nullptr, /* newEnumerate */
1308 : nullptr, /* resolve */
1309 : nullptr, /* mayResolve */
1310 : _finalize, /* finalize */
1311 : nullptr, /* call */
1312 : nullptr, /* hasInstance */
1313 : nullptr, /* construct */
1314 : nullptr, /* trace */
1315 : };
1316 :
1317 : static const js::ClassExtension sClassExtension = {
1318 : nullptr, /* weakmapKeyDelegateOp */
1319 : _objectMoved /* objectMovedOp */
1320 : };
1321 :
1322 : static const DOMJSClass sClass = {
1323 : { "MediaRecorder",
1324 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1325 : &sClassOps,
1326 : JS_NULL_CLASS_SPEC,
1327 : &sClassExtension,
1328 : JS_NULL_OBJECT_OPS
1329 : },
1330 : { prototypes::id::EventTarget, prototypes::id::MediaRecorder, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1331 : IsBaseOf<nsISupports, mozilla::dom::MediaRecorder >::value,
1332 : sNativePropertyHooks,
1333 : FindAssociatedGlobalForNative<mozilla::dom::MediaRecorder>::Get,
1334 : GetProtoObjectHandle,
1335 : GetCCParticipant<mozilla::dom::MediaRecorder>::Get()
1336 : };
1337 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1338 : "Must have the right minimal number of reserved slots.");
1339 : static_assert(1 >= 1,
1340 : "Must have enough reserved slots.");
1341 :
1342 : const JSClass*
1343 0 : GetJSClass()
1344 : {
1345 0 : return sClass.ToJSClass();
1346 : }
1347 :
1348 : bool
1349 0 : Wrap(JSContext* aCx, mozilla::dom::MediaRecorder* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1350 : {
1351 : MOZ_ASSERT(static_cast<mozilla::dom::MediaRecorder*>(aObject) ==
1352 : reinterpret_cast<mozilla::dom::MediaRecorder*>(aObject),
1353 : "Multiple inheritance for mozilla::dom::MediaRecorder is broken.");
1354 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1355 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1356 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1357 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1358 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1359 0 : MOZ_ASSERT(!aCache->GetWrapper(),
1360 : "You should probably not be using Wrap() directly; use "
1361 : "GetOrCreateDOMReflector instead");
1362 :
1363 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1364 : "nsISupports must be on our primary inheritance chain");
1365 :
1366 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1367 0 : if (!global) {
1368 0 : return false;
1369 : }
1370 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
1371 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1372 :
1373 : // That might have ended up wrapping us already, due to the wonders
1374 : // of XBL. Check for that, and bail out as needed.
1375 0 : aReflector.set(aCache->GetWrapper());
1376 0 : if (aReflector) {
1377 : #ifdef DEBUG
1378 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1379 : #endif // DEBUG
1380 0 : return true;
1381 : }
1382 :
1383 0 : JSAutoCompartment ac(aCx, global);
1384 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1385 0 : if (!canonicalProto) {
1386 0 : return false;
1387 : }
1388 0 : JS::Rooted<JSObject*> proto(aCx);
1389 0 : if (aGivenProto) {
1390 0 : proto = aGivenProto;
1391 : // Unfortunately, while aGivenProto was in the compartment of aCx
1392 : // coming in, we changed compartments to that of "parent" so may need
1393 : // to wrap the proto here.
1394 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1395 0 : if (!JS_WrapObject(aCx, &proto)) {
1396 0 : return false;
1397 : }
1398 : }
1399 : } else {
1400 0 : proto = canonicalProto;
1401 : }
1402 :
1403 0 : BindingJSObjectCreator<mozilla::dom::MediaRecorder> creator(aCx);
1404 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1405 0 : if (!aReflector) {
1406 0 : return false;
1407 : }
1408 :
1409 0 : aCache->SetWrapper(aReflector);
1410 0 : creator.InitializationSucceeded();
1411 :
1412 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1413 : aCache->GetWrapperPreserveColor() == aReflector);
1414 : // If proto != canonicalProto, we have to preserve our wrapper;
1415 : // otherwise we won't be able to properly recreate it later, since
1416 : // we won't know what proto to use. Note that we don't check
1417 : // aGivenProto here, since it's entirely possible (and even
1418 : // somewhat common) to have a non-null aGivenProto which is the
1419 : // same as canonicalProto.
1420 0 : if (proto != canonicalProto) {
1421 0 : PreserveWrapper(aObject);
1422 : }
1423 :
1424 0 : return true;
1425 : }
1426 :
1427 : const NativePropertyHooks sNativePropertyHooks[] = { {
1428 : nullptr,
1429 : nullptr,
1430 : nullptr,
1431 : { sNativeProperties.Upcast(), nullptr },
1432 : prototypes::id::MediaRecorder,
1433 : constructors::id::MediaRecorder,
1434 : EventTargetBinding::sNativePropertyHooks,
1435 : &DefaultXrayExpandoObjectClass
1436 : } };
1437 :
1438 : void
1439 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1440 : {
1441 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
1442 0 : if (!parentProto) {
1443 0 : return;
1444 : }
1445 :
1446 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
1447 0 : if (!constructorProto) {
1448 0 : return;
1449 : }
1450 :
1451 : static bool sIdsInited = false;
1452 0 : if (!sIdsInited && NS_IsMainThread()) {
1453 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1454 0 : return;
1455 : }
1456 0 : sIdsInited = true;
1457 : }
1458 :
1459 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaRecorder);
1460 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaRecorder);
1461 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1462 : &sPrototypeClass.mBase, protoCache,
1463 : constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
1464 : interfaceCache,
1465 : sNativeProperties.Upcast(),
1466 : nullptr,
1467 : "MediaRecorder", aDefineOnGlobal,
1468 : nullptr,
1469 0 : false);
1470 : }
1471 :
1472 : JS::Handle<JSObject*>
1473 0 : GetProtoObjectHandle(JSContext* aCx)
1474 : {
1475 : /* Get the interface prototype object for this class. This will create the
1476 : object as needed. */
1477 0 : bool aDefineOnGlobal = true;
1478 :
1479 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1480 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1481 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1482 0 : return nullptr;
1483 : }
1484 :
1485 : /* Check to see whether the interface objects are already installed */
1486 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1487 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::MediaRecorder)) {
1488 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1489 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1490 : }
1491 :
1492 : /*
1493 : * The object might _still_ be null, but that's OK.
1494 : *
1495 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1496 : * traced by TraceProtoAndIfaceCache() and its contents are never
1497 : * changed after they have been set.
1498 : *
1499 : * Calling address() avoids the read read barrier that does gray
1500 : * unmarking, but it's not possible for the object to be gray here.
1501 : */
1502 :
1503 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::MediaRecorder);
1504 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1505 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1506 : }
1507 :
1508 : JS::Handle<JSObject*>
1509 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1510 : {
1511 : /* Get the interface object for this class. This will create the object as
1512 : needed. */
1513 :
1514 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1515 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1516 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1517 0 : return nullptr;
1518 : }
1519 :
1520 : /* Check to see whether the interface objects are already installed */
1521 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1522 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::MediaRecorder)) {
1523 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1524 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1525 : }
1526 :
1527 : /*
1528 : * The object might _still_ be null, but that's OK.
1529 : *
1530 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1531 : * traced by TraceProtoAndIfaceCache() and its contents are never
1532 : * changed after they have been set.
1533 : *
1534 : * Calling address() avoids the read read barrier that does gray
1535 : * unmarking, but it's not possible for the object to be gray here.
1536 : */
1537 :
1538 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::MediaRecorder);
1539 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1540 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1541 : }
1542 :
1543 : JSObject*
1544 0 : GetConstructorObject(JSContext* aCx)
1545 : {
1546 0 : return GetConstructorObjectHandle(aCx);
1547 : }
1548 :
1549 : } // namespace MediaRecorderBinding
1550 :
1551 :
1552 :
1553 : } // namespace dom
1554 : } // namespace mozilla
|