Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM MediaStreamTrack.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #ifndef mozilla_dom_MediaStreamTrackBinding_h
4 : #define mozilla_dom_MediaStreamTrackBinding_h
5 :
6 : #include "MediaStreamTrackBinding.h"
7 : #include "MediaTrackConstraintSetBinding.h"
8 : #include "js/RootingAPI.h"
9 : #include "jspubtd.h"
10 : #include "mozilla/ErrorResult.h"
11 : #include "mozilla/dom/BindingDeclarations.h"
12 : #include "mozilla/dom/FakeString.h"
13 : #include "mozilla/dom/Nullable.h"
14 : #include "mozilla/dom/UnionMember.h"
15 :
16 : namespace mozilla {
17 : namespace dom {
18 :
19 : class BooleanOrConstrainBooleanParameters;
20 : class DoubleOrConstrainDoubleRange;
21 : class LongOrConstrainLongRange;
22 : class MediaStreamTrack;
23 : struct MediaStreamTrackAtoms;
24 : struct MediaTrackConstraintSet;
25 : struct MediaTrackConstraintSetAtoms;
26 : struct MediaTrackConstraintsAtoms;
27 : struct NativePropertyHooks;
28 : class OwningBooleanOrConstrainBooleanParameters;
29 : class OwningDoubleOrConstrainDoubleRange;
30 : class OwningLongOrConstrainLongRange;
31 : class OwningStringOrStringSequenceOrConstrainDOMStringParameters;
32 : class ProtoAndIfaceCache;
33 : class StringOrStringSequenceOrConstrainDOMStringParameters;
34 :
35 : } // namespace dom
36 : } // namespace mozilla
37 :
38 : namespace mozilla {
39 : namespace dom {
40 :
41 : enum class VideoFacingModeEnum : uint8_t {
42 : User,
43 : Environment,
44 : Left,
45 : Right,
46 : EndGuard_
47 : };
48 :
49 : namespace VideoFacingModeEnumValues {
50 : extern const EnumEntry strings[5];
51 : } // namespace VideoFacingModeEnumValues
52 :
53 : bool
54 : ToJSValue(JSContext* aCx, VideoFacingModeEnum aArgument, JS::MutableHandle<JS::Value> aValue);
55 :
56 :
57 : enum class MediaSourceEnum : uint8_t {
58 : Camera,
59 : Screen,
60 : Application,
61 : Window,
62 : Browser,
63 : Microphone,
64 : AudioCapture,
65 : Other,
66 : EndGuard_
67 : };
68 :
69 : namespace MediaSourceEnumValues {
70 : extern const EnumEntry strings[9];
71 : } // namespace MediaSourceEnumValues
72 :
73 : bool
74 : ToJSValue(JSContext* aCx, MediaSourceEnum aArgument, JS::MutableHandle<JS::Value> aValue);
75 :
76 :
77 : enum class MediaStreamTrackState : uint8_t {
78 : Live,
79 : Ended,
80 : EndGuard_
81 : };
82 :
83 : namespace MediaStreamTrackStateValues {
84 : extern const EnumEntry strings[3];
85 : } // namespace MediaStreamTrackStateValues
86 :
87 : bool
88 : ToJSValue(JSContext* aCx, MediaStreamTrackState aArgument, JS::MutableHandle<JS::Value> aValue);
89 :
90 :
91 : class BooleanOrConstrainBooleanParameters
92 : {
93 : friend class BooleanOrConstrainBooleanParametersArgument;
94 : enum Type
95 : {
96 : eUninitialized,
97 : eBoolean,
98 : eConstrainBooleanParameters
99 : };
100 :
101 : union Value
102 : {
103 : UnionMember<bool > mBoolean;
104 : UnionMember<binding_detail::FastConstrainBooleanParameters > mConstrainBooleanParameters;
105 :
106 : };
107 :
108 : Type mType;
109 : Value mValue;
110 :
111 : BooleanOrConstrainBooleanParameters(const BooleanOrConstrainBooleanParameters&) = delete;
112 : BooleanOrConstrainBooleanParameters& operator=(const BooleanOrConstrainBooleanParameters&) = delete;
113 : public:
114 : explicit inline BooleanOrConstrainBooleanParameters()
115 : : mType(eUninitialized)
116 : {
117 : }
118 :
119 : inline ~BooleanOrConstrainBooleanParameters()
120 : {
121 : Uninit();
122 : }
123 :
124 : inline bool&
125 : RawSetAsBoolean()
126 : {
127 : if (mType == eBoolean) {
128 : return mValue.mBoolean.Value();
129 : }
130 : MOZ_ASSERT(mType == eUninitialized);
131 : mType = eBoolean;
132 : return mValue.mBoolean.SetValue();
133 : }
134 :
135 : inline bool&
136 : SetAsBoolean()
137 : {
138 : if (mType == eBoolean) {
139 : return mValue.mBoolean.Value();
140 : }
141 : Uninit();
142 : mType = eBoolean;
143 : return mValue.mBoolean.SetValue();
144 : }
145 :
146 : inline bool
147 : IsBoolean() const
148 : {
149 : return mType == eBoolean;
150 : }
151 :
152 : inline bool&
153 : GetAsBoolean()
154 : {
155 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
156 : return mValue.mBoolean.Value();
157 : }
158 :
159 : inline bool
160 : GetAsBoolean() const
161 : {
162 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
163 : return mValue.mBoolean.Value();
164 : }
165 :
166 : inline binding_detail::FastConstrainBooleanParameters&
167 : RawSetAsConstrainBooleanParameters()
168 : {
169 : if (mType == eConstrainBooleanParameters) {
170 : return mValue.mConstrainBooleanParameters.Value();
171 : }
172 : MOZ_ASSERT(mType == eUninitialized);
173 : mType = eConstrainBooleanParameters;
174 : return mValue.mConstrainBooleanParameters.SetValue();
175 : }
176 :
177 : inline binding_detail::FastConstrainBooleanParameters&
178 : SetAsConstrainBooleanParameters()
179 : {
180 : if (mType == eConstrainBooleanParameters) {
181 : return mValue.mConstrainBooleanParameters.Value();
182 : }
183 : Uninit();
184 : mType = eConstrainBooleanParameters;
185 : return mValue.mConstrainBooleanParameters.SetValue();
186 : }
187 :
188 : inline bool
189 : IsConstrainBooleanParameters() const
190 : {
191 : return mType == eConstrainBooleanParameters;
192 : }
193 :
194 : inline binding_detail::FastConstrainBooleanParameters&
195 : GetAsConstrainBooleanParameters()
196 : {
197 : MOZ_ASSERT(IsConstrainBooleanParameters(), "Wrong type!");
198 : return mValue.mConstrainBooleanParameters.Value();
199 : }
200 :
201 : inline const ConstrainBooleanParameters&
202 : GetAsConstrainBooleanParameters() const
203 : {
204 : MOZ_ASSERT(IsConstrainBooleanParameters(), "Wrong type!");
205 : return mValue.mConstrainBooleanParameters.Value();
206 : }
207 :
208 : inline void
209 : Uninit()
210 : {
211 : switch (mType) {
212 : case eUninitialized: {
213 : break;
214 : }
215 : case eBoolean: {
216 : DestroyBoolean();
217 : break;
218 : }
219 : case eConstrainBooleanParameters: {
220 : DestroyConstrainBooleanParameters();
221 : break;
222 : }
223 : }
224 : }
225 :
226 : bool
227 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
228 :
229 : private:
230 : inline void
231 : DestroyBoolean()
232 : {
233 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
234 : mValue.mBoolean.Destroy();
235 : mType = eUninitialized;
236 : }
237 :
238 : inline void
239 : DestroyConstrainBooleanParameters()
240 : {
241 : MOZ_ASSERT(IsConstrainBooleanParameters(), "Wrong type!");
242 : mValue.mConstrainBooleanParameters.Destroy();
243 : mType = eUninitialized;
244 : }
245 : };
246 :
247 :
248 : class OwningBooleanOrConstrainBooleanParameters : public AllOwningUnionBase
249 : {
250 : friend void ImplCycleCollectionUnlink(OwningBooleanOrConstrainBooleanParameters& aUnion);
251 : enum Type
252 : {
253 : eUninitialized,
254 : eBoolean,
255 : eConstrainBooleanParameters
256 : };
257 :
258 0 : union Value
259 : {
260 : UnionMember<bool > mBoolean;
261 : UnionMember<ConstrainBooleanParameters > mConstrainBooleanParameters;
262 :
263 : };
264 :
265 : Type mType;
266 : Value mValue;
267 :
268 : public:
269 0 : explicit inline OwningBooleanOrConstrainBooleanParameters()
270 0 : : mType(eUninitialized)
271 : {
272 0 : }
273 :
274 : explicit inline OwningBooleanOrConstrainBooleanParameters(const OwningBooleanOrConstrainBooleanParameters& aOther)
275 : : mType(eUninitialized)
276 : {
277 : *this = aOther;
278 : }
279 :
280 0 : inline ~OwningBooleanOrConstrainBooleanParameters()
281 0 : {
282 0 : Uninit();
283 0 : }
284 :
285 : bool&
286 : RawSetAsBoolean();
287 :
288 : bool&
289 : SetAsBoolean();
290 :
291 : bool
292 : TrySetToBoolean(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
293 :
294 : inline bool
295 0 : IsBoolean() const
296 : {
297 0 : return mType == eBoolean;
298 : }
299 :
300 : inline bool&
301 : GetAsBoolean()
302 : {
303 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
304 : return mValue.mBoolean.Value();
305 : }
306 :
307 : inline bool const &
308 0 : GetAsBoolean() const
309 : {
310 0 : MOZ_ASSERT(IsBoolean(), "Wrong type!");
311 0 : return mValue.mBoolean.Value();
312 : }
313 :
314 : ConstrainBooleanParameters&
315 : RawSetAsConstrainBooleanParameters();
316 :
317 : ConstrainBooleanParameters&
318 : SetAsConstrainBooleanParameters();
319 :
320 : bool
321 : TrySetToConstrainBooleanParameters(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
322 :
323 : inline bool
324 0 : IsConstrainBooleanParameters() const
325 : {
326 0 : return mType == eConstrainBooleanParameters;
327 : }
328 :
329 : inline ConstrainBooleanParameters&
330 0 : GetAsConstrainBooleanParameters()
331 : {
332 0 : MOZ_ASSERT(IsConstrainBooleanParameters(), "Wrong type!");
333 0 : return mValue.mConstrainBooleanParameters.Value();
334 : }
335 :
336 : inline ConstrainBooleanParameters const &
337 0 : GetAsConstrainBooleanParameters() const
338 : {
339 0 : MOZ_ASSERT(IsConstrainBooleanParameters(), "Wrong type!");
340 0 : return mValue.mConstrainBooleanParameters.Value();
341 : }
342 :
343 : void
344 : Uninit();
345 :
346 : bool
347 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
348 :
349 : void
350 : TraceUnion(JSTracer* trc);
351 :
352 : OwningBooleanOrConstrainBooleanParameters&
353 : operator=(const OwningBooleanOrConstrainBooleanParameters& aOther);
354 :
355 : private:
356 : void
357 : DestroyBoolean();
358 :
359 : void
360 : DestroyConstrainBooleanParameters();
361 : };
362 :
363 :
364 : class DoubleOrConstrainDoubleRange
365 : {
366 : friend class DoubleOrConstrainDoubleRangeArgument;
367 : enum Type
368 : {
369 : eUninitialized,
370 : eDouble,
371 : eConstrainDoubleRange
372 : };
373 :
374 : union Value
375 : {
376 : UnionMember<double > mDouble;
377 : UnionMember<binding_detail::FastConstrainDoubleRange > mConstrainDoubleRange;
378 :
379 : };
380 :
381 : Type mType;
382 : Value mValue;
383 :
384 : DoubleOrConstrainDoubleRange(const DoubleOrConstrainDoubleRange&) = delete;
385 : DoubleOrConstrainDoubleRange& operator=(const DoubleOrConstrainDoubleRange&) = delete;
386 : public:
387 : explicit inline DoubleOrConstrainDoubleRange()
388 : : mType(eUninitialized)
389 : {
390 : }
391 :
392 : inline ~DoubleOrConstrainDoubleRange()
393 : {
394 : Uninit();
395 : }
396 :
397 : inline double&
398 : RawSetAsDouble()
399 : {
400 : if (mType == eDouble) {
401 : return mValue.mDouble.Value();
402 : }
403 : MOZ_ASSERT(mType == eUninitialized);
404 : mType = eDouble;
405 : return mValue.mDouble.SetValue();
406 : }
407 :
408 : inline double&
409 : SetAsDouble()
410 : {
411 : if (mType == eDouble) {
412 : return mValue.mDouble.Value();
413 : }
414 : Uninit();
415 : mType = eDouble;
416 : return mValue.mDouble.SetValue();
417 : }
418 :
419 : inline bool
420 : IsDouble() const
421 : {
422 : return mType == eDouble;
423 : }
424 :
425 : inline double&
426 : GetAsDouble()
427 : {
428 : MOZ_ASSERT(IsDouble(), "Wrong type!");
429 : return mValue.mDouble.Value();
430 : }
431 :
432 : inline double
433 : GetAsDouble() const
434 : {
435 : MOZ_ASSERT(IsDouble(), "Wrong type!");
436 : return mValue.mDouble.Value();
437 : }
438 :
439 : inline binding_detail::FastConstrainDoubleRange&
440 : RawSetAsConstrainDoubleRange()
441 : {
442 : if (mType == eConstrainDoubleRange) {
443 : return mValue.mConstrainDoubleRange.Value();
444 : }
445 : MOZ_ASSERT(mType == eUninitialized);
446 : mType = eConstrainDoubleRange;
447 : return mValue.mConstrainDoubleRange.SetValue();
448 : }
449 :
450 : inline binding_detail::FastConstrainDoubleRange&
451 : SetAsConstrainDoubleRange()
452 : {
453 : if (mType == eConstrainDoubleRange) {
454 : return mValue.mConstrainDoubleRange.Value();
455 : }
456 : Uninit();
457 : mType = eConstrainDoubleRange;
458 : return mValue.mConstrainDoubleRange.SetValue();
459 : }
460 :
461 : inline bool
462 : IsConstrainDoubleRange() const
463 : {
464 : return mType == eConstrainDoubleRange;
465 : }
466 :
467 : inline binding_detail::FastConstrainDoubleRange&
468 : GetAsConstrainDoubleRange()
469 : {
470 : MOZ_ASSERT(IsConstrainDoubleRange(), "Wrong type!");
471 : return mValue.mConstrainDoubleRange.Value();
472 : }
473 :
474 : inline const ConstrainDoubleRange&
475 : GetAsConstrainDoubleRange() const
476 : {
477 : MOZ_ASSERT(IsConstrainDoubleRange(), "Wrong type!");
478 : return mValue.mConstrainDoubleRange.Value();
479 : }
480 :
481 : inline void
482 : Uninit()
483 : {
484 : switch (mType) {
485 : case eUninitialized: {
486 : break;
487 : }
488 : case eDouble: {
489 : DestroyDouble();
490 : break;
491 : }
492 : case eConstrainDoubleRange: {
493 : DestroyConstrainDoubleRange();
494 : break;
495 : }
496 : }
497 : }
498 :
499 : bool
500 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
501 :
502 : private:
503 : inline void
504 : DestroyDouble()
505 : {
506 : MOZ_ASSERT(IsDouble(), "Wrong type!");
507 : mValue.mDouble.Destroy();
508 : mType = eUninitialized;
509 : }
510 :
511 : inline void
512 : DestroyConstrainDoubleRange()
513 : {
514 : MOZ_ASSERT(IsConstrainDoubleRange(), "Wrong type!");
515 : mValue.mConstrainDoubleRange.Destroy();
516 : mType = eUninitialized;
517 : }
518 : };
519 :
520 :
521 : class OwningDoubleOrConstrainDoubleRange : public AllOwningUnionBase
522 : {
523 : friend void ImplCycleCollectionUnlink(OwningDoubleOrConstrainDoubleRange& aUnion);
524 : enum Type
525 : {
526 : eUninitialized,
527 : eDouble,
528 : eConstrainDoubleRange
529 : };
530 :
531 0 : union Value
532 : {
533 : UnionMember<double > mDouble;
534 : UnionMember<ConstrainDoubleRange > mConstrainDoubleRange;
535 :
536 : };
537 :
538 : Type mType;
539 : Value mValue;
540 :
541 : public:
542 0 : explicit inline OwningDoubleOrConstrainDoubleRange()
543 0 : : mType(eUninitialized)
544 : {
545 0 : }
546 :
547 : explicit inline OwningDoubleOrConstrainDoubleRange(const OwningDoubleOrConstrainDoubleRange& aOther)
548 : : mType(eUninitialized)
549 : {
550 : *this = aOther;
551 : }
552 :
553 0 : inline ~OwningDoubleOrConstrainDoubleRange()
554 0 : {
555 0 : Uninit();
556 0 : }
557 :
558 : double&
559 : RawSetAsDouble();
560 :
561 : double&
562 : SetAsDouble();
563 :
564 : bool
565 : TrySetToDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
566 :
567 : inline bool
568 0 : IsDouble() const
569 : {
570 0 : return mType == eDouble;
571 : }
572 :
573 : inline double&
574 : GetAsDouble()
575 : {
576 : MOZ_ASSERT(IsDouble(), "Wrong type!");
577 : return mValue.mDouble.Value();
578 : }
579 :
580 : inline double const &
581 0 : GetAsDouble() const
582 : {
583 0 : MOZ_ASSERT(IsDouble(), "Wrong type!");
584 0 : return mValue.mDouble.Value();
585 : }
586 :
587 : ConstrainDoubleRange&
588 : RawSetAsConstrainDoubleRange();
589 :
590 : ConstrainDoubleRange&
591 : SetAsConstrainDoubleRange();
592 :
593 : bool
594 : TrySetToConstrainDoubleRange(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
595 :
596 : inline bool
597 0 : IsConstrainDoubleRange() const
598 : {
599 0 : return mType == eConstrainDoubleRange;
600 : }
601 :
602 : inline ConstrainDoubleRange&
603 : GetAsConstrainDoubleRange()
604 : {
605 : MOZ_ASSERT(IsConstrainDoubleRange(), "Wrong type!");
606 : return mValue.mConstrainDoubleRange.Value();
607 : }
608 :
609 : inline ConstrainDoubleRange const &
610 0 : GetAsConstrainDoubleRange() const
611 : {
612 0 : MOZ_ASSERT(IsConstrainDoubleRange(), "Wrong type!");
613 0 : return mValue.mConstrainDoubleRange.Value();
614 : }
615 :
616 : void
617 : Uninit();
618 :
619 : bool
620 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
621 :
622 : void
623 : TraceUnion(JSTracer* trc);
624 :
625 : OwningDoubleOrConstrainDoubleRange&
626 : operator=(const OwningDoubleOrConstrainDoubleRange& aOther);
627 :
628 : private:
629 : void
630 : DestroyDouble();
631 :
632 : void
633 : DestroyConstrainDoubleRange();
634 : };
635 :
636 :
637 : class LongOrConstrainLongRange
638 : {
639 : friend class LongOrConstrainLongRangeArgument;
640 : enum Type
641 : {
642 : eUninitialized,
643 : eLong,
644 : eConstrainLongRange
645 : };
646 :
647 : union Value
648 : {
649 : UnionMember<int32_t > mLong;
650 : UnionMember<binding_detail::FastConstrainLongRange > mConstrainLongRange;
651 :
652 : };
653 :
654 : Type mType;
655 : Value mValue;
656 :
657 : LongOrConstrainLongRange(const LongOrConstrainLongRange&) = delete;
658 : LongOrConstrainLongRange& operator=(const LongOrConstrainLongRange&) = delete;
659 : public:
660 : explicit inline LongOrConstrainLongRange()
661 : : mType(eUninitialized)
662 : {
663 : }
664 :
665 : inline ~LongOrConstrainLongRange()
666 : {
667 : Uninit();
668 : }
669 :
670 : inline int32_t&
671 : RawSetAsLong()
672 : {
673 : if (mType == eLong) {
674 : return mValue.mLong.Value();
675 : }
676 : MOZ_ASSERT(mType == eUninitialized);
677 : mType = eLong;
678 : return mValue.mLong.SetValue();
679 : }
680 :
681 : inline int32_t&
682 : SetAsLong()
683 : {
684 : if (mType == eLong) {
685 : return mValue.mLong.Value();
686 : }
687 : Uninit();
688 : mType = eLong;
689 : return mValue.mLong.SetValue();
690 : }
691 :
692 : inline bool
693 : IsLong() const
694 : {
695 : return mType == eLong;
696 : }
697 :
698 : inline int32_t&
699 : GetAsLong()
700 : {
701 : MOZ_ASSERT(IsLong(), "Wrong type!");
702 : return mValue.mLong.Value();
703 : }
704 :
705 : inline int32_t
706 : GetAsLong() const
707 : {
708 : MOZ_ASSERT(IsLong(), "Wrong type!");
709 : return mValue.mLong.Value();
710 : }
711 :
712 : inline binding_detail::FastConstrainLongRange&
713 : RawSetAsConstrainLongRange()
714 : {
715 : if (mType == eConstrainLongRange) {
716 : return mValue.mConstrainLongRange.Value();
717 : }
718 : MOZ_ASSERT(mType == eUninitialized);
719 : mType = eConstrainLongRange;
720 : return mValue.mConstrainLongRange.SetValue();
721 : }
722 :
723 : inline binding_detail::FastConstrainLongRange&
724 : SetAsConstrainLongRange()
725 : {
726 : if (mType == eConstrainLongRange) {
727 : return mValue.mConstrainLongRange.Value();
728 : }
729 : Uninit();
730 : mType = eConstrainLongRange;
731 : return mValue.mConstrainLongRange.SetValue();
732 : }
733 :
734 : inline bool
735 : IsConstrainLongRange() const
736 : {
737 : return mType == eConstrainLongRange;
738 : }
739 :
740 : inline binding_detail::FastConstrainLongRange&
741 : GetAsConstrainLongRange()
742 : {
743 : MOZ_ASSERT(IsConstrainLongRange(), "Wrong type!");
744 : return mValue.mConstrainLongRange.Value();
745 : }
746 :
747 : inline const ConstrainLongRange&
748 : GetAsConstrainLongRange() const
749 : {
750 : MOZ_ASSERT(IsConstrainLongRange(), "Wrong type!");
751 : return mValue.mConstrainLongRange.Value();
752 : }
753 :
754 : inline void
755 : Uninit()
756 : {
757 : switch (mType) {
758 : case eUninitialized: {
759 : break;
760 : }
761 : case eLong: {
762 : DestroyLong();
763 : break;
764 : }
765 : case eConstrainLongRange: {
766 : DestroyConstrainLongRange();
767 : break;
768 : }
769 : }
770 : }
771 :
772 : bool
773 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
774 :
775 : private:
776 : inline void
777 : DestroyLong()
778 : {
779 : MOZ_ASSERT(IsLong(), "Wrong type!");
780 : mValue.mLong.Destroy();
781 : mType = eUninitialized;
782 : }
783 :
784 : inline void
785 : DestroyConstrainLongRange()
786 : {
787 : MOZ_ASSERT(IsConstrainLongRange(), "Wrong type!");
788 : mValue.mConstrainLongRange.Destroy();
789 : mType = eUninitialized;
790 : }
791 : };
792 :
793 :
794 : class OwningLongOrConstrainLongRange : public AllOwningUnionBase
795 : {
796 : friend void ImplCycleCollectionUnlink(OwningLongOrConstrainLongRange& aUnion);
797 : enum Type
798 : {
799 : eUninitialized,
800 : eLong,
801 : eConstrainLongRange
802 : };
803 :
804 0 : union Value
805 : {
806 : UnionMember<int32_t > mLong;
807 : UnionMember<ConstrainLongRange > mConstrainLongRange;
808 :
809 : };
810 :
811 : Type mType;
812 : Value mValue;
813 :
814 : public:
815 0 : explicit inline OwningLongOrConstrainLongRange()
816 0 : : mType(eUninitialized)
817 : {
818 0 : }
819 :
820 : explicit inline OwningLongOrConstrainLongRange(const OwningLongOrConstrainLongRange& aOther)
821 : : mType(eUninitialized)
822 : {
823 : *this = aOther;
824 : }
825 :
826 0 : inline ~OwningLongOrConstrainLongRange()
827 0 : {
828 0 : Uninit();
829 0 : }
830 :
831 : int32_t&
832 : RawSetAsLong();
833 :
834 : int32_t&
835 : SetAsLong();
836 :
837 : bool
838 : TrySetToLong(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
839 :
840 : inline bool
841 0 : IsLong() const
842 : {
843 0 : return mType == eLong;
844 : }
845 :
846 : inline int32_t&
847 : GetAsLong()
848 : {
849 : MOZ_ASSERT(IsLong(), "Wrong type!");
850 : return mValue.mLong.Value();
851 : }
852 :
853 : inline int32_t const &
854 0 : GetAsLong() const
855 : {
856 0 : MOZ_ASSERT(IsLong(), "Wrong type!");
857 0 : return mValue.mLong.Value();
858 : }
859 :
860 : ConstrainLongRange&
861 : RawSetAsConstrainLongRange();
862 :
863 : ConstrainLongRange&
864 : SetAsConstrainLongRange();
865 :
866 : bool
867 : TrySetToConstrainLongRange(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
868 :
869 : inline bool
870 0 : IsConstrainLongRange() const
871 : {
872 0 : return mType == eConstrainLongRange;
873 : }
874 :
875 : inline ConstrainLongRange&
876 : GetAsConstrainLongRange()
877 : {
878 : MOZ_ASSERT(IsConstrainLongRange(), "Wrong type!");
879 : return mValue.mConstrainLongRange.Value();
880 : }
881 :
882 : inline ConstrainLongRange const &
883 0 : GetAsConstrainLongRange() const
884 : {
885 0 : MOZ_ASSERT(IsConstrainLongRange(), "Wrong type!");
886 0 : return mValue.mConstrainLongRange.Value();
887 : }
888 :
889 : void
890 : Uninit();
891 :
892 : bool
893 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
894 :
895 : void
896 : TraceUnion(JSTracer* trc);
897 :
898 : OwningLongOrConstrainLongRange&
899 : operator=(const OwningLongOrConstrainLongRange& aOther);
900 :
901 : private:
902 : void
903 : DestroyLong();
904 :
905 : void
906 : DestroyConstrainLongRange();
907 : };
908 :
909 :
910 : class StringOrStringSequenceOrConstrainDOMStringParameters
911 : {
912 : friend class StringOrStringSequenceOrConstrainDOMStringParametersArgument;
913 : enum Type
914 : {
915 : eUninitialized,
916 : eString,
917 : eStringSequence,
918 : eConstrainDOMStringParameters
919 : };
920 :
921 : union Value
922 : {
923 : UnionMember<binding_detail::FakeString > mString;
924 : UnionMember<binding_detail::AutoSequence<nsString> > mStringSequence;
925 : UnionMember<binding_detail::FastConstrainDOMStringParameters > mConstrainDOMStringParameters;
926 :
927 : };
928 :
929 : Type mType;
930 : Value mValue;
931 :
932 : StringOrStringSequenceOrConstrainDOMStringParameters(const StringOrStringSequenceOrConstrainDOMStringParameters&) = delete;
933 : StringOrStringSequenceOrConstrainDOMStringParameters& operator=(const StringOrStringSequenceOrConstrainDOMStringParameters&) = delete;
934 : public:
935 : explicit inline StringOrStringSequenceOrConstrainDOMStringParameters()
936 : : mType(eUninitialized)
937 : {
938 : }
939 :
940 : inline ~StringOrStringSequenceOrConstrainDOMStringParameters()
941 : {
942 : Uninit();
943 : }
944 :
945 : inline binding_detail::FakeString&
946 : RawSetAsString()
947 : {
948 : if (mType == eString) {
949 : return mValue.mString.Value();
950 : }
951 : MOZ_ASSERT(mType == eUninitialized);
952 : mType = eString;
953 : return mValue.mString.SetValue();
954 : }
955 :
956 : inline binding_detail::FakeString&
957 : SetAsString()
958 : {
959 : if (mType == eString) {
960 : return mValue.mString.Value();
961 : }
962 : Uninit();
963 : mType = eString;
964 : return mValue.mString.SetValue();
965 : }
966 :
967 : inline bool
968 : IsString() const
969 : {
970 : return mType == eString;
971 : }
972 :
973 : inline binding_detail::FakeString&
974 : GetAsString()
975 : {
976 : MOZ_ASSERT(IsString(), "Wrong type!");
977 : return mValue.mString.Value();
978 : }
979 :
980 : inline const nsAString&
981 : GetAsString() const
982 : {
983 : MOZ_ASSERT(IsString(), "Wrong type!");
984 : return mValue.mString.Value();
985 : }
986 :
987 : inline binding_detail::AutoSequence<nsString>&
988 : RawSetAsStringSequence()
989 : {
990 : if (mType == eStringSequence) {
991 : return mValue.mStringSequence.Value();
992 : }
993 : MOZ_ASSERT(mType == eUninitialized);
994 : mType = eStringSequence;
995 : return mValue.mStringSequence.SetValue();
996 : }
997 :
998 : inline binding_detail::AutoSequence<nsString>&
999 : SetAsStringSequence()
1000 : {
1001 : if (mType == eStringSequence) {
1002 : return mValue.mStringSequence.Value();
1003 : }
1004 : Uninit();
1005 : mType = eStringSequence;
1006 : return mValue.mStringSequence.SetValue();
1007 : }
1008 :
1009 : inline bool
1010 : IsStringSequence() const
1011 : {
1012 : return mType == eStringSequence;
1013 : }
1014 :
1015 : inline binding_detail::AutoSequence<nsString>&
1016 : GetAsStringSequence()
1017 : {
1018 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
1019 : return mValue.mStringSequence.Value();
1020 : }
1021 :
1022 : inline const Sequence<nsString>&
1023 : GetAsStringSequence() const
1024 : {
1025 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
1026 : return mValue.mStringSequence.Value();
1027 : }
1028 :
1029 : inline binding_detail::FastConstrainDOMStringParameters&
1030 : RawSetAsConstrainDOMStringParameters()
1031 : {
1032 : if (mType == eConstrainDOMStringParameters) {
1033 : return mValue.mConstrainDOMStringParameters.Value();
1034 : }
1035 : MOZ_ASSERT(mType == eUninitialized);
1036 : mType = eConstrainDOMStringParameters;
1037 : return mValue.mConstrainDOMStringParameters.SetValue();
1038 : }
1039 :
1040 : inline binding_detail::FastConstrainDOMStringParameters&
1041 : SetAsConstrainDOMStringParameters()
1042 : {
1043 : if (mType == eConstrainDOMStringParameters) {
1044 : return mValue.mConstrainDOMStringParameters.Value();
1045 : }
1046 : Uninit();
1047 : mType = eConstrainDOMStringParameters;
1048 : return mValue.mConstrainDOMStringParameters.SetValue();
1049 : }
1050 :
1051 : inline bool
1052 : IsConstrainDOMStringParameters() const
1053 : {
1054 : return mType == eConstrainDOMStringParameters;
1055 : }
1056 :
1057 : inline binding_detail::FastConstrainDOMStringParameters&
1058 : GetAsConstrainDOMStringParameters()
1059 : {
1060 : MOZ_ASSERT(IsConstrainDOMStringParameters(), "Wrong type!");
1061 : return mValue.mConstrainDOMStringParameters.Value();
1062 : }
1063 :
1064 : inline const ConstrainDOMStringParameters&
1065 : GetAsConstrainDOMStringParameters() const
1066 : {
1067 : MOZ_ASSERT(IsConstrainDOMStringParameters(), "Wrong type!");
1068 : return mValue.mConstrainDOMStringParameters.Value();
1069 : }
1070 :
1071 : inline void
1072 : Uninit()
1073 : {
1074 : switch (mType) {
1075 : case eUninitialized: {
1076 : break;
1077 : }
1078 : case eString: {
1079 : DestroyString();
1080 : break;
1081 : }
1082 : case eStringSequence: {
1083 : DestroyStringSequence();
1084 : break;
1085 : }
1086 : case eConstrainDOMStringParameters: {
1087 : DestroyConstrainDOMStringParameters();
1088 : break;
1089 : }
1090 : }
1091 : }
1092 :
1093 : bool
1094 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1095 :
1096 : private:
1097 : inline void
1098 : DestroyString()
1099 : {
1100 : MOZ_ASSERT(IsString(), "Wrong type!");
1101 : mValue.mString.Destroy();
1102 : mType = eUninitialized;
1103 : }
1104 :
1105 : inline void
1106 : DestroyStringSequence()
1107 : {
1108 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
1109 : mValue.mStringSequence.Destroy();
1110 : mType = eUninitialized;
1111 : }
1112 :
1113 : inline void
1114 : DestroyConstrainDOMStringParameters()
1115 : {
1116 : MOZ_ASSERT(IsConstrainDOMStringParameters(), "Wrong type!");
1117 : mValue.mConstrainDOMStringParameters.Destroy();
1118 : mType = eUninitialized;
1119 : }
1120 : };
1121 :
1122 :
1123 : class OwningStringOrStringSequenceOrConstrainDOMStringParameters : public AllOwningUnionBase
1124 : {
1125 : friend void ImplCycleCollectionUnlink(OwningStringOrStringSequenceOrConstrainDOMStringParameters& aUnion);
1126 : enum Type
1127 : {
1128 : eUninitialized,
1129 : eString,
1130 : eStringSequence,
1131 : eConstrainDOMStringParameters
1132 : };
1133 :
1134 0 : union Value
1135 : {
1136 : UnionMember<nsString > mString;
1137 : UnionMember<Sequence<nsString> > mStringSequence;
1138 : UnionMember<ConstrainDOMStringParameters > mConstrainDOMStringParameters;
1139 :
1140 : };
1141 :
1142 : Type mType;
1143 : Value mValue;
1144 :
1145 : public:
1146 0 : explicit inline OwningStringOrStringSequenceOrConstrainDOMStringParameters()
1147 0 : : mType(eUninitialized)
1148 : {
1149 0 : }
1150 :
1151 : explicit inline OwningStringOrStringSequenceOrConstrainDOMStringParameters(const OwningStringOrStringSequenceOrConstrainDOMStringParameters& aOther)
1152 : : mType(eUninitialized)
1153 : {
1154 : *this = aOther;
1155 : }
1156 :
1157 0 : inline ~OwningStringOrStringSequenceOrConstrainDOMStringParameters()
1158 0 : {
1159 0 : Uninit();
1160 0 : }
1161 :
1162 : nsString&
1163 : RawSetAsString();
1164 :
1165 : nsString&
1166 : SetAsString();
1167 :
1168 : bool
1169 : TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
1170 :
1171 : inline void
1172 : SetStringData(const nsString::char_type* aData, nsString::size_type aLength)
1173 : {
1174 : RawSetAsString().Assign(aData, aLength);
1175 : }
1176 :
1177 : inline bool
1178 0 : IsString() const
1179 : {
1180 0 : return mType == eString;
1181 : }
1182 :
1183 : inline nsString&
1184 : GetAsString()
1185 : {
1186 : MOZ_ASSERT(IsString(), "Wrong type!");
1187 : return mValue.mString.Value();
1188 : }
1189 :
1190 : inline nsString const &
1191 0 : GetAsString() const
1192 : {
1193 0 : MOZ_ASSERT(IsString(), "Wrong type!");
1194 0 : return mValue.mString.Value();
1195 : }
1196 :
1197 : Sequence<nsString>&
1198 : RawSetAsStringSequence();
1199 :
1200 : Sequence<nsString>&
1201 : SetAsStringSequence();
1202 :
1203 : bool
1204 : TrySetToStringSequence(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
1205 :
1206 : inline bool
1207 0 : IsStringSequence() const
1208 : {
1209 0 : return mType == eStringSequence;
1210 : }
1211 :
1212 : inline Sequence<nsString>&
1213 : GetAsStringSequence()
1214 : {
1215 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
1216 : return mValue.mStringSequence.Value();
1217 : }
1218 :
1219 : inline Sequence<nsString> const &
1220 0 : GetAsStringSequence() const
1221 : {
1222 0 : MOZ_ASSERT(IsStringSequence(), "Wrong type!");
1223 0 : return mValue.mStringSequence.Value();
1224 : }
1225 :
1226 : ConstrainDOMStringParameters&
1227 : RawSetAsConstrainDOMStringParameters();
1228 :
1229 : ConstrainDOMStringParameters&
1230 : SetAsConstrainDOMStringParameters();
1231 :
1232 : bool
1233 : TrySetToConstrainDOMStringParameters(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl = false);
1234 :
1235 : inline bool
1236 0 : IsConstrainDOMStringParameters() const
1237 : {
1238 0 : return mType == eConstrainDOMStringParameters;
1239 : }
1240 :
1241 : inline ConstrainDOMStringParameters&
1242 : GetAsConstrainDOMStringParameters()
1243 : {
1244 : MOZ_ASSERT(IsConstrainDOMStringParameters(), "Wrong type!");
1245 : return mValue.mConstrainDOMStringParameters.Value();
1246 : }
1247 :
1248 : inline ConstrainDOMStringParameters const &
1249 0 : GetAsConstrainDOMStringParameters() const
1250 : {
1251 0 : MOZ_ASSERT(IsConstrainDOMStringParameters(), "Wrong type!");
1252 0 : return mValue.mConstrainDOMStringParameters.Value();
1253 : }
1254 :
1255 : void
1256 : Uninit();
1257 :
1258 : bool
1259 : ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const;
1260 :
1261 : void
1262 : TraceUnion(JSTracer* trc);
1263 :
1264 : OwningStringOrStringSequenceOrConstrainDOMStringParameters&
1265 : operator=(const OwningStringOrStringSequenceOrConstrainDOMStringParameters& aOther);
1266 :
1267 : private:
1268 : void
1269 : DestroyString();
1270 :
1271 : void
1272 : DestroyStringSequence();
1273 :
1274 : void
1275 : DestroyConstrainDOMStringParameters();
1276 : };
1277 :
1278 :
1279 0 : struct MediaTrackConstraintSet : public DictionaryBase
1280 : {
1281 : MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrConstrainBooleanParameters mAutoGainControl;
1282 : MOZ_INIT_OUTSIDE_CTOR Optional<int64_t> mBrowserWindow;
1283 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mChannelCount;
1284 : MOZ_INIT_OUTSIDE_CTOR OwningStringOrStringSequenceOrConstrainDOMStringParameters mDeviceId;
1285 : MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrConstrainBooleanParameters mEchoCancellation;
1286 : MOZ_INIT_OUTSIDE_CTOR OwningStringOrStringSequenceOrConstrainDOMStringParameters mFacingMode;
1287 : MOZ_INIT_OUTSIDE_CTOR OwningDoubleOrConstrainDoubleRange mFrameRate;
1288 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mHeight;
1289 : MOZ_INIT_OUTSIDE_CTOR nsString mMediaSource;
1290 : MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrConstrainBooleanParameters mMozAutoGainControl;
1291 : MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrConstrainBooleanParameters mMozNoiseSuppression;
1292 : MOZ_INIT_OUTSIDE_CTOR OwningBooleanOrConstrainBooleanParameters mNoiseSuppression;
1293 : MOZ_INIT_OUTSIDE_CTOR Optional<bool> mScrollWithPage;
1294 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mViewportHeight;
1295 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mViewportOffsetX;
1296 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mViewportOffsetY;
1297 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mViewportWidth;
1298 : MOZ_INIT_OUTSIDE_CTOR OwningLongOrConstrainLongRange mWidth;
1299 :
1300 : MediaTrackConstraintSet();
1301 :
1302 0 : explicit inline MediaTrackConstraintSet(const FastDictionaryInitializer& )
1303 0 : {
1304 : // Do nothing here; this is used by our "Fast" subclass
1305 0 : }
1306 :
1307 0 : explicit inline MediaTrackConstraintSet(const MediaTrackConstraintSet& aOther)
1308 0 : {
1309 0 : *this = aOther;
1310 0 : }
1311 :
1312 : bool
1313 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
1314 :
1315 : bool
1316 : Init(const nsAString& aJSON);
1317 :
1318 : bool
1319 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
1320 :
1321 : bool
1322 : ToJSON(nsAString& aJSON) const;
1323 :
1324 : void
1325 : TraceDictionary(JSTracer* trc);
1326 :
1327 : MediaTrackConstraintSet&
1328 : operator=(const MediaTrackConstraintSet& aOther);
1329 :
1330 : private:
1331 : static bool
1332 : InitIds(JSContext* cx, MediaTrackConstraintSetAtoms* atomsCache);
1333 : };
1334 :
1335 : namespace binding_detail {
1336 : struct FastMediaTrackConstraintSet : public MediaTrackConstraintSet
1337 : {
1338 : inline FastMediaTrackConstraintSet()
1339 : : MediaTrackConstraintSet(FastDictionaryInitializer())
1340 : {
1341 : // Doesn't matter what int we pass to the parent constructor
1342 : }
1343 : };
1344 : } // namespace binding_detail
1345 :
1346 :
1347 0 : struct MediaTrackConstraints : public MediaTrackConstraintSet
1348 : {
1349 : MOZ_INIT_OUTSIDE_CTOR Optional<Sequence<MediaTrackConstraintSet>> mAdvanced;
1350 :
1351 : MediaTrackConstraints();
1352 :
1353 0 : explicit inline MediaTrackConstraints(const FastDictionaryInitializer& )
1354 0 : : MediaTrackConstraintSet(FastDictionaryInitializer())
1355 : {
1356 : // Do nothing here; this is used by our "Fast" subclass
1357 0 : }
1358 :
1359 0 : explicit inline MediaTrackConstraints(const MediaTrackConstraints& aOther)
1360 0 : {
1361 0 : *this = aOther;
1362 0 : }
1363 :
1364 : bool
1365 : Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
1366 :
1367 : bool
1368 : Init(const nsAString& aJSON);
1369 :
1370 : bool
1371 : ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
1372 :
1373 : bool
1374 : ToJSON(nsAString& aJSON) const;
1375 :
1376 : void
1377 : TraceDictionary(JSTracer* trc);
1378 :
1379 : MediaTrackConstraints&
1380 : operator=(const MediaTrackConstraints& aOther);
1381 :
1382 : private:
1383 : static bool
1384 : InitIds(JSContext* cx, MediaTrackConstraintsAtoms* atomsCache);
1385 : };
1386 :
1387 : namespace binding_detail {
1388 0 : struct FastMediaTrackConstraints : public MediaTrackConstraints
1389 : {
1390 0 : inline FastMediaTrackConstraints()
1391 0 : : MediaTrackConstraints(FastDictionaryInitializer())
1392 : {
1393 : // Doesn't matter what int we pass to the parent constructor
1394 0 : }
1395 : };
1396 : } // namespace binding_detail
1397 :
1398 :
1399 : namespace MediaStreamTrackBinding {
1400 :
1401 : typedef mozilla::dom::MediaStreamTrack NativeType;
1402 :
1403 : JSObject*
1404 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal);
1405 :
1406 : // We declare this as an array so that retrieving a pointer to this
1407 : // binding's property hooks only requires compile/link-time resolvable
1408 : // address arithmetic. Declaring it as a pointer instead would require
1409 : // doing a run-time load to fetch a pointer to this binding's property
1410 : // hooks. And then structures which embedded a pointer to this structure
1411 : // would require a run-time load for proper initialization, which would
1412 : // then induce static constructors. Lots of static constructors.
1413 : extern const NativePropertyHooks sNativePropertyHooks[];
1414 :
1415 : void
1416 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal);
1417 :
1418 : JS::Handle<JSObject*>
1419 : GetProtoObjectHandle(JSContext* aCx);
1420 :
1421 : JSObject*
1422 : GetProtoObject(JSContext* aCx);
1423 :
1424 : JS::Handle<JSObject*>
1425 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal = true);
1426 :
1427 : JSObject*
1428 : GetConstructorObject(JSContext* aCx);
1429 :
1430 : } // namespace MediaStreamTrackBinding
1431 :
1432 :
1433 :
1434 : } // namespace dom
1435 : } // namespace mozilla
1436 :
1437 : #endif // mozilla_dom_MediaStreamTrackBinding_h
|