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