Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM MediaTrackSupportedConstraints.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "MediaTrackSupportedConstraintsBinding.h"
5 : #include "mozilla/OwningNonNull.h"
6 : #include "mozilla/dom/BindingUtils.h"
7 : #include "mozilla/dom/NonRefcountedDOMObject.h"
8 : #include "mozilla/dom/PrimitiveConversions.h"
9 : #include "mozilla/dom/ScriptSettings.h"
10 : #include "mozilla/dom/SimpleGlobalObject.h"
11 :
12 : namespace mozilla {
13 : namespace dom {
14 :
15 :
16 0 : MediaTrackSupportedConstraints::MediaTrackSupportedConstraints()
17 : {
18 : // Safe to pass a null context if we pass a null value
19 0 : Init(nullptr, JS::NullHandleValue);
20 0 : }
21 :
22 :
23 :
24 : bool
25 0 : MediaTrackSupportedConstraints::InitIds(JSContext* cx, MediaTrackSupportedConstraintsAtoms* atomsCache)
26 : {
27 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
28 :
29 : // Initialize these in reverse order so that any failure leaves the first one
30 : // uninitialized.
31 0 : if (!atomsCache->width_id.init(cx, "width") ||
32 0 : !atomsCache->volume_id.init(cx, "volume") ||
33 0 : !atomsCache->viewportWidth_id.init(cx, "viewportWidth") ||
34 0 : !atomsCache->viewportOffsetY_id.init(cx, "viewportOffsetY") ||
35 0 : !atomsCache->viewportOffsetX_id.init(cx, "viewportOffsetX") ||
36 0 : !atomsCache->viewportHeight_id.init(cx, "viewportHeight") ||
37 0 : !atomsCache->scrollWithPage_id.init(cx, "scrollWithPage") ||
38 0 : !atomsCache->sampleSize_id.init(cx, "sampleSize") ||
39 0 : !atomsCache->sampleRate_id.init(cx, "sampleRate") ||
40 0 : !atomsCache->noiseSuppression_id.init(cx, "noiseSuppression") ||
41 0 : !atomsCache->mediaSource_id.init(cx, "mediaSource") ||
42 0 : !atomsCache->latency_id.init(cx, "latency") ||
43 0 : !atomsCache->height_id.init(cx, "height") ||
44 0 : !atomsCache->groupId_id.init(cx, "groupId") ||
45 0 : !atomsCache->frameRate_id.init(cx, "frameRate") ||
46 0 : !atomsCache->facingMode_id.init(cx, "facingMode") ||
47 0 : !atomsCache->echoCancellation_id.init(cx, "echoCancellation") ||
48 0 : !atomsCache->deviceId_id.init(cx, "deviceId") ||
49 0 : !atomsCache->channelCount_id.init(cx, "channelCount") ||
50 0 : !atomsCache->browserWindow_id.init(cx, "browserWindow") ||
51 0 : !atomsCache->autoGainControl_id.init(cx, "autoGainControl") ||
52 0 : !atomsCache->aspectRatio_id.init(cx, "aspectRatio")) {
53 0 : return false;
54 : }
55 0 : return true;
56 : }
57 :
58 : bool
59 0 : MediaTrackSupportedConstraints::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
60 : {
61 : // Passing a null JSContext is OK only if we're initing from null,
62 : // Since in that case we will not have to do any property gets
63 : // Also evaluate isNullOrUndefined in order to avoid false-positive
64 : // checkers by static analysis tools
65 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
66 0 : MediaTrackSupportedConstraintsAtoms* atomsCache = nullptr;
67 0 : if (cx) {
68 0 : atomsCache = GetAtomCache<MediaTrackSupportedConstraintsAtoms>(cx);
69 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
70 0 : return false;
71 : }
72 : }
73 :
74 0 : if (!IsConvertibleToDictionary(val)) {
75 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
76 : }
77 :
78 0 : bool isNull = val.isNullOrUndefined();
79 : // We only need these if !isNull, in which case we have |cx|.
80 0 : Maybe<JS::Rooted<JSObject *> > object;
81 0 : Maybe<JS::Rooted<JS::Value> > temp;
82 0 : if (!isNull) {
83 0 : MOZ_ASSERT(cx);
84 0 : object.emplace(cx, &val.toObject());
85 0 : temp.emplace(cx);
86 : }
87 0 : if (!isNull) {
88 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->aspectRatio_id, temp.ptr())) {
89 0 : return false;
90 : }
91 : }
92 0 : if (!isNull && !temp->isUndefined()) {
93 0 : mAspectRatio.Construct();
94 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mAspectRatio.Value()))) {
95 0 : return false;
96 : }
97 0 : mIsAnyMemberPresent = true;
98 : }
99 :
100 0 : if (!isNull) {
101 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->autoGainControl_id, temp.ptr())) {
102 0 : return false;
103 : }
104 : }
105 0 : if (!isNull && !temp->isUndefined()) {
106 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mAutoGainControl)) {
107 0 : return false;
108 : }
109 : } else {
110 0 : mAutoGainControl = true;
111 : }
112 0 : mIsAnyMemberPresent = true;
113 :
114 0 : if (!isNull) {
115 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->browserWindow_id, temp.ptr())) {
116 0 : return false;
117 : }
118 : }
119 0 : if (!isNull && !temp->isUndefined()) {
120 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mBrowserWindow)) {
121 0 : return false;
122 : }
123 : } else {
124 0 : mBrowserWindow = true;
125 : }
126 0 : mIsAnyMemberPresent = true;
127 :
128 0 : if (!isNull) {
129 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->channelCount_id, temp.ptr())) {
130 0 : return false;
131 : }
132 : }
133 0 : if (!isNull && !temp->isUndefined()) {
134 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mChannelCount)) {
135 0 : return false;
136 : }
137 : } else {
138 0 : mChannelCount = true;
139 : }
140 0 : mIsAnyMemberPresent = true;
141 :
142 0 : if (!isNull) {
143 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->deviceId_id, temp.ptr())) {
144 0 : return false;
145 : }
146 : }
147 0 : if (!isNull && !temp->isUndefined()) {
148 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mDeviceId)) {
149 0 : return false;
150 : }
151 : } else {
152 0 : mDeviceId = true;
153 : }
154 0 : mIsAnyMemberPresent = true;
155 :
156 0 : if (!isNull) {
157 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->echoCancellation_id, temp.ptr())) {
158 0 : return false;
159 : }
160 : }
161 0 : if (!isNull && !temp->isUndefined()) {
162 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mEchoCancellation)) {
163 0 : return false;
164 : }
165 : } else {
166 0 : mEchoCancellation = true;
167 : }
168 0 : mIsAnyMemberPresent = true;
169 :
170 0 : if (!isNull) {
171 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->facingMode_id, temp.ptr())) {
172 0 : return false;
173 : }
174 : }
175 0 : if (!isNull && !temp->isUndefined()) {
176 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFacingMode)) {
177 0 : return false;
178 : }
179 : } else {
180 0 : mFacingMode = true;
181 : }
182 0 : mIsAnyMemberPresent = true;
183 :
184 0 : if (!isNull) {
185 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->frameRate_id, temp.ptr())) {
186 0 : return false;
187 : }
188 : }
189 0 : if (!isNull && !temp->isUndefined()) {
190 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mFrameRate)) {
191 0 : return false;
192 : }
193 : } else {
194 0 : mFrameRate = true;
195 : }
196 0 : mIsAnyMemberPresent = true;
197 :
198 0 : if (!isNull) {
199 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->groupId_id, temp.ptr())) {
200 0 : return false;
201 : }
202 : }
203 0 : if (!isNull && !temp->isUndefined()) {
204 0 : mGroupId.Construct();
205 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mGroupId.Value()))) {
206 0 : return false;
207 : }
208 0 : mIsAnyMemberPresent = true;
209 : }
210 :
211 0 : if (!isNull) {
212 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->height_id, temp.ptr())) {
213 0 : return false;
214 : }
215 : }
216 0 : if (!isNull && !temp->isUndefined()) {
217 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mHeight)) {
218 0 : return false;
219 : }
220 : } else {
221 0 : mHeight = true;
222 : }
223 0 : mIsAnyMemberPresent = true;
224 :
225 0 : if (!isNull) {
226 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->latency_id, temp.ptr())) {
227 0 : return false;
228 : }
229 : }
230 0 : if (!isNull && !temp->isUndefined()) {
231 0 : mLatency.Construct();
232 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mLatency.Value()))) {
233 0 : return false;
234 : }
235 0 : mIsAnyMemberPresent = true;
236 : }
237 :
238 0 : if (!isNull) {
239 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->mediaSource_id, temp.ptr())) {
240 0 : return false;
241 : }
242 : }
243 0 : if (!isNull && !temp->isUndefined()) {
244 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMediaSource)) {
245 0 : return false;
246 : }
247 : } else {
248 0 : mMediaSource = true;
249 : }
250 0 : mIsAnyMemberPresent = true;
251 :
252 0 : if (!isNull) {
253 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->noiseSuppression_id, temp.ptr())) {
254 0 : return false;
255 : }
256 : }
257 0 : if (!isNull && !temp->isUndefined()) {
258 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mNoiseSuppression)) {
259 0 : return false;
260 : }
261 : } else {
262 0 : mNoiseSuppression = true;
263 : }
264 0 : mIsAnyMemberPresent = true;
265 :
266 0 : if (!isNull) {
267 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->sampleRate_id, temp.ptr())) {
268 0 : return false;
269 : }
270 : }
271 0 : if (!isNull && !temp->isUndefined()) {
272 0 : mSampleRate.Construct();
273 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mSampleRate.Value()))) {
274 0 : return false;
275 : }
276 0 : mIsAnyMemberPresent = true;
277 : }
278 :
279 0 : if (!isNull) {
280 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->sampleSize_id, temp.ptr())) {
281 0 : return false;
282 : }
283 : }
284 0 : if (!isNull && !temp->isUndefined()) {
285 0 : mSampleSize.Construct();
286 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mSampleSize.Value()))) {
287 0 : return false;
288 : }
289 0 : mIsAnyMemberPresent = true;
290 : }
291 :
292 0 : if (!isNull) {
293 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->scrollWithPage_id, temp.ptr())) {
294 0 : return false;
295 : }
296 : }
297 0 : if (!isNull && !temp->isUndefined()) {
298 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mScrollWithPage)) {
299 0 : return false;
300 : }
301 : } else {
302 0 : mScrollWithPage = true;
303 : }
304 0 : mIsAnyMemberPresent = true;
305 :
306 0 : if (!isNull) {
307 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->viewportHeight_id, temp.ptr())) {
308 0 : return false;
309 : }
310 : }
311 0 : if (!isNull && !temp->isUndefined()) {
312 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportHeight)) {
313 0 : return false;
314 : }
315 : } else {
316 0 : mViewportHeight = true;
317 : }
318 0 : mIsAnyMemberPresent = true;
319 :
320 0 : if (!isNull) {
321 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->viewportOffsetX_id, temp.ptr())) {
322 0 : return false;
323 : }
324 : }
325 0 : if (!isNull && !temp->isUndefined()) {
326 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportOffsetX)) {
327 0 : return false;
328 : }
329 : } else {
330 0 : mViewportOffsetX = true;
331 : }
332 0 : mIsAnyMemberPresent = true;
333 :
334 0 : if (!isNull) {
335 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->viewportOffsetY_id, temp.ptr())) {
336 0 : return false;
337 : }
338 : }
339 0 : if (!isNull && !temp->isUndefined()) {
340 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportOffsetY)) {
341 0 : return false;
342 : }
343 : } else {
344 0 : mViewportOffsetY = true;
345 : }
346 0 : mIsAnyMemberPresent = true;
347 :
348 0 : if (!isNull) {
349 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->viewportWidth_id, temp.ptr())) {
350 0 : return false;
351 : }
352 : }
353 0 : if (!isNull && !temp->isUndefined()) {
354 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mViewportWidth)) {
355 0 : return false;
356 : }
357 : } else {
358 0 : mViewportWidth = true;
359 : }
360 0 : mIsAnyMemberPresent = true;
361 :
362 0 : if (!isNull) {
363 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->volume_id, temp.ptr())) {
364 0 : return false;
365 : }
366 : }
367 0 : if (!isNull && !temp->isUndefined()) {
368 0 : mVolume.Construct();
369 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &(mVolume.Value()))) {
370 0 : return false;
371 : }
372 0 : mIsAnyMemberPresent = true;
373 : }
374 :
375 0 : if (!isNull) {
376 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->width_id, temp.ptr())) {
377 0 : return false;
378 : }
379 : }
380 0 : if (!isNull && !temp->isUndefined()) {
381 0 : if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mWidth)) {
382 0 : return false;
383 : }
384 : } else {
385 0 : mWidth = true;
386 : }
387 0 : mIsAnyMemberPresent = true;
388 0 : return true;
389 : }
390 :
391 : bool
392 0 : MediaTrackSupportedConstraints::Init(const nsAString& aJSON)
393 : {
394 0 : AutoJSAPI jsapi;
395 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
396 0 : if (!cleanGlobal) {
397 0 : return false;
398 : }
399 0 : if (!jsapi.Init(cleanGlobal)) {
400 0 : return false;
401 : }
402 0 : JSContext* cx = jsapi.cx();
403 0 : JS::Rooted<JS::Value> json(cx);
404 0 : bool ok = ParseJSON(cx, aJSON, &json);
405 0 : NS_ENSURE_TRUE(ok, false);
406 0 : return Init(cx, json);
407 : }
408 :
409 : bool
410 0 : MediaTrackSupportedConstraints::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
411 : {
412 0 : MediaTrackSupportedConstraintsAtoms* atomsCache = GetAtomCache<MediaTrackSupportedConstraintsAtoms>(cx);
413 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
414 0 : return false;
415 : }
416 :
417 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
418 0 : if (!obj) {
419 0 : return false;
420 : }
421 0 : rval.set(JS::ObjectValue(*obj));
422 :
423 0 : if (mAspectRatio.WasPassed()) {
424 : do {
425 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
426 0 : JS::Rooted<JS::Value> temp(cx);
427 0 : bool const & currentValue = mAspectRatio.InternalValue();
428 0 : temp.setBoolean(currentValue);
429 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->aspectRatio_id, temp, JSPROP_ENUMERATE)) {
430 0 : return false;
431 : }
432 0 : break;
433 : } while(0);
434 : }
435 :
436 : do {
437 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
438 0 : JS::Rooted<JS::Value> temp(cx);
439 0 : bool const & currentValue = mAutoGainControl;
440 0 : temp.setBoolean(currentValue);
441 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->autoGainControl_id, temp, JSPROP_ENUMERATE)) {
442 0 : return false;
443 : }
444 0 : break;
445 : } while(0);
446 :
447 : do {
448 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
449 0 : JS::Rooted<JS::Value> temp(cx);
450 0 : bool const & currentValue = mBrowserWindow;
451 0 : temp.setBoolean(currentValue);
452 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->browserWindow_id, temp, JSPROP_ENUMERATE)) {
453 0 : return false;
454 : }
455 0 : break;
456 : } while(0);
457 :
458 : do {
459 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
460 0 : JS::Rooted<JS::Value> temp(cx);
461 0 : bool const & currentValue = mChannelCount;
462 0 : temp.setBoolean(currentValue);
463 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->channelCount_id, temp, JSPROP_ENUMERATE)) {
464 0 : return false;
465 : }
466 0 : break;
467 : } while(0);
468 :
469 : do {
470 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
471 0 : JS::Rooted<JS::Value> temp(cx);
472 0 : bool const & currentValue = mDeviceId;
473 0 : temp.setBoolean(currentValue);
474 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->deviceId_id, temp, JSPROP_ENUMERATE)) {
475 0 : return false;
476 : }
477 0 : break;
478 : } while(0);
479 :
480 : do {
481 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
482 0 : JS::Rooted<JS::Value> temp(cx);
483 0 : bool const & currentValue = mEchoCancellation;
484 0 : temp.setBoolean(currentValue);
485 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->echoCancellation_id, temp, JSPROP_ENUMERATE)) {
486 0 : return false;
487 : }
488 0 : break;
489 : } while(0);
490 :
491 : do {
492 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
493 0 : JS::Rooted<JS::Value> temp(cx);
494 0 : bool const & currentValue = mFacingMode;
495 0 : temp.setBoolean(currentValue);
496 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->facingMode_id, temp, JSPROP_ENUMERATE)) {
497 0 : return false;
498 : }
499 0 : break;
500 : } while(0);
501 :
502 : do {
503 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
504 0 : JS::Rooted<JS::Value> temp(cx);
505 0 : bool const & currentValue = mFrameRate;
506 0 : temp.setBoolean(currentValue);
507 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->frameRate_id, temp, JSPROP_ENUMERATE)) {
508 0 : return false;
509 : }
510 0 : break;
511 : } while(0);
512 :
513 0 : if (mGroupId.WasPassed()) {
514 : do {
515 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
516 0 : JS::Rooted<JS::Value> temp(cx);
517 0 : bool const & currentValue = mGroupId.InternalValue();
518 0 : temp.setBoolean(currentValue);
519 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->groupId_id, temp, JSPROP_ENUMERATE)) {
520 0 : return false;
521 : }
522 0 : break;
523 : } while(0);
524 : }
525 :
526 : do {
527 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
528 0 : JS::Rooted<JS::Value> temp(cx);
529 0 : bool const & currentValue = mHeight;
530 0 : temp.setBoolean(currentValue);
531 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->height_id, temp, JSPROP_ENUMERATE)) {
532 0 : return false;
533 : }
534 0 : break;
535 : } while(0);
536 :
537 0 : if (mLatency.WasPassed()) {
538 : do {
539 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
540 0 : JS::Rooted<JS::Value> temp(cx);
541 0 : bool const & currentValue = mLatency.InternalValue();
542 0 : temp.setBoolean(currentValue);
543 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->latency_id, temp, JSPROP_ENUMERATE)) {
544 0 : return false;
545 : }
546 0 : break;
547 : } while(0);
548 : }
549 :
550 : do {
551 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
552 0 : JS::Rooted<JS::Value> temp(cx);
553 0 : bool const & currentValue = mMediaSource;
554 0 : temp.setBoolean(currentValue);
555 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->mediaSource_id, temp, JSPROP_ENUMERATE)) {
556 0 : return false;
557 : }
558 0 : break;
559 : } while(0);
560 :
561 : do {
562 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
563 0 : JS::Rooted<JS::Value> temp(cx);
564 0 : bool const & currentValue = mNoiseSuppression;
565 0 : temp.setBoolean(currentValue);
566 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->noiseSuppression_id, temp, JSPROP_ENUMERATE)) {
567 0 : return false;
568 : }
569 0 : break;
570 : } while(0);
571 :
572 0 : if (mSampleRate.WasPassed()) {
573 : do {
574 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
575 0 : JS::Rooted<JS::Value> temp(cx);
576 0 : bool const & currentValue = mSampleRate.InternalValue();
577 0 : temp.setBoolean(currentValue);
578 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->sampleRate_id, temp, JSPROP_ENUMERATE)) {
579 0 : return false;
580 : }
581 0 : break;
582 : } while(0);
583 : }
584 :
585 0 : if (mSampleSize.WasPassed()) {
586 : do {
587 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
588 0 : JS::Rooted<JS::Value> temp(cx);
589 0 : bool const & currentValue = mSampleSize.InternalValue();
590 0 : temp.setBoolean(currentValue);
591 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->sampleSize_id, temp, JSPROP_ENUMERATE)) {
592 0 : return false;
593 : }
594 0 : break;
595 : } while(0);
596 : }
597 :
598 : do {
599 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
600 0 : JS::Rooted<JS::Value> temp(cx);
601 0 : bool const & currentValue = mScrollWithPage;
602 0 : temp.setBoolean(currentValue);
603 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->scrollWithPage_id, temp, JSPROP_ENUMERATE)) {
604 0 : return false;
605 : }
606 0 : break;
607 : } while(0);
608 :
609 : do {
610 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
611 0 : JS::Rooted<JS::Value> temp(cx);
612 0 : bool const & currentValue = mViewportHeight;
613 0 : temp.setBoolean(currentValue);
614 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportHeight_id, temp, JSPROP_ENUMERATE)) {
615 0 : return false;
616 : }
617 0 : break;
618 : } while(0);
619 :
620 : do {
621 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
622 0 : JS::Rooted<JS::Value> temp(cx);
623 0 : bool const & currentValue = mViewportOffsetX;
624 0 : temp.setBoolean(currentValue);
625 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportOffsetX_id, temp, JSPROP_ENUMERATE)) {
626 0 : return false;
627 : }
628 0 : break;
629 : } while(0);
630 :
631 : do {
632 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
633 0 : JS::Rooted<JS::Value> temp(cx);
634 0 : bool const & currentValue = mViewportOffsetY;
635 0 : temp.setBoolean(currentValue);
636 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportOffsetY_id, temp, JSPROP_ENUMERATE)) {
637 0 : return false;
638 : }
639 0 : break;
640 : } while(0);
641 :
642 : do {
643 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
644 0 : JS::Rooted<JS::Value> temp(cx);
645 0 : bool const & currentValue = mViewportWidth;
646 0 : temp.setBoolean(currentValue);
647 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->viewportWidth_id, temp, JSPROP_ENUMERATE)) {
648 0 : return false;
649 : }
650 0 : break;
651 : } while(0);
652 :
653 0 : if (mVolume.WasPassed()) {
654 : do {
655 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
656 0 : JS::Rooted<JS::Value> temp(cx);
657 0 : bool const & currentValue = mVolume.InternalValue();
658 0 : temp.setBoolean(currentValue);
659 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->volume_id, temp, JSPROP_ENUMERATE)) {
660 0 : return false;
661 : }
662 0 : break;
663 : } while(0);
664 : }
665 :
666 : do {
667 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
668 0 : JS::Rooted<JS::Value> temp(cx);
669 0 : bool const & currentValue = mWidth;
670 0 : temp.setBoolean(currentValue);
671 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->width_id, temp, JSPROP_ENUMERATE)) {
672 0 : return false;
673 : }
674 0 : break;
675 : } while(0);
676 :
677 0 : return true;
678 : }
679 :
680 : bool
681 0 : MediaTrackSupportedConstraints::ToJSON(nsAString& aJSON) const
682 : {
683 0 : AutoJSAPI jsapi;
684 0 : jsapi.Init();
685 0 : JSContext *cx = jsapi.cx();
686 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
687 : // because we'll only be creating objects, in ways that have no
688 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
689 : // which likewise guarantees no side-effects for the sorts of
690 : // things we will pass it.
691 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
692 0 : JS::Rooted<JS::Value> val(cx);
693 0 : if (!ToObjectInternal(cx, &val)) {
694 0 : return false;
695 : }
696 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
697 0 : return StringifyToJSON(cx, obj, aJSON);
698 : }
699 :
700 : void
701 0 : MediaTrackSupportedConstraints::TraceDictionary(JSTracer* trc)
702 : {
703 0 : }
704 :
705 : MediaTrackSupportedConstraints&
706 0 : MediaTrackSupportedConstraints::operator=(const MediaTrackSupportedConstraints& aOther)
707 : {
708 0 : mAspectRatio.Reset();
709 0 : if (aOther.mAspectRatio.WasPassed()) {
710 0 : mAspectRatio.Construct(aOther.mAspectRatio.Value());
711 : }
712 0 : mAutoGainControl = aOther.mAutoGainControl;
713 0 : mBrowserWindow = aOther.mBrowserWindow;
714 0 : mChannelCount = aOther.mChannelCount;
715 0 : mDeviceId = aOther.mDeviceId;
716 0 : mEchoCancellation = aOther.mEchoCancellation;
717 0 : mFacingMode = aOther.mFacingMode;
718 0 : mFrameRate = aOther.mFrameRate;
719 0 : mGroupId.Reset();
720 0 : if (aOther.mGroupId.WasPassed()) {
721 0 : mGroupId.Construct(aOther.mGroupId.Value());
722 : }
723 0 : mHeight = aOther.mHeight;
724 0 : mLatency.Reset();
725 0 : if (aOther.mLatency.WasPassed()) {
726 0 : mLatency.Construct(aOther.mLatency.Value());
727 : }
728 0 : mMediaSource = aOther.mMediaSource;
729 0 : mNoiseSuppression = aOther.mNoiseSuppression;
730 0 : mSampleRate.Reset();
731 0 : if (aOther.mSampleRate.WasPassed()) {
732 0 : mSampleRate.Construct(aOther.mSampleRate.Value());
733 : }
734 0 : mSampleSize.Reset();
735 0 : if (aOther.mSampleSize.WasPassed()) {
736 0 : mSampleSize.Construct(aOther.mSampleSize.Value());
737 : }
738 0 : mScrollWithPage = aOther.mScrollWithPage;
739 0 : mViewportHeight = aOther.mViewportHeight;
740 0 : mViewportOffsetX = aOther.mViewportOffsetX;
741 0 : mViewportOffsetY = aOther.mViewportOffsetY;
742 0 : mViewportWidth = aOther.mViewportWidth;
743 0 : mVolume.Reset();
744 0 : if (aOther.mVolume.WasPassed()) {
745 0 : mVolume.Construct(aOther.mVolume.Value());
746 : }
747 0 : mWidth = aOther.mWidth;
748 0 : return *this;
749 : }
750 :
751 : namespace binding_detail {
752 : } // namespace binding_detail
753 :
754 :
755 : } // namespace dom
756 : } // namespace mozilla
|