/work/obj-fuzz/dom/bindings/MediaStreamBinding.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* THIS FILE IS AUTOGENERATED FROM MediaStream.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 "MediaStreamBinding.h" |
8 | | #include "WrapperFactory.h" |
9 | | #include "mozilla/FloatingPoint.h" |
10 | | #include "mozilla/OwningNonNull.h" |
11 | | #include "mozilla/dom/AudioStreamTrack.h" |
12 | | #include "mozilla/dom/BindingUtils.h" |
13 | | #include "mozilla/dom/DOMJSClass.h" |
14 | | #include "mozilla/dom/MediaStreamTrack.h" |
15 | | #include "mozilla/dom/NonRefcountedDOMObject.h" |
16 | | #include "mozilla/dom/Nullable.h" |
17 | | #include "mozilla/dom/PrimitiveConversions.h" |
18 | | #include "mozilla/dom/Promise.h" |
19 | | #include "mozilla/dom/ScriptSettings.h" |
20 | | #include "mozilla/dom/SimpleGlobalObject.h" |
21 | | #include "mozilla/dom/ToJSValue.h" |
22 | | #include "mozilla/dom/UnionConversions.h" |
23 | | #include "mozilla/dom/VideoStreamTrack.h" |
24 | | #include "mozilla/dom/XrayExpandoClass.h" |
25 | | #include "nsContentUtils.h" |
26 | | |
27 | | namespace mozilla { |
28 | | namespace dom { |
29 | | |
30 | | namespace binding_detail {}; // Just to make sure it's known as a namespace |
31 | | using namespace mozilla::dom::binding_detail; |
32 | | |
33 | | |
34 | | bool |
35 | | BooleanOrMediaTrackConstraints::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
36 | 0 | { |
37 | 0 | switch (mType) { |
38 | 0 | case eUninitialized: { |
39 | 0 | return false; |
40 | 0 | break; |
41 | 0 | } |
42 | 0 | case eBoolean: { |
43 | 0 | rval.setBoolean(mValue.mBoolean.Value()); |
44 | 0 | return true; |
45 | 0 | break; |
46 | 0 | } |
47 | 0 | case eMediaTrackConstraints: { |
48 | 0 | if (!mValue.mMediaTrackConstraints.Value().ToObjectInternal(cx, rval)) { |
49 | 0 | return false; |
50 | 0 | } |
51 | 0 | return true; |
52 | 0 | break; |
53 | 0 | } |
54 | 0 | default: { |
55 | 0 | return false; |
56 | 0 | break; |
57 | 0 | } |
58 | 0 | } |
59 | 0 | |
60 | 0 | return false; |
61 | 0 | } |
62 | | |
63 | | |
64 | | bool& |
65 | | OwningBooleanOrMediaTrackConstraints::RawSetAsBoolean() |
66 | 0 | { |
67 | 0 | if (mType == eBoolean) { |
68 | 0 | return mValue.mBoolean.Value(); |
69 | 0 | } |
70 | 0 | MOZ_ASSERT(mType == eUninitialized); |
71 | 0 | mType = eBoolean; |
72 | 0 | return mValue.mBoolean.SetValue(); |
73 | 0 | } |
74 | | |
75 | | bool& |
76 | | OwningBooleanOrMediaTrackConstraints::SetAsBoolean() |
77 | 0 | { |
78 | 0 | if (mType == eBoolean) { |
79 | 0 | return mValue.mBoolean.Value(); |
80 | 0 | } |
81 | 0 | Uninit(); |
82 | 0 | mType = eBoolean; |
83 | 0 | return mValue.mBoolean.SetValue(); |
84 | 0 | } |
85 | | |
86 | | bool |
87 | | OwningBooleanOrMediaTrackConstraints::TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
88 | 0 | { |
89 | 0 | tryNext = false; |
90 | 0 | { // scope for memberSlot |
91 | 0 | bool& memberSlot = RawSetAsBoolean(); |
92 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, value, &memberSlot)) { |
93 | 0 | return false; |
94 | 0 | } |
95 | 0 | } |
96 | 0 | return true; |
97 | 0 | } |
98 | | |
99 | | void |
100 | | OwningBooleanOrMediaTrackConstraints::DestroyBoolean() |
101 | 0 | { |
102 | 0 | MOZ_ASSERT(IsBoolean(), "Wrong type!"); |
103 | 0 | mValue.mBoolean.Destroy(); |
104 | 0 | mType = eUninitialized; |
105 | 0 | } |
106 | | |
107 | | |
108 | | |
109 | | |
110 | | MediaTrackConstraints& |
111 | | OwningBooleanOrMediaTrackConstraints::RawSetAsMediaTrackConstraints() |
112 | 0 | { |
113 | 0 | if (mType == eMediaTrackConstraints) { |
114 | 0 | return mValue.mMediaTrackConstraints.Value(); |
115 | 0 | } |
116 | 0 | MOZ_ASSERT(mType == eUninitialized); |
117 | 0 | mType = eMediaTrackConstraints; |
118 | 0 | return mValue.mMediaTrackConstraints.SetValue(); |
119 | 0 | } |
120 | | |
121 | | MediaTrackConstraints& |
122 | | OwningBooleanOrMediaTrackConstraints::SetAsMediaTrackConstraints() |
123 | 0 | { |
124 | 0 | if (mType == eMediaTrackConstraints) { |
125 | 0 | return mValue.mMediaTrackConstraints.Value(); |
126 | 0 | } |
127 | 0 | Uninit(); |
128 | 0 | mType = eMediaTrackConstraints; |
129 | 0 | return mValue.mMediaTrackConstraints.SetValue(); |
130 | 0 | } |
131 | | |
132 | | bool |
133 | | OwningBooleanOrMediaTrackConstraints::TrySetToMediaTrackConstraints(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl) |
134 | 0 | { |
135 | 0 | tryNext = false; |
136 | 0 | { // scope for memberSlot |
137 | 0 | MediaTrackConstraints& memberSlot = RawSetAsMediaTrackConstraints(); |
138 | 0 | if (!IsConvertibleToDictionary(value)) { |
139 | 0 | DestroyMediaTrackConstraints(); |
140 | 0 | tryNext = true; |
141 | 0 | return true; |
142 | 0 | } |
143 | 0 | if (!memberSlot.Init(cx, value, "Member of BooleanOrMediaTrackConstraints", passedToJSImpl)) { |
144 | 0 | return false; |
145 | 0 | } |
146 | 0 | } |
147 | 0 | return true; |
148 | 0 | } |
149 | | |
150 | | void |
151 | | OwningBooleanOrMediaTrackConstraints::DestroyMediaTrackConstraints() |
152 | 0 | { |
153 | 0 | MOZ_ASSERT(IsMediaTrackConstraints(), "Wrong type!"); |
154 | 0 | mValue.mMediaTrackConstraints.Destroy(); |
155 | 0 | mType = eUninitialized; |
156 | 0 | } |
157 | | |
158 | | |
159 | | |
160 | | |
161 | | void |
162 | | OwningBooleanOrMediaTrackConstraints::Uninit() |
163 | | { |
164 | | switch (mType) { |
165 | | case eUninitialized: { |
166 | | break; |
167 | | } |
168 | | case eBoolean: { |
169 | | DestroyBoolean(); |
170 | | break; |
171 | | } |
172 | | case eMediaTrackConstraints: { |
173 | | DestroyMediaTrackConstraints(); |
174 | | break; |
175 | | } |
176 | | } |
177 | | } |
178 | | |
179 | | bool |
180 | | OwningBooleanOrMediaTrackConstraints::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const |
181 | 0 | { |
182 | 0 | switch (mType) { |
183 | 0 | case eUninitialized: { |
184 | 0 | return false; |
185 | 0 | break; |
186 | 0 | } |
187 | 0 | case eBoolean: { |
188 | 0 | rval.setBoolean(mValue.mBoolean.Value()); |
189 | 0 | return true; |
190 | 0 | break; |
191 | 0 | } |
192 | 0 | case eMediaTrackConstraints: { |
193 | 0 | if (!mValue.mMediaTrackConstraints.Value().ToObjectInternal(cx, rval)) { |
194 | 0 | return false; |
195 | 0 | } |
196 | 0 | return true; |
197 | 0 | break; |
198 | 0 | } |
199 | 0 | default: { |
200 | 0 | return false; |
201 | 0 | break; |
202 | 0 | } |
203 | 0 | } |
204 | 0 | |
205 | 0 | return false; |
206 | 0 | } |
207 | | |
208 | | void |
209 | | OwningBooleanOrMediaTrackConstraints::TraceUnion(JSTracer* trc) |
210 | 0 | { |
211 | 0 | } |
212 | | |
213 | | OwningBooleanOrMediaTrackConstraints& |
214 | | OwningBooleanOrMediaTrackConstraints::operator=(const OwningBooleanOrMediaTrackConstraints& aOther) |
215 | 0 | { |
216 | 0 | switch (aOther.mType) { |
217 | 0 | case eUninitialized: { |
218 | 0 | MOZ_ASSERT(mType == eUninitialized, |
219 | 0 | "We need to destroy ourselves?"); |
220 | 0 | break; |
221 | 0 | } |
222 | 0 | case eBoolean: { |
223 | 0 | SetAsBoolean() = aOther.GetAsBoolean(); |
224 | 0 | break; |
225 | 0 | } |
226 | 0 | case eMediaTrackConstraints: { |
227 | 0 | SetAsMediaTrackConstraints() = aOther.GetAsMediaTrackConstraints(); |
228 | 0 | break; |
229 | 0 | } |
230 | 0 | } |
231 | 0 | return *this; |
232 | 0 | } |
233 | | |
234 | | |
235 | | |
236 | | MediaStreamConstraints::MediaStreamConstraints() |
237 | 0 | { |
238 | 0 | // Safe to pass a null context if we pass a null value |
239 | 0 | Init(nullptr, JS::NullHandleValue); |
240 | 0 | } |
241 | | |
242 | | |
243 | | |
244 | | bool |
245 | | MediaStreamConstraints::InitIds(JSContext* cx, MediaStreamConstraintsAtoms* atomsCache) |
246 | 0 | { |
247 | 0 | MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache)); |
248 | 0 |
|
249 | 0 | // Initialize these in reverse order so that any failure leaves the first one |
250 | 0 | // uninitialized. |
251 | 0 | if (!atomsCache->video_id.init(cx, "video") || |
252 | 0 | !atomsCache->picture_id.init(cx, "picture") || |
253 | 0 | !atomsCache->peerIdentity_id.init(cx, "peerIdentity") || |
254 | 0 | !atomsCache->fake_id.init(cx, "fake") || |
255 | 0 | !atomsCache->audio_id.init(cx, "audio")) { |
256 | 0 | return false; |
257 | 0 | } |
258 | 0 | return true; |
259 | 0 | } |
260 | | |
261 | | bool |
262 | | MediaStreamConstraints::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl) |
263 | 0 | { |
264 | 0 | // Passing a null JSContext is OK only if we're initing from null, |
265 | 0 | // Since in that case we will not have to do any property gets |
266 | 0 | // Also evaluate isNullOrUndefined in order to avoid false-positive |
267 | 0 | // checkers by static analysis tools |
268 | 0 | MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined()); |
269 | 0 | MediaStreamConstraintsAtoms* atomsCache = nullptr; |
270 | 0 | if (cx) { |
271 | 0 | atomsCache = GetAtomCache<MediaStreamConstraintsAtoms>(cx); |
272 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
273 | 0 | return false; |
274 | 0 | } |
275 | 0 | } |
276 | 0 | |
277 | 0 | if (!IsConvertibleToDictionary(val)) { |
278 | 0 | return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription); |
279 | 0 | } |
280 | 0 | |
281 | 0 | bool isNull = val.isNullOrUndefined(); |
282 | 0 | // We only need these if !isNull, in which case we have |cx|. |
283 | 0 | Maybe<JS::Rooted<JSObject *> > object; |
284 | 0 | Maybe<JS::Rooted<JS::Value> > temp; |
285 | 0 | if (!isNull) { |
286 | 0 | MOZ_ASSERT(cx); |
287 | 0 | object.emplace(cx, &val.toObject()); |
288 | 0 | temp.emplace(cx); |
289 | 0 | } |
290 | 0 | if (!isNull) { |
291 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->audio_id, temp.ptr())) { |
292 | 0 | return false; |
293 | 0 | } |
294 | 0 | } |
295 | 0 | mAudio.Uninit(); |
296 | 0 | if (!(!isNull && !temp->isUndefined())) { |
297 | 0 | mAudio.RawSetAsBoolean() = false; |
298 | 0 | } else { |
299 | 0 | { |
300 | 0 | bool done = false, failed = false, tryNext; |
301 | 0 | if (!done) { |
302 | 0 | done = (failed = !mAudio.TrySetToMediaTrackConstraints(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext; |
303 | 0 | } |
304 | 0 | if (!done) { |
305 | 0 | do { |
306 | 0 | done = (failed = !mAudio.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext; |
307 | 0 | break; |
308 | 0 | } while (false); |
309 | 0 | } |
310 | 0 | if (failed) { |
311 | 0 | return false; |
312 | 0 | } |
313 | 0 | if (!done) { |
314 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'audio' member of MediaStreamConstraints", "MediaTrackConstraints"); |
315 | 0 | return false; |
316 | 0 | } |
317 | 0 | } |
318 | 0 | } |
319 | 0 | mIsAnyMemberPresent = true; |
320 | 0 |
|
321 | 0 | if (!isNull) { |
322 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->fake_id, temp.ptr())) { |
323 | 0 | return false; |
324 | 0 | } |
325 | 0 | } |
326 | 0 | if (!isNull && !temp->isUndefined()) { |
327 | 0 | mFake.Construct(); |
328 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mFake.Value()))) { |
329 | 0 | return false; |
330 | 0 | } |
331 | 0 | mIsAnyMemberPresent = true; |
332 | 0 | } |
333 | 0 |
|
334 | 0 | if (!isNull) { |
335 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->peerIdentity_id, temp.ptr())) { |
336 | 0 | return false; |
337 | 0 | } |
338 | 0 | } |
339 | 0 | if (!isNull && !temp->isUndefined()) { |
340 | 0 | if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, mPeerIdentity)) { |
341 | 0 | return false; |
342 | 0 | } |
343 | 0 | } else { |
344 | 0 | mPeerIdentity.SetIsVoid(true); |
345 | 0 | } |
346 | 0 | mIsAnyMemberPresent = true; |
347 | 0 |
|
348 | 0 | if (!isNull) { |
349 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->picture_id, temp.ptr())) { |
350 | 0 | return false; |
351 | 0 | } |
352 | 0 | } |
353 | 0 | if (!isNull && !temp->isUndefined()) { |
354 | 0 | if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mPicture)) { |
355 | 0 | return false; |
356 | 0 | } |
357 | 0 | } else { |
358 | 0 | mPicture = false; |
359 | 0 | } |
360 | 0 | mIsAnyMemberPresent = true; |
361 | 0 |
|
362 | 0 | if (!isNull) { |
363 | 0 | if (!JS_GetPropertyById(cx, *object, atomsCache->video_id, temp.ptr())) { |
364 | 0 | return false; |
365 | 0 | } |
366 | 0 | } |
367 | 0 | mVideo.Uninit(); |
368 | 0 | if (!(!isNull && !temp->isUndefined())) { |
369 | 0 | mVideo.RawSetAsBoolean() = false; |
370 | 0 | } else { |
371 | 0 | { |
372 | 0 | bool done = false, failed = false, tryNext; |
373 | 0 | if (!done) { |
374 | 0 | done = (failed = !mVideo.TrySetToMediaTrackConstraints(cx, temp.ref(), tryNext, passedToJSImpl)) || !tryNext; |
375 | 0 | } |
376 | 0 | if (!done) { |
377 | 0 | do { |
378 | 0 | done = (failed = !mVideo.TrySetToBoolean(cx, temp.ref(), tryNext)) || !tryNext; |
379 | 0 | break; |
380 | 0 | } while (false); |
381 | 0 | } |
382 | 0 | if (failed) { |
383 | 0 | return false; |
384 | 0 | } |
385 | 0 | if (!done) { |
386 | 0 | ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "'video' member of MediaStreamConstraints", "MediaTrackConstraints"); |
387 | 0 | return false; |
388 | 0 | } |
389 | 0 | } |
390 | 0 | } |
391 | 0 | mIsAnyMemberPresent = true; |
392 | 0 | return true; |
393 | 0 | } |
394 | | |
395 | | bool |
396 | | MediaStreamConstraints::Init(const nsAString& aJSON) |
397 | 0 | { |
398 | 0 | AutoJSAPI jsapi; |
399 | 0 | JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail); |
400 | 0 | if (!cleanGlobal) { |
401 | 0 | return false; |
402 | 0 | } |
403 | 0 | if (!jsapi.Init(cleanGlobal)) { |
404 | 0 | return false; |
405 | 0 | } |
406 | 0 | JSContext* cx = jsapi.cx(); |
407 | 0 | JS::Rooted<JS::Value> json(cx); |
408 | 0 | bool ok = ParseJSON(cx, aJSON, &json); |
409 | 0 | NS_ENSURE_TRUE(ok, false); |
410 | 0 | return Init(cx, json); |
411 | 0 | } |
412 | | |
413 | | bool |
414 | | MediaStreamConstraints::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const |
415 | 0 | { |
416 | 0 | MediaStreamConstraintsAtoms* atomsCache = GetAtomCache<MediaStreamConstraintsAtoms>(cx); |
417 | 0 | if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) { |
418 | 0 | return false; |
419 | 0 | } |
420 | 0 | |
421 | 0 | JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx)); |
422 | 0 | if (!obj) { |
423 | 0 | return false; |
424 | 0 | } |
425 | 0 | rval.set(JS::ObjectValue(*obj)); |
426 | 0 |
|
427 | 0 | do { |
428 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
429 | 0 | JS::Rooted<JS::Value> temp(cx); |
430 | 0 | OwningBooleanOrMediaTrackConstraints const & currentValue = mAudio; |
431 | 0 | if (!currentValue.ToJSVal(cx, obj, &temp)) { |
432 | 0 | return false; |
433 | 0 | } |
434 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->audio_id, temp, JSPROP_ENUMERATE)) { |
435 | 0 | return false; |
436 | 0 | } |
437 | 0 | break; |
438 | 0 | } while(false); |
439 | 0 |
|
440 | 0 | if (mFake.WasPassed()) { |
441 | 0 | do { |
442 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
443 | 0 | JS::Rooted<JS::Value> temp(cx); |
444 | 0 | bool const & currentValue = mFake.InternalValue(); |
445 | 0 | temp.setBoolean(currentValue); |
446 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->fake_id, temp, JSPROP_ENUMERATE)) { |
447 | 0 | return false; |
448 | 0 | } |
449 | 0 | break; |
450 | 0 | } while(false); |
451 | 0 | } |
452 | 0 |
|
453 | 0 | do { |
454 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
455 | 0 | JS::Rooted<JS::Value> temp(cx); |
456 | 0 | nsString const & currentValue = mPeerIdentity; |
457 | 0 | if (!xpc::StringToJsval(cx, currentValue, &temp)) { |
458 | 0 | return false; |
459 | 0 | } |
460 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->peerIdentity_id, temp, JSPROP_ENUMERATE)) { |
461 | 0 | return false; |
462 | 0 | } |
463 | 0 | break; |
464 | 0 | } while(false); |
465 | 0 |
|
466 | 0 | do { |
467 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
468 | 0 | JS::Rooted<JS::Value> temp(cx); |
469 | 0 | bool const & currentValue = mPicture; |
470 | 0 | temp.setBoolean(currentValue); |
471 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->picture_id, temp, JSPROP_ENUMERATE)) { |
472 | 0 | return false; |
473 | 0 | } |
474 | 0 | break; |
475 | 0 | } while(false); |
476 | 0 |
|
477 | 0 | do { |
478 | 0 | // block for our 'break' successCode and scope for 'temp' and 'currentValue' |
479 | 0 | JS::Rooted<JS::Value> temp(cx); |
480 | 0 | OwningBooleanOrMediaTrackConstraints const & currentValue = mVideo; |
481 | 0 | if (!currentValue.ToJSVal(cx, obj, &temp)) { |
482 | 0 | return false; |
483 | 0 | } |
484 | 0 | if (!JS_DefinePropertyById(cx, obj, atomsCache->video_id, temp, JSPROP_ENUMERATE)) { |
485 | 0 | return false; |
486 | 0 | } |
487 | 0 | break; |
488 | 0 | } while(false); |
489 | 0 |
|
490 | 0 | return true; |
491 | 0 | } |
492 | | |
493 | | bool |
494 | | MediaStreamConstraints::ToJSON(nsAString& aJSON) const |
495 | 0 | { |
496 | 0 | AutoJSAPI jsapi; |
497 | 0 | jsapi.Init(); |
498 | 0 | JSContext *cx = jsapi.cx(); |
499 | 0 | // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here |
500 | 0 | // because we'll only be creating objects, in ways that have no |
501 | 0 | // side-effects, followed by a call to JS::ToJSONMaybeSafely, |
502 | 0 | // which likewise guarantees no side-effects for the sorts of |
503 | 0 | // things we will pass it. |
504 | 0 | JSAutoRealm ar(cx, UnprivilegedJunkScopeOrWorkerGlobal()); |
505 | 0 | JS::Rooted<JS::Value> val(cx); |
506 | 0 | if (!ToObjectInternal(cx, &val)) { |
507 | 0 | return false; |
508 | 0 | } |
509 | 0 | JS::Rooted<JSObject*> obj(cx, &val.toObject()); |
510 | 0 | return StringifyToJSON(cx, obj, aJSON); |
511 | 0 | } |
512 | | |
513 | | void |
514 | | MediaStreamConstraints::TraceDictionary(JSTracer* trc) |
515 | 0 | { |
516 | 0 | } |
517 | | |
518 | | MediaStreamConstraints& |
519 | | MediaStreamConstraints::operator=(const MediaStreamConstraints& aOther) |
520 | 0 | { |
521 | 0 | DictionaryBase::operator=(aOther); |
522 | 0 | mAudio = aOther.mAudio; |
523 | 0 | mFake.Reset(); |
524 | 0 | if (aOther.mFake.WasPassed()) { |
525 | 0 | mFake.Construct(aOther.mFake.Value()); |
526 | 0 | } |
527 | 0 | mPeerIdentity = aOther.mPeerIdentity; |
528 | 0 | mPicture = aOther.mPicture; |
529 | 0 | mVideo = aOther.mVideo; |
530 | 0 | return *this; |
531 | 0 | } |
532 | | |
533 | | namespace binding_detail { |
534 | | } // namespace binding_detail |
535 | | |
536 | | |
537 | | namespace MediaStream_Binding { |
538 | | |
539 | | static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTarget_Binding::NativeType>::value, |
540 | | "Can't inherit from an interface with a different ownership model."); |
541 | | |
542 | | MOZ_CAN_RUN_SCRIPT static bool |
543 | | get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitGetterCallArgs args) |
544 | 0 | { |
545 | 0 | AUTO_PROFILER_LABEL_FAST("get MediaStream.id", DOM, cx); |
546 | 0 |
|
547 | 0 | DOMString result; |
548 | 0 | self->GetId(result); |
549 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
550 | 0 | if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) { |
551 | 0 | return false; |
552 | 0 | } |
553 | 0 | return true; |
554 | 0 | } |
555 | | |
556 | | static const JSJitInfo id_getterinfo = { |
557 | | { (JSJitGetterOp)get_id }, |
558 | | { prototypes::id::MediaStream }, |
559 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
560 | | JSJitInfo::Getter, |
561 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
562 | | JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */ |
563 | | false, /* isInfallible. False in setters. */ |
564 | | false, /* isMovable. Not relevant for setters. */ |
565 | | false, /* isEliminatable. Not relevant for setters. */ |
566 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
567 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
568 | | false, /* isTypedMethod. Only relevant for methods. */ |
569 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
570 | | }; |
571 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
572 | | static_assert(0 < 1, "There is no slot for us"); |
573 | | |
574 | | MOZ_CAN_RUN_SCRIPT static bool |
575 | | getAudioTracks(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
576 | 0 | { |
577 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.getAudioTracks", DOM, cx); |
578 | 0 |
|
579 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::AudioStreamTrack>::Type> result; |
580 | 0 | self->GetAudioTracks(result); |
581 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
582 | 0 |
|
583 | 0 | uint32_t length = result.Length(); |
584 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
585 | 0 | if (!returnArray) { |
586 | 0 | return false; |
587 | 0 | } |
588 | 0 | // Scope for 'tmp' |
589 | 0 | { |
590 | 0 | JS::Rooted<JS::Value> tmp(cx); |
591 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
592 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
593 | 0 | // are different ways to succeed at wrapping the object. |
594 | 0 | do { |
595 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
596 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
597 | 0 | return false; |
598 | 0 | } |
599 | 0 | break; |
600 | 0 | } while (false); |
601 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
602 | 0 | JSPROP_ENUMERATE)) { |
603 | 0 | return false; |
604 | 0 | } |
605 | 0 | } |
606 | 0 | } |
607 | 0 | args.rval().setObject(*returnArray); |
608 | 0 | return true; |
609 | 0 | } |
610 | | |
611 | | static const JSJitInfo getAudioTracks_methodinfo = { |
612 | | { (JSJitGetterOp)getAudioTracks }, |
613 | | { prototypes::id::MediaStream }, |
614 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
615 | | JSJitInfo::Method, |
616 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
617 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
618 | | false, /* isInfallible. False in setters. */ |
619 | | false, /* isMovable. Not relevant for setters. */ |
620 | | false, /* isEliminatable. Not relevant for setters. */ |
621 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
622 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
623 | | false, /* isTypedMethod. Only relevant for methods. */ |
624 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
625 | | }; |
626 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
627 | | static_assert(0 < 1, "There is no slot for us"); |
628 | | |
629 | | MOZ_CAN_RUN_SCRIPT static bool |
630 | | getVideoTracks(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
631 | 0 | { |
632 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.getVideoTracks", DOM, cx); |
633 | 0 |
|
634 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::VideoStreamTrack>::Type> result; |
635 | 0 | self->GetVideoTracks(result); |
636 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
637 | 0 |
|
638 | 0 | uint32_t length = result.Length(); |
639 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
640 | 0 | if (!returnArray) { |
641 | 0 | return false; |
642 | 0 | } |
643 | 0 | // Scope for 'tmp' |
644 | 0 | { |
645 | 0 | JS::Rooted<JS::Value> tmp(cx); |
646 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
647 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
648 | 0 | // are different ways to succeed at wrapping the object. |
649 | 0 | do { |
650 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
651 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
652 | 0 | return false; |
653 | 0 | } |
654 | 0 | break; |
655 | 0 | } while (false); |
656 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
657 | 0 | JSPROP_ENUMERATE)) { |
658 | 0 | return false; |
659 | 0 | } |
660 | 0 | } |
661 | 0 | } |
662 | 0 | args.rval().setObject(*returnArray); |
663 | 0 | return true; |
664 | 0 | } |
665 | | |
666 | | static const JSJitInfo getVideoTracks_methodinfo = { |
667 | | { (JSJitGetterOp)getVideoTracks }, |
668 | | { prototypes::id::MediaStream }, |
669 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
670 | | JSJitInfo::Method, |
671 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
672 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
673 | | false, /* isInfallible. False in setters. */ |
674 | | false, /* isMovable. Not relevant for setters. */ |
675 | | false, /* isEliminatable. Not relevant for setters. */ |
676 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
677 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
678 | | false, /* isTypedMethod. Only relevant for methods. */ |
679 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
680 | | }; |
681 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
682 | | static_assert(0 < 1, "There is no slot for us"); |
683 | | |
684 | | MOZ_CAN_RUN_SCRIPT static bool |
685 | | getTracks(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
686 | 0 | { |
687 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.getTracks", DOM, cx); |
688 | 0 |
|
689 | 0 | nsTArray<StrongPtrForMember<mozilla::dom::MediaStreamTrack>::Type> result; |
690 | 0 | self->GetTracks(result); |
691 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
692 | 0 |
|
693 | 0 | uint32_t length = result.Length(); |
694 | 0 | JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length)); |
695 | 0 | if (!returnArray) { |
696 | 0 | return false; |
697 | 0 | } |
698 | 0 | // Scope for 'tmp' |
699 | 0 | { |
700 | 0 | JS::Rooted<JS::Value> tmp(cx); |
701 | 0 | for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) { |
702 | 0 | // Control block to let us common up the JS_DefineElement calls when there |
703 | 0 | // are different ways to succeed at wrapping the object. |
704 | 0 | do { |
705 | 0 | if (!GetOrCreateDOMReflector(cx, result[sequenceIdx0], &tmp)) { |
706 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
707 | 0 | return false; |
708 | 0 | } |
709 | 0 | break; |
710 | 0 | } while (false); |
711 | 0 | if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp, |
712 | 0 | JSPROP_ENUMERATE)) { |
713 | 0 | return false; |
714 | 0 | } |
715 | 0 | } |
716 | 0 | } |
717 | 0 | args.rval().setObject(*returnArray); |
718 | 0 | return true; |
719 | 0 | } |
720 | | |
721 | | static const JSJitInfo getTracks_methodinfo = { |
722 | | { (JSJitGetterOp)getTracks }, |
723 | | { prototypes::id::MediaStream }, |
724 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
725 | | JSJitInfo::Method, |
726 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
727 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
728 | | false, /* isInfallible. False in setters. */ |
729 | | false, /* isMovable. Not relevant for setters. */ |
730 | | false, /* isEliminatable. Not relevant for setters. */ |
731 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
732 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
733 | | false, /* isTypedMethod. Only relevant for methods. */ |
734 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
735 | | }; |
736 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
737 | | static_assert(0 < 1, "There is no slot for us"); |
738 | | |
739 | | MOZ_CAN_RUN_SCRIPT static bool |
740 | | getTrackById(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
741 | 0 | { |
742 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.getTrackById", DOM, cx); |
743 | 0 |
|
744 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
745 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaStream.getTrackById"); |
746 | 0 | } |
747 | 0 | binding_detail::FakeString arg0; |
748 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
749 | 0 | return false; |
750 | 0 | } |
751 | 0 | auto result(StrongOrRawPtr<mozilla::dom::MediaStreamTrack>(self->GetTrackById(NonNullHelper(Constify(arg0))))); |
752 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
753 | 0 | if (!result) { |
754 | 0 | args.rval().setNull(); |
755 | 0 | return true; |
756 | 0 | } |
757 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
758 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
759 | 0 | return false; |
760 | 0 | } |
761 | 0 | return true; |
762 | 0 | } |
763 | | |
764 | | static const JSJitInfo getTrackById_methodinfo = { |
765 | | { (JSJitGetterOp)getTrackById }, |
766 | | { prototypes::id::MediaStream }, |
767 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
768 | | JSJitInfo::Method, |
769 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
770 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
771 | | false, /* isInfallible. False in setters. */ |
772 | | false, /* isMovable. Not relevant for setters. */ |
773 | | false, /* isEliminatable. Not relevant for setters. */ |
774 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
775 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
776 | | false, /* isTypedMethod. Only relevant for methods. */ |
777 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
778 | | }; |
779 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
780 | | static_assert(0 < 1, "There is no slot for us"); |
781 | | |
782 | | MOZ_CAN_RUN_SCRIPT static bool |
783 | | addTrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
784 | 0 | { |
785 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.addTrack", DOM, cx); |
786 | 0 |
|
787 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
788 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaStream.addTrack"); |
789 | 0 | } |
790 | 0 | NonNull<mozilla::dom::MediaStreamTrack> arg0; |
791 | 0 | if (args[0].isObject()) { |
792 | 0 | { |
793 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStreamTrack, mozilla::dom::MediaStreamTrack>(args[0], arg0); |
794 | 0 | if (NS_FAILED(rv)) { |
795 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of MediaStream.addTrack", "MediaStreamTrack"); |
796 | 0 | return false; |
797 | 0 | } |
798 | 0 | } |
799 | 0 | } else { |
800 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MediaStream.addTrack"); |
801 | 0 | return false; |
802 | 0 | } |
803 | 0 | self->AddTrack(MOZ_KnownLive(NonNullHelper(arg0))); |
804 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
805 | 0 | args.rval().setUndefined(); |
806 | 0 | return true; |
807 | 0 | } |
808 | | |
809 | | static const JSJitInfo addTrack_methodinfo = { |
810 | | { (JSJitGetterOp)addTrack }, |
811 | | { prototypes::id::MediaStream }, |
812 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
813 | | JSJitInfo::Method, |
814 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
815 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
816 | | false, /* isInfallible. False in setters. */ |
817 | | false, /* isMovable. Not relevant for setters. */ |
818 | | false, /* isEliminatable. Not relevant for setters. */ |
819 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
820 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
821 | | false, /* isTypedMethod. Only relevant for methods. */ |
822 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
823 | | }; |
824 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
825 | | static_assert(0 < 1, "There is no slot for us"); |
826 | | |
827 | | MOZ_CAN_RUN_SCRIPT static bool |
828 | | removeTrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
829 | 0 | { |
830 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.removeTrack", DOM, cx); |
831 | 0 |
|
832 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
833 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaStream.removeTrack"); |
834 | 0 | } |
835 | 0 | NonNull<mozilla::dom::MediaStreamTrack> arg0; |
836 | 0 | if (args[0].isObject()) { |
837 | 0 | { |
838 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStreamTrack, mozilla::dom::MediaStreamTrack>(args[0], arg0); |
839 | 0 | if (NS_FAILED(rv)) { |
840 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of MediaStream.removeTrack", "MediaStreamTrack"); |
841 | 0 | return false; |
842 | 0 | } |
843 | 0 | } |
844 | 0 | } else { |
845 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of MediaStream.removeTrack"); |
846 | 0 | return false; |
847 | 0 | } |
848 | 0 | self->RemoveTrack(MOZ_KnownLive(NonNullHelper(arg0))); |
849 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
850 | 0 | args.rval().setUndefined(); |
851 | 0 | return true; |
852 | 0 | } |
853 | | |
854 | | static const JSJitInfo removeTrack_methodinfo = { |
855 | | { (JSJitGetterOp)removeTrack }, |
856 | | { prototypes::id::MediaStream }, |
857 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
858 | | JSJitInfo::Method, |
859 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
860 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
861 | | false, /* isInfallible. False in setters. */ |
862 | | false, /* isMovable. Not relevant for setters. */ |
863 | | false, /* isEliminatable. Not relevant for setters. */ |
864 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
865 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
866 | | false, /* isTypedMethod. Only relevant for methods. */ |
867 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
868 | | }; |
869 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
870 | | static_assert(0 < 1, "There is no slot for us"); |
871 | | |
872 | | MOZ_CAN_RUN_SCRIPT static bool |
873 | | clone(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
874 | 0 | { |
875 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.clone", DOM, cx); |
876 | 0 |
|
877 | 0 | auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(self->Clone())); |
878 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
879 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval())) { |
880 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
881 | 0 | return false; |
882 | 0 | } |
883 | 0 | return true; |
884 | 0 | } |
885 | | |
886 | | static const JSJitInfo clone_methodinfo = { |
887 | | { (JSJitGetterOp)clone }, |
888 | | { prototypes::id::MediaStream }, |
889 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
890 | | JSJitInfo::Method, |
891 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
892 | | JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */ |
893 | | false, /* isInfallible. False in setters. */ |
894 | | false, /* isMovable. Not relevant for setters. */ |
895 | | false, /* isEliminatable. Not relevant for setters. */ |
896 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
897 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
898 | | false, /* isTypedMethod. Only relevant for methods. */ |
899 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
900 | | }; |
901 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
902 | | static_assert(0 < 1, "There is no slot for us"); |
903 | | |
904 | | MOZ_CAN_RUN_SCRIPT static bool |
905 | | get_active(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitGetterCallArgs args) |
906 | 0 | { |
907 | 0 | AUTO_PROFILER_LABEL_FAST("get MediaStream.active", DOM, cx); |
908 | 0 |
|
909 | 0 | bool result(self->Active()); |
910 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
911 | 0 | args.rval().setBoolean(result); |
912 | 0 | return true; |
913 | 0 | } |
914 | | |
915 | | static const JSJitInfo active_getterinfo = { |
916 | | { (JSJitGetterOp)get_active }, |
917 | | { prototypes::id::MediaStream }, |
918 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
919 | | JSJitInfo::Getter, |
920 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
921 | | JSVAL_TYPE_BOOLEAN, /* returnType. Not relevant for setters. */ |
922 | | true, /* isInfallible. False in setters. */ |
923 | | false, /* isMovable. Not relevant for setters. */ |
924 | | false, /* isEliminatable. Not relevant for setters. */ |
925 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
926 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
927 | | false, /* isTypedMethod. Only relevant for methods. */ |
928 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
929 | | }; |
930 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
931 | | static_assert(0 < 1, "There is no slot for us"); |
932 | | |
933 | | MOZ_CAN_RUN_SCRIPT static bool |
934 | | get_onaddtrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitGetterCallArgs args) |
935 | 0 | { |
936 | 0 | AUTO_PROFILER_LABEL_FAST("get MediaStream.onaddtrack", DOM, cx); |
937 | 0 |
|
938 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnaddtrack()); |
939 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
940 | 0 | if (result) { |
941 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
942 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
943 | 0 | return false; |
944 | 0 | } |
945 | 0 | return true; |
946 | 0 | } else { |
947 | 0 | args.rval().setNull(); |
948 | 0 | return true; |
949 | 0 | } |
950 | 0 | } |
951 | | |
952 | | MOZ_CAN_RUN_SCRIPT static bool |
953 | | set_onaddtrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitSetterCallArgs args) |
954 | 0 | { |
955 | 0 | AUTO_PROFILER_LABEL_FAST("set MediaStream.onaddtrack", DOM, cx); |
956 | 0 |
|
957 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
958 | 0 | if (args[0].isObject()) { |
959 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
960 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
961 | 0 | } |
962 | 0 | } else { |
963 | 0 | arg0 = nullptr; |
964 | 0 | } |
965 | 0 | self->SetOnaddtrack(Constify(arg0)); |
966 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
967 | 0 |
|
968 | 0 | return true; |
969 | 0 | } |
970 | | |
971 | | static const JSJitInfo onaddtrack_getterinfo = { |
972 | | { (JSJitGetterOp)get_onaddtrack }, |
973 | | { prototypes::id::MediaStream }, |
974 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
975 | | JSJitInfo::Getter, |
976 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
977 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
978 | | false, /* isInfallible. False in setters. */ |
979 | | false, /* isMovable. Not relevant for setters. */ |
980 | | false, /* isEliminatable. Not relevant for setters. */ |
981 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
982 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
983 | | false, /* isTypedMethod. Only relevant for methods. */ |
984 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
985 | | }; |
986 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
987 | | static_assert(0 < 1, "There is no slot for us"); |
988 | | static const JSJitInfo onaddtrack_setterinfo = { |
989 | | { (JSJitGetterOp)set_onaddtrack }, |
990 | | { prototypes::id::MediaStream }, |
991 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
992 | | JSJitInfo::Setter, |
993 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
994 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
995 | | false, /* isInfallible. False in setters. */ |
996 | | false, /* isMovable. Not relevant for setters. */ |
997 | | false, /* isEliminatable. Not relevant for setters. */ |
998 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
999 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1000 | | false, /* isTypedMethod. Only relevant for methods. */ |
1001 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1002 | | }; |
1003 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1004 | | static_assert(0 < 1, "There is no slot for us"); |
1005 | | |
1006 | | MOZ_CAN_RUN_SCRIPT static bool |
1007 | | get_onremovetrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitGetterCallArgs args) |
1008 | 0 | { |
1009 | 0 | AUTO_PROFILER_LABEL_FAST("get MediaStream.onremovetrack", DOM, cx); |
1010 | 0 |
|
1011 | 0 | RefPtr<EventHandlerNonNull> result(self->GetOnremovetrack()); |
1012 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1013 | 0 | if (result) { |
1014 | 0 | args.rval().setObjectOrNull(GetCallbackFromCallbackObject(cx, result)); |
1015 | 0 | if (!MaybeWrapObjectOrNullValue(cx, args.rval())) { |
1016 | 0 | return false; |
1017 | 0 | } |
1018 | 0 | return true; |
1019 | 0 | } else { |
1020 | 0 | args.rval().setNull(); |
1021 | 0 | return true; |
1022 | 0 | } |
1023 | 0 | } |
1024 | | |
1025 | | MOZ_CAN_RUN_SCRIPT static bool |
1026 | | set_onremovetrack(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitSetterCallArgs args) |
1027 | 0 | { |
1028 | 0 | AUTO_PROFILER_LABEL_FAST("set MediaStream.onremovetrack", DOM, cx); |
1029 | 0 |
|
1030 | 0 | RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx); |
1031 | 0 | if (args[0].isObject()) { |
1032 | 0 | { // scope for tempRoot and tempGlobalRoot if needed |
1033 | 0 | arg0 = new binding_detail::FastEventHandlerNonNull(&args[0].toObject(), JS::CurrentGlobalOrNull(cx)); |
1034 | 0 | } |
1035 | 0 | } else { |
1036 | 0 | arg0 = nullptr; |
1037 | 0 | } |
1038 | 0 | self->SetOnremovetrack(Constify(arg0)); |
1039 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1040 | 0 |
|
1041 | 0 | return true; |
1042 | 0 | } |
1043 | | |
1044 | | static const JSJitInfo onremovetrack_getterinfo = { |
1045 | | { (JSJitGetterOp)get_onremovetrack }, |
1046 | | { prototypes::id::MediaStream }, |
1047 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
1048 | | JSJitInfo::Getter, |
1049 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1050 | | JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */ |
1051 | | false, /* isInfallible. False in setters. */ |
1052 | | false, /* isMovable. Not relevant for setters. */ |
1053 | | false, /* isEliminatable. Not relevant for setters. */ |
1054 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1055 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1056 | | false, /* isTypedMethod. Only relevant for methods. */ |
1057 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1058 | | }; |
1059 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1060 | | static_assert(0 < 1, "There is no slot for us"); |
1061 | | static const JSJitInfo onremovetrack_setterinfo = { |
1062 | | { (JSJitGetterOp)set_onremovetrack }, |
1063 | | { prototypes::id::MediaStream }, |
1064 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
1065 | | JSJitInfo::Setter, |
1066 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1067 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1068 | | false, /* isInfallible. False in setters. */ |
1069 | | false, /* isMovable. Not relevant for setters. */ |
1070 | | false, /* isEliminatable. Not relevant for setters. */ |
1071 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1072 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1073 | | false, /* isTypedMethod. Only relevant for methods. */ |
1074 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1075 | | }; |
1076 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1077 | | static_assert(0 < 1, "There is no slot for us"); |
1078 | | |
1079 | | MOZ_CAN_RUN_SCRIPT static bool |
1080 | | get_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, JSJitGetterCallArgs args) |
1081 | 0 | { |
1082 | 0 | AUTO_PROFILER_LABEL_FAST("get MediaStream.currentTime", DOM, cx); |
1083 | 0 |
|
1084 | 0 | double result(self->CurrentTime()); |
1085 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1086 | 0 | args.rval().set(JS_NumberValue(double(result))); |
1087 | 0 | return true; |
1088 | 0 | } |
1089 | | |
1090 | | static const JSJitInfo currentTime_getterinfo = { |
1091 | | { (JSJitGetterOp)get_currentTime }, |
1092 | | { prototypes::id::MediaStream }, |
1093 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
1094 | | JSJitInfo::Getter, |
1095 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1096 | | JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */ |
1097 | | true, /* isInfallible. False in setters. */ |
1098 | | false, /* isMovable. Not relevant for setters. */ |
1099 | | false, /* isEliminatable. Not relevant for setters. */ |
1100 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1101 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1102 | | false, /* isTypedMethod. Only relevant for methods. */ |
1103 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1104 | | }; |
1105 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1106 | | static_assert(0 < 1, "There is no slot for us"); |
1107 | | |
1108 | | static bool |
1109 | | countUnderlyingStreams(JSContext* cx, unsigned argc, JS::Value* vp) |
1110 | 0 | { |
1111 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.countUnderlyingStreams", DOM, cx); |
1112 | 0 |
|
1113 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
1114 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
1115 | 0 |
|
1116 | 0 | GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); |
1117 | 0 | if (global.Failed()) { |
1118 | 0 | return false; |
1119 | 0 | } |
1120 | 0 | |
1121 | 0 | FastErrorResult rv; |
1122 | 0 | auto result(StrongOrRawPtr<Promise>(mozilla::DOMMediaStream::CountUnderlyingStreams(global, rv))); |
1123 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1124 | 0 | return false; |
1125 | 0 | } |
1126 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1127 | 0 | if (!ToJSValue(cx, result, args.rval())) { |
1128 | 0 | return false; |
1129 | 0 | } |
1130 | 0 | return true; |
1131 | 0 | } |
1132 | | |
1133 | | |
1134 | | static const JSJitInfo countUnderlyingStreams_methodinfo = { |
1135 | | { (JSJitGetterOp)countUnderlyingStreams }, |
1136 | | { prototypes::id::_ID_Count }, { 0 }, JSJitInfo::StaticMethod, |
1137 | | JSJitInfo::AliasEverything, JSVAL_TYPE_MISSING, false, false, |
1138 | | false, false, 0 |
1139 | | }; |
1140 | | |
1141 | | MOZ_CAN_RUN_SCRIPT static bool |
1142 | | assignId(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMMediaStream* self, const JSJitMethodCallArgs& args) |
1143 | 0 | { |
1144 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream.assignId", DOM, cx); |
1145 | 0 |
|
1146 | 0 | if (MOZ_UNLIKELY(args.length() < 1)) { |
1147 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaStream.assignId"); |
1148 | 0 | } |
1149 | 0 | binding_detail::FakeString arg0; |
1150 | 0 | if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) { |
1151 | 0 | return false; |
1152 | 0 | } |
1153 | 0 | self->AssignId(NonNullHelper(Constify(arg0))); |
1154 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1155 | 0 | args.rval().setUndefined(); |
1156 | 0 | return true; |
1157 | 0 | } |
1158 | | |
1159 | | static const JSJitInfo assignId_methodinfo = { |
1160 | | { (JSJitGetterOp)assignId }, |
1161 | | { prototypes::id::MediaStream }, |
1162 | | { PrototypeTraits<prototypes::id::MediaStream>::Depth }, |
1163 | | JSJitInfo::Method, |
1164 | | JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */ |
1165 | | JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */ |
1166 | | false, /* isInfallible. False in setters. */ |
1167 | | false, /* isMovable. Not relevant for setters. */ |
1168 | | false, /* isEliminatable. Not relevant for setters. */ |
1169 | | false, /* isAlwaysInSlot. Only relevant for getters. */ |
1170 | | false, /* isLazilyCachedInSlot. Only relevant for getters. */ |
1171 | | false, /* isTypedMethod. Only relevant for methods. */ |
1172 | | 0 /* Reserved slot index, if we're stored in a slot, else 0. */ |
1173 | | }; |
1174 | | static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit"); |
1175 | | static_assert(0 < 1, "There is no slot for us"); |
1176 | | |
1177 | | static bool |
1178 | | _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val) |
1179 | 0 | { |
1180 | 0 | mozilla::DOMMediaStream* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMMediaStream>(obj); |
1181 | 0 | // We don't want to preserve if we don't have a wrapper, and we |
1182 | 0 | // obviously can't preserve if we're not initialized. |
1183 | 0 | if (self && self->GetWrapperPreserveColor()) { |
1184 | 0 | PreserveWrapper(self); |
1185 | 0 | } |
1186 | 0 | return true; |
1187 | 0 | } |
1188 | | |
1189 | | static void |
1190 | | _finalize(js::FreeOp* fop, JSObject* obj) |
1191 | 0 | { |
1192 | 0 | mozilla::DOMMediaStream* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMMediaStream>(obj); |
1193 | 0 | if (self) { |
1194 | 0 | ClearWrapper(self, self, obj); |
1195 | 0 | AddForDeferredFinalization<mozilla::DOMMediaStream>(self); |
1196 | 0 | } |
1197 | 0 | } |
1198 | | |
1199 | | static size_t |
1200 | | _objectMoved(JSObject* obj, JSObject* old) |
1201 | 0 | { |
1202 | 0 | mozilla::DOMMediaStream* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMMediaStream>(obj); |
1203 | 0 | if (self) { |
1204 | 0 | UpdateWrapper(self, self, obj, old); |
1205 | 0 | } |
1206 | 0 |
|
1207 | 0 | return 0; |
1208 | 0 | } |
1209 | | |
1210 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1211 | | #if defined(__clang__) |
1212 | | #pragma clang diagnostic push |
1213 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1214 | | #endif |
1215 | | static const JSFunctionSpec sChromeStaticMethods_specs[] = { |
1216 | | JS_FNSPEC("countUnderlyingStreams", StaticMethodPromiseWrapper, &countUnderlyingStreams_methodinfo, 0, JSPROP_ENUMERATE, nullptr), |
1217 | | JS_FS_END |
1218 | | }; |
1219 | | #if defined(__clang__) |
1220 | | #pragma clang diagnostic pop |
1221 | | #endif |
1222 | | |
1223 | | |
1224 | | static const Prefable<const JSFunctionSpec> sChromeStaticMethods[] = { |
1225 | | { nullptr, &sChromeStaticMethods_specs[0] }, |
1226 | | { nullptr, nullptr } |
1227 | | }; |
1228 | | |
1229 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1230 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1231 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1232 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1233 | | |
1234 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1235 | | #if defined(__clang__) |
1236 | | #pragma clang diagnostic push |
1237 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1238 | | #endif |
1239 | | static const JSFunctionSpec sMethods_specs[] = { |
1240 | | JS_FNSPEC("getAudioTracks", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getAudioTracks_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1241 | | JS_FNSPEC("getVideoTracks", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getVideoTracks_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1242 | | JS_FNSPEC("getTracks", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTracks_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1243 | | JS_FNSPEC("getTrackById", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTrackById_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1244 | | JS_FNSPEC("addTrack", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&addTrack_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1245 | | JS_FNSPEC("removeTrack", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&removeTrack_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1246 | | JS_FNSPEC("clone", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&clone_methodinfo), 0, JSPROP_ENUMERATE, nullptr), |
1247 | | JS_FS_END |
1248 | | }; |
1249 | | #if defined(__clang__) |
1250 | | #pragma clang diagnostic pop |
1251 | | #endif |
1252 | | |
1253 | | |
1254 | | static const Prefable<const JSFunctionSpec> sMethods[] = { |
1255 | | { nullptr, &sMethods_specs[0] }, |
1256 | | { nullptr, nullptr } |
1257 | | }; |
1258 | | |
1259 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1260 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1261 | | static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1262 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1263 | | |
1264 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1265 | | #if defined(__clang__) |
1266 | | #pragma clang diagnostic push |
1267 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1268 | | #endif |
1269 | | static const JSFunctionSpec sChromeMethods_specs[] = { |
1270 | | JS_FNSPEC("assignId", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&assignId_methodinfo), 1, JSPROP_ENUMERATE, nullptr), |
1271 | | JS_FS_END |
1272 | | }; |
1273 | | #if defined(__clang__) |
1274 | | #pragma clang diagnostic pop |
1275 | | #endif |
1276 | | |
1277 | | |
1278 | | static const Prefable<const JSFunctionSpec> sChromeMethods[] = { |
1279 | | { nullptr, &sChromeMethods_specs[0] }, |
1280 | | { nullptr, nullptr } |
1281 | | }; |
1282 | | |
1283 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1284 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1285 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1286 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1287 | | |
1288 | | // We deliberately use brace-elision to make Visual Studio produce better initalization code. |
1289 | | #if defined(__clang__) |
1290 | | #pragma clang diagnostic push |
1291 | | #pragma clang diagnostic ignored "-Wmissing-braces" |
1292 | | #endif |
1293 | | static const JSPropertySpec sAttributes_specs[] = { |
1294 | | { "id", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &id_getterinfo, nullptr, nullptr }, |
1295 | | { "active", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &active_getterinfo, nullptr, nullptr }, |
1296 | | { "onaddtrack", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onaddtrack_getterinfo, GenericSetter<NormalThisPolicy>, &onaddtrack_setterinfo }, |
1297 | | { "onremovetrack", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &onremovetrack_getterinfo, GenericSetter<NormalThisPolicy>, &onremovetrack_setterinfo }, |
1298 | | { "currentTime", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, ¤tTime_getterinfo, nullptr, nullptr }, |
1299 | | { nullptr, 0, nullptr, nullptr, nullptr, nullptr } |
1300 | | }; |
1301 | | #if defined(__clang__) |
1302 | | #pragma clang diagnostic pop |
1303 | | #endif |
1304 | | |
1305 | | |
1306 | | static const Prefable<const JSPropertySpec> sAttributes[] = { |
1307 | | { nullptr, &sAttributes_specs[0] }, |
1308 | | { nullptr, nullptr } |
1309 | | }; |
1310 | | |
1311 | | static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX, |
1312 | | "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)"); |
1313 | | static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX, |
1314 | | "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)"); |
1315 | | |
1316 | | |
1317 | | static uint16_t sNativeProperties_sortedPropertyIndices[12]; |
1318 | | static PropertyInfo sNativeProperties_propertyInfos[12]; |
1319 | | |
1320 | | static const NativePropertiesN<2> sNativeProperties = { |
1321 | | false, 0, |
1322 | | false, 0, |
1323 | | true, 0 /* sMethods */, |
1324 | | true, 1 /* sAttributes */, |
1325 | | false, 0, |
1326 | | false, 0, |
1327 | | false, 0, |
1328 | | -1, |
1329 | | 12, |
1330 | | sNativeProperties_sortedPropertyIndices, |
1331 | | { |
1332 | | { sMethods, &sNativeProperties_propertyInfos[0] }, |
1333 | | { sAttributes, &sNativeProperties_propertyInfos[7] } |
1334 | | } |
1335 | | }; |
1336 | | static_assert(12 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount), |
1337 | | "We have a property info count that is oversized"); |
1338 | | |
1339 | | static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[2]; |
1340 | | static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[2]; |
1341 | | |
1342 | | static const NativePropertiesN<2> sChromeOnlyNativeProperties = { |
1343 | | true, 0 /* sChromeStaticMethods */, |
1344 | | false, 0, |
1345 | | true, 1 /* sChromeMethods */, |
1346 | | false, 0, |
1347 | | false, 0, |
1348 | | false, 0, |
1349 | | false, 0, |
1350 | | -1, |
1351 | | 2, |
1352 | | sChromeOnlyNativeProperties_sortedPropertyIndices, |
1353 | | { |
1354 | | { sChromeStaticMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }, |
1355 | | { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[1] } |
1356 | | } |
1357 | | }; |
1358 | | static_assert(2 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount), |
1359 | | "We have a property info count that is oversized"); |
1360 | | |
1361 | | static bool |
1362 | | _constructor(JSContext* cx, unsigned argc, JS::Value* vp) |
1363 | 0 | { |
1364 | 0 | AUTO_PROFILER_LABEL_FAST("MediaStream constructor", DOM, cx); |
1365 | 0 |
|
1366 | 0 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); |
1367 | 0 | JS::Rooted<JSObject*> obj(cx, &args.callee()); |
1368 | 0 | if (!args.isConstructing()) { |
1369 | 0 | // XXXbz wish I could get the name from the callee instead of |
1370 | 0 | // Adding more relocations |
1371 | 0 | return ThrowConstructorWithoutNew(cx, "MediaStream"); |
1372 | 0 | } |
1373 | 0 | |
1374 | 0 | JS::Rooted<JSObject*> desiredProto(cx); |
1375 | 0 | if (!GetDesiredProto(cx, args, &desiredProto)) { |
1376 | 0 | return false; |
1377 | 0 | } |
1378 | 0 | |
1379 | 0 | unsigned argcount = std::min(args.length(), 1u); |
1380 | 0 | switch (argcount) { |
1381 | 0 | case 0: { |
1382 | 0 | GlobalObject global(cx, obj); |
1383 | 0 | if (global.Failed()) { |
1384 | 0 | return false; |
1385 | 0 | } |
1386 | 0 | |
1387 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1388 | 0 | Maybe<JSAutoRealm> ar; |
1389 | 0 | if (objIsXray) { |
1390 | 0 | obj = js::CheckedUnwrap(obj); |
1391 | 0 | if (!obj) { |
1392 | 0 | return false; |
1393 | 0 | } |
1394 | 0 | ar.emplace(cx, obj); |
1395 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1396 | 0 | return false; |
1397 | 0 | } |
1398 | 0 | } |
1399 | 0 | FastErrorResult rv; |
1400 | 0 | auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(mozilla::DOMMediaStream::Constructor(global, rv))); |
1401 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1402 | 0 | return false; |
1403 | 0 | } |
1404 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1405 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1406 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1407 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1408 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1409 | 0 | return false; |
1410 | 0 | } |
1411 | 0 | return true; |
1412 | 0 | break; |
1413 | 0 | } |
1414 | 0 | case 1: { |
1415 | 0 | if (args[0].isObject()) { |
1416 | 0 | do { |
1417 | 0 | NonNull<mozilla::DOMMediaStream> arg0; |
1418 | 0 | { |
1419 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStream, mozilla::DOMMediaStream>(args[0], arg0); |
1420 | 0 | if (NS_FAILED(rv)) { |
1421 | 0 | break; |
1422 | 0 | } |
1423 | 0 | } |
1424 | 0 | GlobalObject global(cx, obj); |
1425 | 0 | if (global.Failed()) { |
1426 | 0 | return false; |
1427 | 0 | } |
1428 | 0 | |
1429 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1430 | 0 | Maybe<JSAutoRealm> ar; |
1431 | 0 | if (objIsXray) { |
1432 | 0 | obj = js::CheckedUnwrap(obj); |
1433 | 0 | if (!obj) { |
1434 | 0 | return false; |
1435 | 0 | } |
1436 | 0 | ar.emplace(cx, obj); |
1437 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1438 | 0 | return false; |
1439 | 0 | } |
1440 | 0 | } |
1441 | 0 | FastErrorResult rv; |
1442 | 0 | auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(mozilla::DOMMediaStream::Constructor(global, MOZ_KnownLive(NonNullHelper(arg0)), rv))); |
1443 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1444 | 0 | return false; |
1445 | 0 | } |
1446 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1447 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1448 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1449 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1450 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1451 | 0 | return false; |
1452 | 0 | } |
1453 | 0 | return true; |
1454 | 0 | } while (false); |
1455 | 0 | do { |
1456 | 0 | binding_detail::AutoSequence<OwningNonNull<mozilla::dom::MediaStreamTrack>> arg0; |
1457 | 0 | JS::ForOfIterator iter(cx); |
1458 | 0 | if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) { |
1459 | 0 | return false; |
1460 | 0 | } |
1461 | 0 | if (!iter.valueIsIterable()) { |
1462 | 0 | break; |
1463 | 0 | } |
1464 | 0 | binding_detail::AutoSequence<OwningNonNull<mozilla::dom::MediaStreamTrack>> &arr = arg0; |
1465 | 0 | JS::Rooted<JS::Value> temp(cx); |
1466 | 0 | while (true) { |
1467 | 0 | bool done; |
1468 | 0 | if (!iter.next(&temp, &done)) { |
1469 | 0 | return false; |
1470 | 0 | } |
1471 | 0 | if (done) { |
1472 | 0 | break; |
1473 | 0 | } |
1474 | 0 | OwningNonNull<mozilla::dom::MediaStreamTrack>* slotPtr = arr.AppendElement(mozilla::fallible); |
1475 | 0 | if (!slotPtr) { |
1476 | 0 | JS_ReportOutOfMemory(cx); |
1477 | 0 | return false; |
1478 | 0 | } |
1479 | 0 | OwningNonNull<mozilla::dom::MediaStreamTrack>& slot = *slotPtr; |
1480 | 0 | if (temp.isObject()) { |
1481 | 0 | static_assert(IsRefcounted<mozilla::dom::MediaStreamTrack>::value, "We can only store refcounted classes.");{ |
1482 | 0 | nsresult rv = UnwrapObject<prototypes::id::MediaStreamTrack, mozilla::dom::MediaStreamTrack>(&temp, slot); |
1483 | 0 | if (NS_FAILED(rv)) { |
1484 | 0 | ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Element of argument 1 of MediaStream", "MediaStreamTrack"); |
1485 | 0 | return false; |
1486 | 0 | } |
1487 | 0 | } |
1488 | 0 | } else { |
1489 | 0 | ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Element of argument 1 of MediaStream"); |
1490 | 0 | return false; |
1491 | 0 | } |
1492 | 0 | } |
1493 | 0 | GlobalObject global(cx, obj); |
1494 | 0 | if (global.Failed()) { |
1495 | 0 | return false; |
1496 | 0 | } |
1497 | 0 | |
1498 | 0 | bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj); |
1499 | 0 | Maybe<JSAutoRealm> ar; |
1500 | 0 | if (objIsXray) { |
1501 | 0 | obj = js::CheckedUnwrap(obj); |
1502 | 0 | if (!obj) { |
1503 | 0 | return false; |
1504 | 0 | } |
1505 | 0 | ar.emplace(cx, obj); |
1506 | 0 | if (!JS_WrapObject(cx, &desiredProto)) { |
1507 | 0 | return false; |
1508 | 0 | } |
1509 | 0 | } |
1510 | 0 | FastErrorResult rv; |
1511 | 0 | auto result(StrongOrRawPtr<mozilla::DOMMediaStream>(mozilla::DOMMediaStream::Constructor(global, Constify(arg0), rv))); |
1512 | 0 | if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) { |
1513 | 0 | return false; |
1514 | 0 | } |
1515 | 0 | MOZ_ASSERT(!JS_IsExceptionPending(cx)); |
1516 | 0 | static_assert(!IsPointer<decltype(result)>::value, |
1517 | 0 | "NewObject implies that we need to keep the object alive with a strong reference."); |
1518 | 0 | if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) { |
1519 | 0 | MOZ_ASSERT(JS_IsExceptionPending(cx)); |
1520 | 0 | return false; |
1521 | 0 | } |
1522 | 0 | return true; |
1523 | 0 | } while (false); |
1524 | 0 | } |
1525 | 0 | return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "1", "MediaStream"); |
1526 | 0 | break; |
1527 | 0 | } |
1528 | 0 | default: { |
1529 | 0 | return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "MediaStream"); |
1530 | 0 | break; |
1531 | 0 | } |
1532 | 0 | } |
1533 | 0 | MOZ_CRASH("We have an always-returning default case"); |
1534 | 0 | return false; |
1535 | 0 | } |
1536 | | |
1537 | | static const js::ClassOps sInterfaceObjectClassOps = { |
1538 | | nullptr, /* addProperty */ |
1539 | | nullptr, /* delProperty */ |
1540 | | nullptr, /* enumerate */ |
1541 | | nullptr, /* newEnumerate */ |
1542 | | nullptr, /* resolve */ |
1543 | | nullptr, /* mayResolve */ |
1544 | | nullptr, /* finalize */ |
1545 | | _constructor, /* call */ |
1546 | | nullptr, /* hasInstance */ |
1547 | | _constructor, /* construct */ |
1548 | | nullptr, /* trace */ |
1549 | | }; |
1550 | | |
1551 | | static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = { |
1552 | | { |
1553 | | "Function", |
1554 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE), |
1555 | | &sInterfaceObjectClassOps, |
1556 | | JS_NULL_CLASS_SPEC, |
1557 | | JS_NULL_CLASS_EXT, |
1558 | | &sInterfaceObjectClassObjectOps |
1559 | | }, |
1560 | | eInterface, |
1561 | | true, |
1562 | | prototypes::id::MediaStream, |
1563 | | PrototypeTraits<prototypes::id::MediaStream>::Depth, |
1564 | | sNativePropertyHooks, |
1565 | | "function MediaStream() {\n [native code]\n}", |
1566 | | EventTarget_Binding::GetConstructorObject |
1567 | | }; |
1568 | | |
1569 | | static const DOMIfaceAndProtoJSClass sPrototypeClass = { |
1570 | | { |
1571 | | "MediaStreamPrototype", |
1572 | | JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE), |
1573 | | JS_NULL_CLASS_OPS, |
1574 | | JS_NULL_CLASS_SPEC, |
1575 | | JS_NULL_CLASS_EXT, |
1576 | | JS_NULL_OBJECT_OPS |
1577 | | }, |
1578 | | eInterfacePrototype, |
1579 | | false, |
1580 | | prototypes::id::MediaStream, |
1581 | | PrototypeTraits<prototypes::id::MediaStream>::Depth, |
1582 | | sNativePropertyHooks, |
1583 | | "[object MediaStreamPrototype]", |
1584 | | EventTarget_Binding::GetProtoObject |
1585 | | }; |
1586 | | |
1587 | | static const js::ClassOps sClassOps = { |
1588 | | _addProperty, /* addProperty */ |
1589 | | nullptr, /* delProperty */ |
1590 | | nullptr, /* enumerate */ |
1591 | | nullptr, /* newEnumerate */ |
1592 | | nullptr, /* resolve */ |
1593 | | nullptr, /* mayResolve */ |
1594 | | _finalize, /* finalize */ |
1595 | | nullptr, /* call */ |
1596 | | nullptr, /* hasInstance */ |
1597 | | nullptr, /* construct */ |
1598 | | nullptr, /* trace */ |
1599 | | }; |
1600 | | |
1601 | | static const js::ClassExtension sClassExtension = { |
1602 | | nullptr, /* weakmapKeyDelegateOp */ |
1603 | | _objectMoved /* objectMovedOp */ |
1604 | | }; |
1605 | | |
1606 | | static const DOMJSClass sClass = { |
1607 | | { "MediaStream", |
1608 | | JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1), |
1609 | | &sClassOps, |
1610 | | JS_NULL_CLASS_SPEC, |
1611 | | &sClassExtension, |
1612 | | JS_NULL_OBJECT_OPS |
1613 | | }, |
1614 | | { prototypes::id::EventTarget, prototypes::id::MediaStream, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count }, |
1615 | | IsBaseOf<nsISupports, mozilla::DOMMediaStream >::value, |
1616 | | sNativePropertyHooks, |
1617 | | FindAssociatedGlobalForNative<mozilla::DOMMediaStream>::Get, |
1618 | | GetProtoObjectHandle, |
1619 | | GetCCParticipant<mozilla::DOMMediaStream>::Get() |
1620 | | }; |
1621 | | static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS, |
1622 | | "Must have the right minimal number of reserved slots."); |
1623 | | static_assert(1 >= 1, |
1624 | | "Must have enough reserved slots."); |
1625 | | |
1626 | | const JSClass* |
1627 | | GetJSClass() |
1628 | 0 | { |
1629 | 0 | return sClass.ToJSClass(); |
1630 | 0 | } |
1631 | | |
1632 | | bool |
1633 | | Wrap(JSContext* aCx, mozilla::DOMMediaStream* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector) |
1634 | 0 | { |
1635 | 0 | static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::DOMMediaStream>::value, |
1636 | 0 | "Shouldn't have wrappercached things that are not refcounted."); |
1637 | 0 | MOZ_ASSERT(static_cast<mozilla::DOMMediaStream*>(aObject) == |
1638 | 0 | reinterpret_cast<mozilla::DOMMediaStream*>(aObject), |
1639 | 0 | "Multiple inheritance for mozilla::DOMMediaStream is broken."); |
1640 | 0 | MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) == |
1641 | 0 | reinterpret_cast<mozilla::dom::EventTarget*>(aObject), |
1642 | 0 | "Multiple inheritance for mozilla::dom::EventTarget is broken."); |
1643 | 0 | MOZ_ASSERT(ToSupportsIsCorrect(aObject)); |
1644 | 0 | MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx)); |
1645 | 0 | MOZ_ASSERT(!aCache->GetWrapper(), |
1646 | 0 | "You should probably not be using Wrap() directly; use " |
1647 | 0 | "GetOrCreateDOMReflector instead"); |
1648 | 0 |
|
1649 | 0 | MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache), |
1650 | 0 | "nsISupports must be on our primary inheritance chain"); |
1651 | 0 |
|
1652 | 0 | JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject())); |
1653 | 0 | if (!global) { |
1654 | 0 | return false; |
1655 | 0 | } |
1656 | 0 | MOZ_ASSERT(JS_IsGlobalObject(global)); |
1657 | 0 | MOZ_ASSERT(JS::ObjectIsNotGray(global)); |
1658 | 0 |
|
1659 | 0 | // That might have ended up wrapping us already, due to the wonders |
1660 | 0 | // of XBL. Check for that, and bail out as needed. |
1661 | 0 | aReflector.set(aCache->GetWrapper()); |
1662 | 0 | if (aReflector) { |
1663 | | #ifdef DEBUG |
1664 | | AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto); |
1665 | | #endif // DEBUG |
1666 | | return true; |
1667 | 0 | } |
1668 | 0 |
|
1669 | 0 | JSAutoRealm ar(aCx, global); |
1670 | 0 | JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx); |
1671 | 0 | if (!canonicalProto) { |
1672 | 0 | return false; |
1673 | 0 | } |
1674 | 0 | JS::Rooted<JSObject*> proto(aCx); |
1675 | 0 | if (aGivenProto) { |
1676 | 0 | proto = aGivenProto; |
1677 | 0 | // Unfortunately, while aGivenProto was in the compartment of aCx |
1678 | 0 | // coming in, we changed compartments to that of "parent" so may need |
1679 | 0 | // to wrap the proto here. |
1680 | 0 | if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) { |
1681 | 0 | if (!JS_WrapObject(aCx, &proto)) { |
1682 | 0 | return false; |
1683 | 0 | } |
1684 | 0 | } |
1685 | 0 | } else { |
1686 | 0 | proto = canonicalProto; |
1687 | 0 | } |
1688 | 0 |
|
1689 | 0 | BindingJSObjectCreator<mozilla::DOMMediaStream> creator(aCx); |
1690 | 0 | creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector); |
1691 | 0 | if (!aReflector) { |
1692 | 0 | return false; |
1693 | 0 | } |
1694 | 0 | |
1695 | 0 | aCache->SetWrapper(aReflector); |
1696 | 0 | creator.InitializationSucceeded(); |
1697 | 0 |
|
1698 | 0 | MOZ_ASSERT(aCache->GetWrapperPreserveColor() && |
1699 | 0 | aCache->GetWrapperPreserveColor() == aReflector); |
1700 | 0 | // If proto != canonicalProto, we have to preserve our wrapper; |
1701 | 0 | // otherwise we won't be able to properly recreate it later, since |
1702 | 0 | // we won't know what proto to use. Note that we don't check |
1703 | 0 | // aGivenProto here, since it's entirely possible (and even |
1704 | 0 | // somewhat common) to have a non-null aGivenProto which is the |
1705 | 0 | // same as canonicalProto. |
1706 | 0 | if (proto != canonicalProto) { |
1707 | 0 | PreserveWrapper(aObject); |
1708 | 0 | } |
1709 | 0 |
|
1710 | 0 | return true; |
1711 | 0 | } |
1712 | | |
1713 | | const NativePropertyHooks sNativePropertyHooks[] = { { |
1714 | | nullptr, |
1715 | | nullptr, |
1716 | | nullptr, |
1717 | | { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() }, |
1718 | | prototypes::id::MediaStream, |
1719 | | constructors::id::MediaStream, |
1720 | | EventTarget_Binding::sNativePropertyHooks, |
1721 | | &DefaultXrayExpandoObjectClass |
1722 | | } }; |
1723 | | |
1724 | | void |
1725 | | CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal) |
1726 | 0 | { |
1727 | 0 | JS::Handle<JSObject*> parentProto(EventTarget_Binding::GetProtoObjectHandle(aCx)); |
1728 | 0 | if (!parentProto) { |
1729 | 0 | return; |
1730 | 0 | } |
1731 | 0 | |
1732 | 0 | JS::Handle<JSObject*> constructorProto(EventTarget_Binding::GetConstructorObjectHandle(aCx)); |
1733 | 0 | if (!constructorProto) { |
1734 | 0 | return; |
1735 | 0 | } |
1736 | 0 | |
1737 | 0 | static bool sIdsInited = false; |
1738 | 0 | if (!sIdsInited && NS_IsMainThread()) { |
1739 | 0 | if (!InitIds(aCx, sNativeProperties.Upcast())) { |
1740 | 0 | return; |
1741 | 0 | } |
1742 | 0 | if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) { |
1743 | 0 | return; |
1744 | 0 | } |
1745 | 0 | sIdsInited = true; |
1746 | 0 | } |
1747 | 0 |
|
1748 | 0 | JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::MediaStream); |
1749 | 0 | JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::MediaStream); |
1750 | 0 | dom::CreateInterfaceObjects(aCx, aGlobal, parentProto, |
1751 | 0 | &sPrototypeClass.mBase, protoCache, |
1752 | 0 | nullptr, |
1753 | 0 | constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr, |
1754 | 0 | interfaceCache, |
1755 | 0 | sNativeProperties.Upcast(), |
1756 | 0 | sChromeOnlyNativeProperties.Upcast(), |
1757 | 0 | "MediaStream", aDefineOnGlobal, |
1758 | 0 | nullptr, |
1759 | 0 | false); |
1760 | 0 | } |
1761 | | |
1762 | | JSObject* |
1763 | | GetProtoObject(JSContext* aCx) |
1764 | 0 | { |
1765 | 0 | return GetProtoObjectHandle(aCx); |
1766 | 0 | } |
1767 | | |
1768 | | JSObject* |
1769 | | GetConstructorObject(JSContext* aCx) |
1770 | 0 | { |
1771 | 0 | return GetConstructorObjectHandle(aCx); |
1772 | 0 | } |
1773 | | |
1774 | | } // namespace MediaStream_Binding |
1775 | | |
1776 | | |
1777 | | |
1778 | | } // namespace dom |
1779 | | } // namespace mozilla |