LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - HTMLVideoElementBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 258 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 28 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM HTMLVideoElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "HTMLMediaElementBinding.h"
       4             : #include "HTMLVideoElementBinding.h"
       5             : #include "Navigator.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/FloatingPoint.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/Preferences.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/CustomElementRegistry.h"
      12             : #include "mozilla/dom/DOMJSClass.h"
      13             : #include "mozilla/dom/HTMLVideoElement.h"
      14             : #include "mozilla/dom/MediaSource.h"
      15             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      16             : #include "mozilla/dom/PrimitiveConversions.h"
      17             : #include "mozilla/dom/VideoPlaybackQuality.h"
      18             : #include "mozilla/dom/XrayExpandoClass.h"
      19             : 
      20             : namespace mozilla {
      21             : namespace dom {
      22             : 
      23             : namespace HTMLVideoElementBinding {
      24             : 
      25             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLMediaElementBinding::NativeType>::value,
      26             :               "Can't inherit from an interface with a different ownership model.");
      27             : 
      28             : static bool
      29           0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
      30             : {
      31           0 :   uint32_t result(self->Width());
      32           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      33           0 :   args.rval().setNumber(result);
      34           0 :   return true;
      35             : }
      36             : 
      37             : static bool
      38           0 : set_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitSetterCallArgs args)
      39             : {
      40             :   uint32_t arg0;
      41           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
      42           0 :     return false;
      43             :   }
      44           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
      45           0 :   Maybe<AutoCEReaction> ceReaction;
      46           0 :   if (reactionsStack) {
      47           0 :     ceReaction.emplace(reactionsStack);
      48             :   }
      49           0 :   binding_detail::FastErrorResult rv;
      50           0 :   self->SetWidth(arg0, rv);
      51           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      52           0 :     return false;
      53             :   }
      54           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      55             : 
      56           0 :   return true;
      57             : }
      58             : 
      59             : static const JSJitInfo width_getterinfo = {
      60             :   { (JSJitGetterOp)get_width },
      61             :   { prototypes::id::HTMLVideoElement },
      62             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
      63             :   JSJitInfo::Getter,
      64             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      65             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      66             :   true,  /* isInfallible. False in setters. */
      67             :   false,  /* isMovable.  Not relevant for setters. */
      68             :   false, /* isEliminatable.  Not relevant for setters. */
      69             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      70             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      71             :   false,  /* isTypedMethod.  Only relevant for methods. */
      72             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      73             : };
      74             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      75             : static_assert(0 < 1, "There is no slot for us");
      76             : static const JSJitInfo width_setterinfo = {
      77             :   { (JSJitGetterOp)set_width },
      78             :   { prototypes::id::HTMLVideoElement },
      79             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
      80             :   JSJitInfo::Setter,
      81             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      82             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
      83             :   false,  /* isInfallible. False in setters. */
      84             :   false,  /* isMovable.  Not relevant for setters. */
      85             :   false, /* isEliminatable.  Not relevant for setters. */
      86             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      87             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      88             :   false,  /* isTypedMethod.  Only relevant for methods. */
      89             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      90             : };
      91             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      92             : static_assert(0 < 1, "There is no slot for us");
      93             : 
      94             : static bool
      95           0 : get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
      96             : {
      97           0 :   uint32_t result(self->Height());
      98           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      99           0 :   args.rval().setNumber(result);
     100           0 :   return true;
     101             : }
     102             : 
     103             : static bool
     104           0 : set_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitSetterCallArgs args)
     105             : {
     106             :   uint32_t arg0;
     107           0 :   if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
     108           0 :     return false;
     109             :   }
     110           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     111           0 :   Maybe<AutoCEReaction> ceReaction;
     112           0 :   if (reactionsStack) {
     113           0 :     ceReaction.emplace(reactionsStack);
     114             :   }
     115           0 :   binding_detail::FastErrorResult rv;
     116           0 :   self->SetHeight(arg0, rv);
     117           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     118           0 :     return false;
     119             :   }
     120           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     121             : 
     122           0 :   return true;
     123             : }
     124             : 
     125             : static const JSJitInfo height_getterinfo = {
     126             :   { (JSJitGetterOp)get_height },
     127             :   { prototypes::id::HTMLVideoElement },
     128             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     129             :   JSJitInfo::Getter,
     130             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     131             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     132             :   true,  /* isInfallible. False in setters. */
     133             :   false,  /* isMovable.  Not relevant for setters. */
     134             :   false, /* isEliminatable.  Not relevant for setters. */
     135             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     136             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     137             :   false,  /* isTypedMethod.  Only relevant for methods. */
     138             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     139             : };
     140             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     141             : static_assert(0 < 1, "There is no slot for us");
     142             : static const JSJitInfo height_setterinfo = {
     143             :   { (JSJitGetterOp)set_height },
     144             :   { prototypes::id::HTMLVideoElement },
     145             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     146             :   JSJitInfo::Setter,
     147             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     148             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     149             :   false,  /* isInfallible. False in setters. */
     150             :   false,  /* isMovable.  Not relevant for setters. */
     151             :   false, /* isEliminatable.  Not relevant for setters. */
     152             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     153             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     154             :   false,  /* isTypedMethod.  Only relevant for methods. */
     155             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     156             : };
     157             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     158             : static_assert(0 < 1, "There is no slot for us");
     159             : 
     160             : static bool
     161           0 : get_videoWidth(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     162             : {
     163           0 :   uint32_t result(self->VideoWidth());
     164           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     165           0 :   args.rval().setNumber(result);
     166           0 :   return true;
     167             : }
     168             : 
     169             : static const JSJitInfo videoWidth_getterinfo = {
     170             :   { (JSJitGetterOp)get_videoWidth },
     171             :   { prototypes::id::HTMLVideoElement },
     172             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     173             :   JSJitInfo::Getter,
     174             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     175             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     176             :   true,  /* isInfallible. False in setters. */
     177             :   false,  /* isMovable.  Not relevant for setters. */
     178             :   false, /* isEliminatable.  Not relevant for setters. */
     179             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     180             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     181             :   false,  /* isTypedMethod.  Only relevant for methods. */
     182             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     183             : };
     184             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     185             : static_assert(0 < 1, "There is no slot for us");
     186             : 
     187             : static bool
     188           0 : get_videoHeight(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     189             : {
     190           0 :   uint32_t result(self->VideoHeight());
     191           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     192           0 :   args.rval().setNumber(result);
     193           0 :   return true;
     194             : }
     195             : 
     196             : static const JSJitInfo videoHeight_getterinfo = {
     197             :   { (JSJitGetterOp)get_videoHeight },
     198             :   { prototypes::id::HTMLVideoElement },
     199             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     200             :   JSJitInfo::Getter,
     201             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     202             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     203             :   true,  /* isInfallible. False in setters. */
     204             :   false,  /* isMovable.  Not relevant for setters. */
     205             :   false, /* isEliminatable.  Not relevant for setters. */
     206             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     207             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     208             :   false,  /* isTypedMethod.  Only relevant for methods. */
     209             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     210             : };
     211             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     212             : static_assert(0 < 1, "There is no slot for us");
     213             : 
     214             : static bool
     215           0 : get_poster(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     216             : {
     217           0 :   DOMString result;
     218           0 :   self->GetPoster(result);
     219           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     220           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     221           0 :     return false;
     222             :   }
     223           0 :   return true;
     224             : }
     225             : 
     226             : static bool
     227           0 : set_poster(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitSetterCallArgs args)
     228             : {
     229           0 :   binding_detail::FakeString arg0;
     230           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     231           0 :     return false;
     232             :   }
     233           0 :   CustomElementReactionsStack* reactionsStack = GetCustomElementReactionsStack(obj);
     234           0 :   Maybe<AutoCEReaction> ceReaction;
     235           0 :   if (reactionsStack) {
     236           0 :     ceReaction.emplace(reactionsStack);
     237             :   }
     238           0 :   binding_detail::FastErrorResult rv;
     239           0 :   self->SetPoster(NonNullHelper(Constify(arg0)), rv);
     240           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     241           0 :     return false;
     242             :   }
     243           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     244             : 
     245           0 :   return true;
     246             : }
     247             : 
     248             : static const JSJitInfo poster_getterinfo = {
     249             :   { (JSJitGetterOp)get_poster },
     250             :   { prototypes::id::HTMLVideoElement },
     251             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     252             :   JSJitInfo::Getter,
     253             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     254             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     255             :   false,  /* isInfallible. False in setters. */
     256             :   false,  /* isMovable.  Not relevant for setters. */
     257             :   false, /* isEliminatable.  Not relevant for setters. */
     258             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     259             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     260             :   false,  /* isTypedMethod.  Only relevant for methods. */
     261             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     262             : };
     263             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     264             : static_assert(0 < 1, "There is no slot for us");
     265             : static const JSJitInfo poster_setterinfo = {
     266             :   { (JSJitGetterOp)set_poster },
     267             :   { prototypes::id::HTMLVideoElement },
     268             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     269             :   JSJitInfo::Setter,
     270             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     271             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     272             :   false,  /* isInfallible. False in setters. */
     273             :   false,  /* isMovable.  Not relevant for setters. */
     274             :   false, /* isEliminatable.  Not relevant for setters. */
     275             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     276             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     277             :   false,  /* isTypedMethod.  Only relevant for methods. */
     278             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     279             : };
     280             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     281             : static_assert(0 < 1, "There is no slot for us");
     282             : 
     283             : static bool
     284           0 : get_mozParsedFrames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     285             : {
     286           0 :   uint32_t result(self->MozParsedFrames());
     287           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     288           0 :   args.rval().setNumber(result);
     289           0 :   return true;
     290             : }
     291             : 
     292             : static const JSJitInfo mozParsedFrames_getterinfo = {
     293             :   { (JSJitGetterOp)get_mozParsedFrames },
     294             :   { prototypes::id::HTMLVideoElement },
     295             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     296             :   JSJitInfo::Getter,
     297             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     298             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     299             :   true,  /* isInfallible. False in setters. */
     300             :   false,  /* isMovable.  Not relevant for setters. */
     301             :   false, /* isEliminatable.  Not relevant for setters. */
     302             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     303             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     304             :   false,  /* isTypedMethod.  Only relevant for methods. */
     305             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     306             : };
     307             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     308             : static_assert(0 < 1, "There is no slot for us");
     309             : 
     310             : static bool
     311           0 : get_mozDecodedFrames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     312             : {
     313           0 :   uint32_t result(self->MozDecodedFrames());
     314           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     315           0 :   args.rval().setNumber(result);
     316           0 :   return true;
     317             : }
     318             : 
     319             : static const JSJitInfo mozDecodedFrames_getterinfo = {
     320             :   { (JSJitGetterOp)get_mozDecodedFrames },
     321             :   { prototypes::id::HTMLVideoElement },
     322             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     323             :   JSJitInfo::Getter,
     324             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     325             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     326             :   true,  /* isInfallible. False in setters. */
     327             :   false,  /* isMovable.  Not relevant for setters. */
     328             :   false, /* isEliminatable.  Not relevant for setters. */
     329             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     330             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     331             :   false,  /* isTypedMethod.  Only relevant for methods. */
     332             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     333             : };
     334             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     335             : static_assert(0 < 1, "There is no slot for us");
     336             : 
     337             : static bool
     338           0 : get_mozPresentedFrames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     339             : {
     340           0 :   uint32_t result(self->MozPresentedFrames());
     341           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     342           0 :   args.rval().setNumber(result);
     343           0 :   return true;
     344             : }
     345             : 
     346             : static const JSJitInfo mozPresentedFrames_getterinfo = {
     347             :   { (JSJitGetterOp)get_mozPresentedFrames },
     348             :   { prototypes::id::HTMLVideoElement },
     349             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     350             :   JSJitInfo::Getter,
     351             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     352             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     353             :   true,  /* isInfallible. False in setters. */
     354             :   false,  /* isMovable.  Not relevant for setters. */
     355             :   false, /* isEliminatable.  Not relevant for setters. */
     356             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     357             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     358             :   false,  /* isTypedMethod.  Only relevant for methods. */
     359             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     360             : };
     361             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     362             : static_assert(0 < 1, "There is no slot for us");
     363             : 
     364             : static bool
     365           0 : get_mozPaintedFrames(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     366             : {
     367           0 :   uint32_t result(self->MozPaintedFrames());
     368           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     369           0 :   args.rval().setNumber(result);
     370           0 :   return true;
     371             : }
     372             : 
     373             : static const JSJitInfo mozPaintedFrames_getterinfo = {
     374             :   { (JSJitGetterOp)get_mozPaintedFrames },
     375             :   { prototypes::id::HTMLVideoElement },
     376             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     377             :   JSJitInfo::Getter,
     378             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     379             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     380             :   true,  /* isInfallible. False in setters. */
     381             :   false,  /* isMovable.  Not relevant for setters. */
     382             :   false, /* isEliminatable.  Not relevant for setters. */
     383             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     384             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     385             :   false,  /* isTypedMethod.  Only relevant for methods. */
     386             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     387             : };
     388             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     389             : static_assert(0 < 1, "There is no slot for us");
     390             : 
     391             : static bool
     392           0 : get_mozFrameDelay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     393             : {
     394           0 :   double result(self->MozFrameDelay());
     395           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     396           0 :   args.rval().set(JS_NumberValue(double(result)));
     397           0 :   return true;
     398             : }
     399             : 
     400             : static const JSJitInfo mozFrameDelay_getterinfo = {
     401             :   { (JSJitGetterOp)get_mozFrameDelay },
     402             :   { prototypes::id::HTMLVideoElement },
     403             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     404             :   JSJitInfo::Getter,
     405             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     406             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     407             :   true,  /* isInfallible. False in setters. */
     408             :   false,  /* isMovable.  Not relevant for setters. */
     409             :   false, /* isEliminatable.  Not relevant for setters. */
     410             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     411             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     412             :   false,  /* isTypedMethod.  Only relevant for methods. */
     413             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     414             : };
     415             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     416             : static_assert(0 < 1, "There is no slot for us");
     417             : 
     418             : static bool
     419           0 : get_mozHasAudio(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     420             : {
     421           0 :   bool result(self->MozHasAudio());
     422           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     423           0 :   args.rval().setBoolean(result);
     424           0 :   return true;
     425             : }
     426             : 
     427             : static const JSJitInfo mozHasAudio_getterinfo = {
     428             :   { (JSJitGetterOp)get_mozHasAudio },
     429             :   { prototypes::id::HTMLVideoElement },
     430             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     431             :   JSJitInfo::Getter,
     432             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     433             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     434             :   true,  /* isInfallible. False in setters. */
     435             :   false,  /* isMovable.  Not relevant for setters. */
     436             :   false, /* isEliminatable.  Not relevant for setters. */
     437             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     438             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     439             :   false,  /* isTypedMethod.  Only relevant for methods. */
     440             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     441             : };
     442             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     443             : static_assert(0 < 1, "There is no slot for us");
     444             : 
     445             : static bool
     446           0 : get_mozUseScreenWakeLock(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitGetterCallArgs args)
     447             : {
     448           0 :   bool result(self->MozUseScreenWakeLock());
     449           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     450           0 :   args.rval().setBoolean(result);
     451           0 :   return true;
     452             : }
     453             : 
     454             : static bool
     455           0 : set_mozUseScreenWakeLock(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, JSJitSetterCallArgs args)
     456             : {
     457             :   bool arg0;
     458           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
     459           0 :     return false;
     460             :   }
     461           0 :   self->SetMozUseScreenWakeLock(arg0);
     462           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     463             : 
     464           0 :   return true;
     465             : }
     466             : 
     467             : static const JSJitInfo mozUseScreenWakeLock_getterinfo = {
     468             :   { (JSJitGetterOp)get_mozUseScreenWakeLock },
     469             :   { prototypes::id::HTMLVideoElement },
     470             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     471             :   JSJitInfo::Getter,
     472             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     473             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     474             :   true,  /* isInfallible. False in setters. */
     475             :   false,  /* isMovable.  Not relevant for setters. */
     476             :   false, /* isEliminatable.  Not relevant for setters. */
     477             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     478             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     479             :   false,  /* isTypedMethod.  Only relevant for methods. */
     480             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     481             : };
     482             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     483             : static_assert(0 < 1, "There is no slot for us");
     484             : static const JSJitInfo mozUseScreenWakeLock_setterinfo = {
     485             :   { (JSJitGetterOp)set_mozUseScreenWakeLock },
     486             :   { prototypes::id::HTMLVideoElement },
     487             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     488             :   JSJitInfo::Setter,
     489             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     490             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     491             :   false,  /* isInfallible. False in setters. */
     492             :   false,  /* isMovable.  Not relevant for setters. */
     493             :   false, /* isEliminatable.  Not relevant for setters. */
     494             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     495             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     496             :   false,  /* isTypedMethod.  Only relevant for methods. */
     497             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     498             : };
     499             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     500             : static_assert(0 < 1, "There is no slot for us");
     501             : 
     502             : static bool
     503           0 : getVideoPlaybackQuality(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLVideoElement* self, const JSJitMethodCallArgs& args)
     504             : {
     505           0 :   auto result(StrongOrRawPtr<mozilla::dom::VideoPlaybackQuality>(self->GetVideoPlaybackQuality()));
     506           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     507             :   static_assert(!IsPointer<decltype(result)>::value,
     508             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     509           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     510           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     511           0 :     return false;
     512             :   }
     513           0 :   return true;
     514             : }
     515             : 
     516             : static const JSJitInfo getVideoPlaybackQuality_methodinfo = {
     517             :   { (JSJitGetterOp)getVideoPlaybackQuality },
     518             :   { prototypes::id::HTMLVideoElement },
     519             :   { PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth },
     520             :   JSJitInfo::Method,
     521             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     522             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     523             :   false,  /* isInfallible. False in setters. */
     524             :   false,  /* isMovable.  Not relevant for setters. */
     525             :   false, /* isEliminatable.  Not relevant for setters. */
     526             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     527             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     528             :   false,  /* isTypedMethod.  Only relevant for methods. */
     529             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     530             : };
     531             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     532             : static_assert(0 < 1, "There is no slot for us");
     533             : 
     534             : static bool
     535           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     536             : {
     537           0 :   mozilla::dom::HTMLVideoElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLVideoElement>(obj);
     538             :   // We don't want to preserve if we don't have a wrapper, and we
     539             :   // obviously can't preserve if we're not initialized.
     540           0 :   if (self && self->GetWrapperPreserveColor()) {
     541           0 :     PreserveWrapper(self);
     542             :   }
     543           0 :   return true;
     544             : }
     545             : 
     546             : static void
     547           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     548             : {
     549           0 :   mozilla::dom::HTMLVideoElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLVideoElement>(obj);
     550           0 :   if (self) {
     551           0 :     ClearWrapper(self, self, obj);
     552           0 :     AddForDeferredFinalization<mozilla::dom::HTMLVideoElement>(self);
     553             :   }
     554           0 : }
     555             : 
     556             : static void
     557           0 : _objectMoved(JSObject* obj, const JSObject* old)
     558             : {
     559           0 :   mozilla::dom::HTMLVideoElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLVideoElement>(obj);
     560           0 :   if (self) {
     561           0 :     UpdateWrapper(self, self, obj, old);
     562             :   }
     563           0 : }
     564             : 
     565             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     566             : #if defined(__clang__)
     567             : #pragma clang diagnostic push
     568             : #pragma clang diagnostic ignored "-Wmissing-braces"
     569             : #endif
     570             : static const JSFunctionSpec sMethods_specs[] = {
     571             :   JS_FNSPEC("getVideoPlaybackQuality", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getVideoPlaybackQuality_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     572             :   JS_FS_END
     573             : };
     574             : #if defined(__clang__)
     575             : #pragma clang diagnostic pop
     576             : #endif
     577             : 
     578             : static PrefableDisablers sMethods_disablers0 = {
     579             :   true, false, 0, &mozilla::dom::MediaSource::Enabled
     580             : };
     581             : 
     582             : // Can't be const because the pref-enabled boolean needs to be writable
     583             : static Prefable<const JSFunctionSpec> sMethods[] = {
     584             :   { &sMethods_disablers0, &sMethods_specs[0] },
     585             :   { nullptr, nullptr }
     586             : };
     587             : 
     588             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     589             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     590             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     591             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     592             : 
     593             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     594             : #if defined(__clang__)
     595             : #pragma clang diagnostic push
     596             : #pragma clang diagnostic ignored "-Wmissing-braces"
     597             : #endif
     598             : static const JSPropertySpec sAttributes_specs[] = {
     599             :   { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, GenericBindingSetter, &width_setterinfo },
     600             :   { "height", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &height_getterinfo, GenericBindingSetter, &height_setterinfo },
     601             :   { "videoWidth", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &videoWidth_getterinfo, nullptr, nullptr },
     602             :   { "videoHeight", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &videoHeight_getterinfo, nullptr, nullptr },
     603             :   { "poster", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &poster_getterinfo, GenericBindingSetter, &poster_setterinfo },
     604             :   { "mozParsedFrames", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozParsedFrames_getterinfo, nullptr, nullptr },
     605             :   { "mozDecodedFrames", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozDecodedFrames_getterinfo, nullptr, nullptr },
     606             :   { "mozPresentedFrames", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozPresentedFrames_getterinfo, nullptr, nullptr },
     607             :   { "mozPaintedFrames", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozPaintedFrames_getterinfo, nullptr, nullptr },
     608             :   { "mozFrameDelay", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozFrameDelay_getterinfo, nullptr, nullptr },
     609             :   { "mozHasAudio", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozHasAudio_getterinfo, nullptr, nullptr },
     610             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
     611             :   { "mozUseScreenWakeLock", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &mozUseScreenWakeLock_getterinfo, GenericBindingSetter, &mozUseScreenWakeLock_setterinfo },
     612             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     613             : };
     614             : #if defined(__clang__)
     615             : #pragma clang diagnostic pop
     616             : #endif
     617             : 
     618             : static PrefableDisablers sAttributes_disablers12 = {
     619             :   true, false, 0, &Navigator::HasWakeLockSupport
     620             : };
     621             : 
     622             : // Can't be const because the pref-enabled boolean needs to be writable
     623             : static Prefable<const JSPropertySpec> sAttributes[] = {
     624             :   { nullptr, &sAttributes_specs[0] },
     625             :   { &sAttributes_disablers12, &sAttributes_specs[12] },
     626             :   { nullptr, nullptr }
     627             : };
     628             : 
     629             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     630             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     631             : static_assert(11 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     632             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     633             : 
     634             : 
     635             : static uint16_t sNativeProperties_sortedPropertyIndices[13];
     636             : static PropertyInfo sNativeProperties_propertyInfos[13];
     637             : 
     638             : static const NativePropertiesN<2> sNativeProperties = {
     639             :   false, 0,
     640             :   false, 0,
     641             :   true,  0 /* sMethods */,
     642             :   true,  1 /* sAttributes */,
     643             :   false, 0,
     644             :   false, 0,
     645             :   false, 0,
     646             :   -1,
     647             :   13,
     648             :   sNativeProperties_sortedPropertyIndices,
     649             :   {
     650             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     651             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
     652             :   }
     653             : };
     654             : static_assert(13 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     655             :     "We have a property info count that is oversized");
     656             : 
     657             : static bool
     658           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     659             : {
     660           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     661           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     662           0 :   if (!args.isConstructing()) {
     663             :     // XXXbz wish I could get the name from the callee instead of
     664             :     // Adding more relocations
     665           0 :     return ThrowConstructorWithoutNew(cx, "HTMLVideoElement");
     666             :   }
     667             : 
     668           0 :   GlobalObject global(cx, obj);
     669           0 :   if (global.Failed()) {
     670           0 :     return false;
     671             :   }
     672             : 
     673             :   // The newTarget might be a cross-compartment wrapper. Get the underlying object
     674             :   // so we can do the spec's object-identity checks.
     675           0 :   JS::Rooted<JSObject*> newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject()));
     676           0 :   if (!newTarget) {
     677           0 :     return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     678             :   }
     679             : 
     680             :   // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     681             :   // Enter the compartment of our underlying newTarget object, so we end
     682             :   // up comparing to the constructor object for our interface from that global.
     683             :   {
     684           0 :     JSAutoCompartment ac(cx, newTarget);
     685           0 :     JS::Handle<JSObject*> constructor(GetConstructorObjectHandle(cx));
     686           0 :     if (!constructor) {
     687           0 :       return false;
     688             :     }
     689           0 :     if (newTarget == constructor) {
     690           0 :       return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR);
     691             :     }
     692             :   }
     693             : 
     694           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     695           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     696           0 :     return false;
     697             :   }
     698           0 :   if (!desiredProto) {
     699             :     // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor.
     700             :     // This fallback behavior is designed to match analogous behavior for the
     701             :     // JavaScript built-ins. So we enter the compartment of our underlying
     702             :     // newTarget object and fall back to the prototype object from that global.
     703             :     // XXX The spec says to use GetFunctionRealm(), which is not actually
     704             :     // the same thing as what we have here (e.g. in the case of scripted callable proxies
     705             :     // whose target is not same-compartment with the proxy, or bound functions, etc).
     706             :     // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658
     707             :     {
     708           0 :       JSAutoCompartment ac(cx, newTarget);
     709           0 :       desiredProto = GetProtoObjectHandle(cx);
     710           0 :       if (!desiredProto) {
     711           0 :           return false;
     712             :       }
     713             :     }
     714             : 
     715             :     // desiredProto is in the compartment of the underlying newTarget object.
     716             :     // Wrap it into the context compartment.
     717           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     718           0 :       return false;
     719             :     }
     720             :   }
     721             : 
     722           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     723           0 :   Maybe<JSAutoCompartment> ac;
     724           0 :   if (objIsXray) {
     725           0 :     obj = js::CheckedUnwrap(obj);
     726           0 :     if (!obj) {
     727           0 :       return false;
     728             :     }
     729           0 :     ac.emplace(cx, obj);
     730           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     731           0 :       return false;
     732             :     }
     733             :   }
     734           0 :   binding_detail::FastErrorResult rv;
     735           0 :   auto result(StrongOrRawPtr<mozilla::dom::HTMLVideoElement>(CreateHTMLElement(global, args, rv)));
     736           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     737           0 :     return false;
     738             :   }
     739           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     740             :   static_assert(!IsPointer<decltype(result)>::value,
     741             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     742           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     743           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     744           0 :     return false;
     745             :   }
     746           0 :   return true;
     747             : }
     748             : 
     749             : static const js::ClassOps sInterfaceObjectClassOps = {
     750             :     nullptr,               /* addProperty */
     751             :     nullptr,               /* delProperty */
     752             :     nullptr,               /* getProperty */
     753             :     nullptr,               /* setProperty */
     754             :     nullptr,               /* enumerate */
     755             :     nullptr,               /* newEnumerate */
     756             :     nullptr,               /* resolve */
     757             :     nullptr,               /* mayResolve */
     758             :     nullptr,               /* finalize */
     759             :     _constructor, /* call */
     760             :     nullptr,               /* hasInstance */
     761             :     _constructor, /* construct */
     762             :     nullptr,               /* trace */
     763             : };
     764             : 
     765             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     766             :   {
     767             :     "Function",
     768             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     769             :     &sInterfaceObjectClassOps,
     770             :     JS_NULL_CLASS_SPEC,
     771             :     JS_NULL_CLASS_EXT,
     772             :     &sInterfaceObjectClassObjectOps
     773             :   },
     774             :   eInterface,
     775             :   true,
     776             :   prototypes::id::HTMLVideoElement,
     777             :   PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth,
     778             :   sNativePropertyHooks,
     779             :   "function HTMLVideoElement() {\n    [native code]\n}",
     780             :   HTMLMediaElementBinding::GetConstructorObject
     781             : };
     782             : 
     783             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     784             :   {
     785             :     "HTMLVideoElementPrototype",
     786             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     787             :     JS_NULL_CLASS_OPS,
     788             :     JS_NULL_CLASS_SPEC,
     789             :     JS_NULL_CLASS_EXT,
     790             :     JS_NULL_OBJECT_OPS
     791             :   },
     792             :   eInterfacePrototype,
     793             :   false,
     794             :   prototypes::id::HTMLVideoElement,
     795             :   PrototypeTraits<prototypes::id::HTMLVideoElement>::Depth,
     796             :   sNativePropertyHooks,
     797             :   "[object HTMLVideoElementPrototype]",
     798             :   HTMLMediaElementBinding::GetProtoObject
     799             : };
     800             : 
     801             : JSObject*
     802           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     803             : {
     804           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     805             : }
     806             : 
     807             : static const js::ClassOps sClassOps = {
     808             :   _addProperty, /* addProperty */
     809             :   nullptr,               /* delProperty */
     810             :   nullptr,               /* getProperty */
     811             :   nullptr,               /* setProperty */
     812             :   nullptr,               /* enumerate */
     813             :   nullptr, /* newEnumerate */
     814             :   nullptr, /* resolve */
     815             :   nullptr, /* mayResolve */
     816             :   _finalize, /* finalize */
     817             :   nullptr, /* call */
     818             :   nullptr,               /* hasInstance */
     819             :   nullptr,               /* construct */
     820             :   nullptr, /* trace */
     821             : };
     822             : 
     823             : static const js::ClassExtension sClassExtension = {
     824             :   nullptr, /* weakmapKeyDelegateOp */
     825             :   _objectMoved /* objectMovedOp */
     826             : };
     827             : 
     828             : static const DOMJSClass sClass = {
     829             :   { "HTMLVideoElement",
     830             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     831             :     &sClassOps,
     832             :     JS_NULL_CLASS_SPEC,
     833             :     &sClassExtension,
     834             :     JS_NULL_OBJECT_OPS
     835             :   },
     836             :   { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLMediaElement, prototypes::id::HTMLVideoElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     837             :   IsBaseOf<nsISupports, mozilla::dom::HTMLVideoElement >::value,
     838             :   sNativePropertyHooks,
     839             :   FindAssociatedGlobalForNative<mozilla::dom::HTMLVideoElement>::Get,
     840             :   GetProtoObjectHandle,
     841             :   GetCCParticipant<mozilla::dom::HTMLVideoElement>::Get()
     842             : };
     843             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     844             :               "Must have the right minimal number of reserved slots.");
     845             : static_assert(1 >= 1,
     846             :               "Must have enough reserved slots.");
     847             : 
     848             : const JSClass*
     849           0 : GetJSClass()
     850             : {
     851           0 :   return sClass.ToJSClass();
     852             : }
     853             : 
     854             : bool
     855           0 : Wrap(JSContext* aCx, mozilla::dom::HTMLVideoElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     856             : {
     857             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLVideoElement*>(aObject) ==
     858             :              reinterpret_cast<mozilla::dom::HTMLVideoElement*>(aObject),
     859             :              "Multiple inheritance for mozilla::dom::HTMLVideoElement is broken.");
     860             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLMediaElement*>(aObject) ==
     861             :              reinterpret_cast<mozilla::dom::HTMLMediaElement*>(aObject),
     862             :              "Multiple inheritance for mozilla::dom::HTMLMediaElement is broken.");
     863             :   MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
     864             :              reinterpret_cast<nsGenericHTMLElement*>(aObject),
     865             :              "Multiple inheritance for nsGenericHTMLElement is broken.");
     866             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     867             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     868             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     869             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     870             :              reinterpret_cast<nsINode*>(aObject),
     871             :              "Multiple inheritance for nsINode is broken.");
     872             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     873             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     874             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     875           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     876           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     877           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     878             :              "You should probably not be using Wrap() directly; use "
     879             :              "GetOrCreateDOMReflector instead");
     880             : 
     881           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     882             :              "nsISupports must be on our primary inheritance chain");
     883             : 
     884           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     885           0 :   if (!global) {
     886           0 :     return false;
     887             :   }
     888           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     889           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     890             : 
     891             :   // That might have ended up wrapping us already, due to the wonders
     892             :   // of XBL.  Check for that, and bail out as needed.
     893           0 :   aReflector.set(aCache->GetWrapper());
     894           0 :   if (aReflector) {
     895             : #ifdef DEBUG
     896           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     897             : #endif // DEBUG
     898           0 :     return true;
     899             :   }
     900             : 
     901           0 :   JSAutoCompartment ac(aCx, global);
     902           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     903           0 :   if (!canonicalProto) {
     904           0 :     return false;
     905             :   }
     906           0 :   JS::Rooted<JSObject*> proto(aCx);
     907           0 :   if (aGivenProto) {
     908           0 :     proto = aGivenProto;
     909             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     910             :     // coming in, we changed compartments to that of "parent" so may need
     911             :     // to wrap the proto here.
     912           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     913           0 :       if (!JS_WrapObject(aCx, &proto)) {
     914           0 :         return false;
     915             :       }
     916             :     }
     917             :   } else {
     918           0 :     proto = canonicalProto;
     919             :   }
     920             : 
     921           0 :   BindingJSObjectCreator<mozilla::dom::HTMLVideoElement> creator(aCx);
     922           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     923           0 :   if (!aReflector) {
     924           0 :     return false;
     925             :   }
     926             : 
     927           0 :   aCache->SetWrapper(aReflector);
     928           0 :   creator.InitializationSucceeded();
     929             : 
     930           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     931             :              aCache->GetWrapperPreserveColor() == aReflector);
     932             :   // If proto != canonicalProto, we have to preserve our wrapper;
     933             :   // otherwise we won't be able to properly recreate it later, since
     934             :   // we won't know what proto to use.  Note that we don't check
     935             :   // aGivenProto here, since it's entirely possible (and even
     936             :   // somewhat common) to have a non-null aGivenProto which is the
     937             :   // same as canonicalProto.
     938           0 :   if (proto != canonicalProto) {
     939           0 :     PreserveWrapper(aObject);
     940             :   }
     941             : 
     942           0 :   return true;
     943             : }
     944             : 
     945             : const NativePropertyHooks sNativePropertyHooks[] = { {
     946             :   nullptr,
     947             :   nullptr,
     948             :   nullptr,
     949             :   { sNativeProperties.Upcast(), nullptr },
     950             :   prototypes::id::HTMLVideoElement,
     951             :   constructors::id::HTMLVideoElement,
     952             :   HTMLMediaElementBinding::sNativePropertyHooks,
     953             :   &DefaultXrayExpandoObjectClass
     954             : } };
     955             : 
     956             : void
     957           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     958             : {
     959           0 :   JS::Handle<JSObject*> parentProto(HTMLMediaElementBinding::GetProtoObjectHandle(aCx));
     960           0 :   if (!parentProto) {
     961           0 :     return;
     962             :   }
     963             : 
     964           0 :   JS::Handle<JSObject*> constructorProto(HTMLMediaElementBinding::GetConstructorObjectHandle(aCx));
     965           0 :   if (!constructorProto) {
     966           0 :     return;
     967             :   }
     968             : 
     969             :   static bool sIdsInited = false;
     970           0 :   if (!sIdsInited && NS_IsMainThread()) {
     971           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     972           0 :       return;
     973             :     }
     974           0 :     sIdsInited = true;
     975             :   }
     976             : 
     977             :   static bool sPrefCachesInited = false;
     978           0 :   if (!sPrefCachesInited && NS_IsMainThread()) {
     979           0 :     sPrefCachesInited = true;
     980           0 :     Preferences::AddBoolVarCache(&sAttributes[1].disablers->enabled, "dom.wakelock.enabled");
     981             :   }
     982             : 
     983           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLVideoElement);
     984           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLVideoElement);
     985           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     986             :                               &sPrototypeClass.mBase, protoCache,
     987             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     988             :                               interfaceCache,
     989             :                               sNativeProperties.Upcast(),
     990             :                               nullptr,
     991             :                               "HTMLVideoElement", aDefineOnGlobal,
     992             :                               nullptr,
     993           0 :                               false);
     994             : }
     995             : 
     996             : JS::Handle<JSObject*>
     997           0 : GetProtoObjectHandle(JSContext* aCx)
     998             : {
     999             :   /* Get the interface prototype object for this class.  This will create the
    1000             :      object as needed. */
    1001           0 :   bool aDefineOnGlobal = true;
    1002             : 
    1003             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1004           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1005           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1006           0 :     return nullptr;
    1007             :   }
    1008             : 
    1009             :   /* Check to see whether the interface objects are already installed */
    1010           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1011           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLVideoElement)) {
    1012           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1013           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1014             :   }
    1015             : 
    1016             :   /*
    1017             :    * The object might _still_ be null, but that's OK.
    1018             :    *
    1019             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1020             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1021             :    * changed after they have been set.
    1022             :    *
    1023             :    * Calling address() avoids the read read barrier that does gray
    1024             :    * unmarking, but it's not possible for the object to be gray here.
    1025             :    */
    1026             : 
    1027           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLVideoElement);
    1028           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1029           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1030             : }
    1031             : 
    1032             : JS::Handle<JSObject*>
    1033           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1034             : {
    1035             :   /* Get the interface object for this class.  This will create the object as
    1036             :      needed. */
    1037             : 
    1038             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1039           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1040           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1041           0 :     return nullptr;
    1042             :   }
    1043             : 
    1044             :   /* Check to see whether the interface objects are already installed */
    1045           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1046           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLVideoElement)) {
    1047           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1048           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1049             :   }
    1050             : 
    1051             :   /*
    1052             :    * The object might _still_ be null, but that's OK.
    1053             :    *
    1054             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1055             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1056             :    * changed after they have been set.
    1057             :    *
    1058             :    * Calling address() avoids the read read barrier that does gray
    1059             :    * unmarking, but it's not possible for the object to be gray here.
    1060             :    */
    1061             : 
    1062           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLVideoElement);
    1063           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1064           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1065             : }
    1066             : 
    1067             : JSObject*
    1068           0 : GetConstructorObject(JSContext* aCx)
    1069             : {
    1070           0 :   return GetConstructorObjectHandle(aCx);
    1071             : }
    1072             : 
    1073             : } // namespace HTMLVideoElementBinding
    1074             : 
    1075             : 
    1076             : 
    1077             : } // namespace dom
    1078             : } // namespace mozilla

Generated by: LCOV version 1.13