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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM PresentationRequest.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "PresentationRequestBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/Preferences.h"
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/Nullable.h"
      13             : #include "mozilla/dom/PresentationRequest.h"
      14             : #include "mozilla/dom/Promise.h"
      15             : #include "mozilla/dom/ToJSValue.h"
      16             : #include "mozilla/dom/XrayExpandoClass.h"
      17             : #include "nsContentUtils.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace PresentationRequestBinding {
      23             : 
      24             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      25             :               "Can't inherit from an interface with a different ownership model.");
      26             : 
      27             : static bool
      28           0 : start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
      29             : {
      30           0 :   binding_detail::FastErrorResult rv;
      31           0 :   auto result(StrongOrRawPtr<Promise>(self->Start(rv)));
      32           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      33           0 :     return false;
      34             :   }
      35           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      36           0 :   if (!ToJSValue(cx, result, args.rval())) {
      37           0 :     return false;
      38             :   }
      39           0 :   return true;
      40             : }
      41             : 
      42             : static bool
      43           0 : start_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
      44             : {
      45             :   // Make sure to save the callee before someone maybe messes
      46             :   // with rval().
      47           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
      48           0 :   bool ok = start(cx, obj, self, args);
      49           0 :   if (ok) {
      50           0 :     return true;
      51             :   }
      52           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
      53           0 :                                    args.rval());
      54             : }
      55             : 
      56             : static const JSJitInfo start_methodinfo = {
      57             :   { (JSJitGetterOp)start_promiseWrapper },
      58             :   { prototypes::id::PresentationRequest },
      59             :   { PrototypeTraits<prototypes::id::PresentationRequest>::Depth },
      60             :   JSJitInfo::Method,
      61             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      62             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      63             :   false,  /* isInfallible. False in setters. */
      64             :   false,  /* isMovable.  Not relevant for setters. */
      65             :   false, /* isEliminatable.  Not relevant for setters. */
      66             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      67             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      68             :   false,  /* isTypedMethod.  Only relevant for methods. */
      69             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      70             : };
      71             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      72             : static_assert(0 < 1, "There is no slot for us");
      73             : 
      74             : static bool
      75           0 : reconnect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
      76             : {
      77           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
      78           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PresentationRequest.reconnect");
      79             :   }
      80           0 :   binding_detail::FakeString arg0;
      81           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
      82           0 :     return false;
      83             :   }
      84           0 :   binding_detail::FastErrorResult rv;
      85           0 :   auto result(StrongOrRawPtr<Promise>(self->Reconnect(NonNullHelper(Constify(arg0)), rv)));
      86           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      87           0 :     return false;
      88             :   }
      89           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      90           0 :   if (!ToJSValue(cx, result, args.rval())) {
      91           0 :     return false;
      92             :   }
      93           0 :   return true;
      94             : }
      95             : 
      96             : static bool
      97           0 : reconnect_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
      98             : {
      99             :   // Make sure to save the callee before someone maybe messes
     100             :   // with rval().
     101           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     102           0 :   bool ok = reconnect(cx, obj, self, args);
     103           0 :   if (ok) {
     104           0 :     return true;
     105             :   }
     106           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     107           0 :                                    args.rval());
     108             : }
     109             : 
     110             : static const JSJitInfo reconnect_methodinfo = {
     111             :   { (JSJitGetterOp)reconnect_promiseWrapper },
     112             :   { prototypes::id::PresentationRequest },
     113             :   { PrototypeTraits<prototypes::id::PresentationRequest>::Depth },
     114             :   JSJitInfo::Method,
     115             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     116             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     117             :   false,  /* isInfallible. False in setters. */
     118             :   false,  /* isMovable.  Not relevant for setters. */
     119             :   false, /* isEliminatable.  Not relevant for setters. */
     120             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     121             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     122             :   false,  /* isTypedMethod.  Only relevant for methods. */
     123             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     124             : };
     125             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     126             : static_assert(0 < 1, "There is no slot for us");
     127             : 
     128             : static bool
     129           0 : getAvailability(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
     130             : {
     131           0 :   binding_detail::FastErrorResult rv;
     132           0 :   auto result(StrongOrRawPtr<Promise>(self->GetAvailability(rv)));
     133           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     134           0 :     return false;
     135             :   }
     136           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     137           0 :   if (!ToJSValue(cx, result, args.rval())) {
     138           0 :     return false;
     139             :   }
     140           0 :   return true;
     141             : }
     142             : 
     143             : static bool
     144           0 : getAvailability_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
     145             : {
     146             :   // Make sure to save the callee before someone maybe messes
     147             :   // with rval().
     148           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     149           0 :   bool ok = getAvailability(cx, obj, self, args);
     150           0 :   if (ok) {
     151           0 :     return true;
     152             :   }
     153           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     154           0 :                                    args.rval());
     155             : }
     156             : 
     157             : static const JSJitInfo getAvailability_methodinfo = {
     158             :   { (JSJitGetterOp)getAvailability_promiseWrapper },
     159             :   { prototypes::id::PresentationRequest },
     160             :   { PrototypeTraits<prototypes::id::PresentationRequest>::Depth },
     161             :   JSJitInfo::Method,
     162             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     163             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     164             :   false,  /* isInfallible. False in setters. */
     165             :   false,  /* isMovable.  Not relevant for setters. */
     166             :   false, /* isEliminatable.  Not relevant for setters. */
     167             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     168             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     169             :   false,  /* isTypedMethod.  Only relevant for methods. */
     170             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     171             : };
     172             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     173             : static_assert(0 < 1, "There is no slot for us");
     174             : 
     175             : static bool
     176           0 : get_onconnectionavailable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, JSJitGetterCallArgs args)
     177             : {
     178           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnconnectionavailable());
     179           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     180           0 :   if (result) {
     181           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     182           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     183           0 :       return false;
     184             :     }
     185           0 :     return true;
     186             :   } else {
     187           0 :     args.rval().setNull();
     188           0 :     return true;
     189             :   }
     190             : }
     191             : 
     192             : static bool
     193           0 : set_onconnectionavailable(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, JSJitSetterCallArgs args)
     194             : {
     195           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     196           0 :   if (args[0].isObject()) {
     197             :     { // scope for tempRoot
     198           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     199           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     200             :     }
     201             :   } else {
     202           0 :     arg0 = nullptr;
     203             :   }
     204           0 :   self->SetOnconnectionavailable(Constify(arg0));
     205           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     206             : 
     207           0 :   return true;
     208             : }
     209             : 
     210             : static const JSJitInfo onconnectionavailable_getterinfo = {
     211             :   { (JSJitGetterOp)get_onconnectionavailable },
     212             :   { prototypes::id::PresentationRequest },
     213             :   { PrototypeTraits<prototypes::id::PresentationRequest>::Depth },
     214             :   JSJitInfo::Getter,
     215             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     216             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     217             :   false,  /* isInfallible. False in setters. */
     218             :   false,  /* isMovable.  Not relevant for setters. */
     219             :   false, /* isEliminatable.  Not relevant for setters. */
     220             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     221             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     222             :   false,  /* isTypedMethod.  Only relevant for methods. */
     223             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     224             : };
     225             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     226             : static_assert(0 < 1, "There is no slot for us");
     227             : static const JSJitInfo onconnectionavailable_setterinfo = {
     228             :   { (JSJitGetterOp)set_onconnectionavailable },
     229             :   { prototypes::id::PresentationRequest },
     230             :   { PrototypeTraits<prototypes::id::PresentationRequest>::Depth },
     231             :   JSJitInfo::Setter,
     232             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     233             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     234             :   false,  /* isInfallible. False in setters. */
     235             :   false,  /* isMovable.  Not relevant for setters. */
     236             :   false, /* isEliminatable.  Not relevant for setters. */
     237             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     238             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     239             :   false,  /* isTypedMethod.  Only relevant for methods. */
     240             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     241             : };
     242             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     243             : static_assert(0 < 1, "There is no slot for us");
     244             : 
     245             : static bool
     246           0 : startWithDevice(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
     247             : {
     248           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     249           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PresentationRequest.startWithDevice");
     250             :   }
     251           0 :   binding_detail::FakeString arg0;
     252           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     253           0 :     return false;
     254             :   }
     255           0 :   binding_detail::FastErrorResult rv;
     256           0 :   auto result(StrongOrRawPtr<Promise>(self->StartWithDevice(NonNullHelper(Constify(arg0)), rv)));
     257           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     258           0 :     return false;
     259             :   }
     260           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     261           0 :   if (!ToJSValue(cx, result, args.rval())) {
     262           0 :     return false;
     263             :   }
     264           0 :   return true;
     265             : }
     266             : 
     267             : static bool
     268           0 : startWithDevice_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationRequest* self, const JSJitMethodCallArgs& args)
     269             : {
     270             :   // Make sure to save the callee before someone maybe messes
     271             :   // with rval().
     272           0 :   JS::Rooted<JSObject*> callee(cx, &args.callee());
     273           0 :   bool ok = startWithDevice(cx, obj, self, args);
     274           0 :   if (ok) {
     275           0 :     return true;
     276             :   }
     277           0 :   return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
     278           0 :                                    args.rval());
     279             : }
     280             : 
     281             : static const JSJitInfo startWithDevice_methodinfo = {
     282             :   { (JSJitGetterOp)startWithDevice_promiseWrapper },
     283             :   { prototypes::id::PresentationRequest },
     284             :   { PrototypeTraits<prototypes::id::PresentationRequest>::Depth },
     285             :   JSJitInfo::Method,
     286             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     287             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     288             :   false,  /* isInfallible. False in setters. */
     289             :   false,  /* isMovable.  Not relevant for setters. */
     290             :   false, /* isEliminatable.  Not relevant for setters. */
     291             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     292             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     293             :   false,  /* isTypedMethod.  Only relevant for methods. */
     294             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     295             : };
     296             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     297             : static_assert(0 < 1, "There is no slot for us");
     298             : 
     299             : static bool
     300           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     301             : {
     302           0 :   mozilla::dom::PresentationRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationRequest>(obj);
     303             :   // We don't want to preserve if we don't have a wrapper, and we
     304             :   // obviously can't preserve if we're not initialized.
     305           0 :   if (self && self->GetWrapperPreserveColor()) {
     306           0 :     PreserveWrapper(self);
     307             :   }
     308           0 :   return true;
     309             : }
     310             : 
     311             : static void
     312           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     313             : {
     314           0 :   mozilla::dom::PresentationRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationRequest>(obj);
     315           0 :   if (self) {
     316           0 :     ClearWrapper(self, self, obj);
     317           0 :     AddForDeferredFinalization<mozilla::dom::PresentationRequest>(self);
     318             :   }
     319           0 : }
     320             : 
     321             : static void
     322           0 : _objectMoved(JSObject* obj, const JSObject* old)
     323             : {
     324           0 :   mozilla::dom::PresentationRequest* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationRequest>(obj);
     325           0 :   if (self) {
     326           0 :     UpdateWrapper(self, self, obj, old);
     327             :   }
     328           0 : }
     329             : 
     330             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     331             : #if defined(__clang__)
     332             : #pragma clang diagnostic push
     333             : #pragma clang diagnostic ignored "-Wmissing-braces"
     334             : #endif
     335             : static const JSFunctionSpec sMethods_specs[] = {
     336             :   JS_FNSPEC("start", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&start_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     337             :   JS_FNSPEC("reconnect", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&reconnect_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     338             :   JS_FNSPEC("getAvailability", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAvailability_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     339             :   JS_FS_END
     340             : };
     341             : #if defined(__clang__)
     342             : #pragma clang diagnostic pop
     343             : #endif
     344             : 
     345             : 
     346             : // Can't be const because the pref-enabled boolean needs to be writable
     347             : static Prefable<const JSFunctionSpec> sMethods[] = {
     348             :   { nullptr, &sMethods_specs[0] },
     349             :   { nullptr, nullptr }
     350             : };
     351             : 
     352             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     353             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     354             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     355             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     356             : 
     357             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     358             : #if defined(__clang__)
     359             : #pragma clang diagnostic push
     360             : #pragma clang diagnostic ignored "-Wmissing-braces"
     361             : #endif
     362             : static const JSFunctionSpec sChromeMethods_specs[] = {
     363             :   JS_FNSPEC("startWithDevice", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&startWithDevice_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     364             :   JS_FS_END
     365             : };
     366             : #if defined(__clang__)
     367             : #pragma clang diagnostic pop
     368             : #endif
     369             : 
     370             : 
     371             : // Can't be const because the pref-enabled boolean needs to be writable
     372             : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
     373             :   { nullptr, &sChromeMethods_specs[0] },
     374             :   { nullptr, nullptr }
     375             : };
     376             : 
     377             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     378             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     379             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     380             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     381             : 
     382             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     383             : #if defined(__clang__)
     384             : #pragma clang diagnostic push
     385             : #pragma clang diagnostic ignored "-Wmissing-braces"
     386             : #endif
     387             : static const JSPropertySpec sAttributes_specs[] = {
     388             :   { "onconnectionavailable", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onconnectionavailable_getterinfo, GenericBindingSetter, &onconnectionavailable_setterinfo },
     389             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     390             : };
     391             : #if defined(__clang__)
     392             : #pragma clang diagnostic pop
     393             : #endif
     394             : 
     395             : 
     396             : // Can't be const because the pref-enabled boolean needs to be writable
     397             : static Prefable<const JSPropertySpec> sAttributes[] = {
     398             :   { nullptr, &sAttributes_specs[0] },
     399             :   { nullptr, nullptr }
     400             : };
     401             : 
     402             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     403             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     404             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     405             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     406             : 
     407             : 
     408             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
     409             : static PropertyInfo sNativeProperties_propertyInfos[4];
     410             : 
     411             : static const NativePropertiesN<2> sNativeProperties = {
     412             :   false, 0,
     413             :   false, 0,
     414             :   true,  0 /* sMethods */,
     415             :   true,  1 /* sAttributes */,
     416             :   false, 0,
     417             :   false, 0,
     418             :   false, 0,
     419             :   -1,
     420             :   4,
     421             :   sNativeProperties_sortedPropertyIndices,
     422             :   {
     423             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     424             :     { sAttributes, &sNativeProperties_propertyInfos[3] }
     425             :   }
     426             : };
     427             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     428             :     "We have a property info count that is oversized");
     429             : 
     430             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
     431             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
     432             : 
     433             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
     434             :   false, 0,
     435             :   false, 0,
     436             :   true,  0 /* sChromeMethods */,
     437             :   false, 0,
     438             :   false, 0,
     439             :   false, 0,
     440             :   false, 0,
     441             :   -1,
     442             :   1,
     443             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
     444             :   {
     445             :     { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
     446             :   }
     447             : };
     448             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
     449             :     "We have a property info count that is oversized");
     450             : 
     451             : static bool
     452           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     453             : {
     454           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     455           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     456           0 :   if (!args.isConstructing()) {
     457             :     // XXXbz wish I could get the name from the callee instead of
     458             :     // Adding more relocations
     459           0 :     return ThrowConstructorWithoutNew(cx, "PresentationRequest");
     460             :   }
     461             : 
     462           0 :   GlobalObject global(cx, obj);
     463           0 :   if (global.Failed()) {
     464           0 :     return false;
     465             :   }
     466             : 
     467           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     468           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     469           0 :     return false;
     470             :   }
     471             : 
     472           0 :   unsigned argcount = std::min(args.length(), 1u);
     473           0 :   switch (argcount) {
     474             :     case 1: {
     475           0 :       if (args[0].isObject()) {
     476             :         do {
     477           0 :           binding_detail::AutoSequence<nsString> arg0;
     478           0 :           JS::ForOfIterator iter(cx);
     479           0 :           if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
     480           0 :             return false;
     481             :           }
     482           0 :           if (!iter.valueIsIterable()) {
     483           0 :             break;
     484             :           }
     485           0 :           binding_detail::AutoSequence<nsString> &arr = arg0;
     486           0 :           JS::Rooted<JS::Value> temp(cx);
     487             :           while (true) {
     488             :             bool done;
     489           0 :             if (!iter.next(&temp, &done)) {
     490           0 :               return false;
     491             :             }
     492           0 :             if (done) {
     493           0 :               break;
     494             :             }
     495           0 :             nsString* slotPtr = arr.AppendElement(mozilla::fallible);
     496           0 :             if (!slotPtr) {
     497           0 :               JS_ReportOutOfMemory(cx);
     498           0 :               return false;
     499             :             }
     500           0 :             nsString& slot = *slotPtr;
     501           0 :             if (!ConvertJSValueToString(cx, temp, eStringify, eStringify, slot)) {
     502           0 :               return false;
     503             :             }
     504           0 :           }
     505           0 :           bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     506           0 :           Maybe<JSAutoCompartment> ac;
     507           0 :           if (objIsXray) {
     508           0 :             obj = js::CheckedUnwrap(obj);
     509           0 :             if (!obj) {
     510           0 :               return false;
     511             :             }
     512           0 :             ac.emplace(cx, obj);
     513           0 :             if (!JS_WrapObject(cx, &desiredProto)) {
     514           0 :               return false;
     515             :             }
     516             :           }
     517           0 :           binding_detail::FastErrorResult rv;
     518           0 :           auto result(StrongOrRawPtr<mozilla::dom::PresentationRequest>(mozilla::dom::PresentationRequest::Constructor(global, Constify(arg0), rv)));
     519           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     520           0 :             return false;
     521             :           }
     522           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     523             :           static_assert(!IsPointer<decltype(result)>::value,
     524             :                         "NewObject implies that we need to keep the object alive with a strong reference.");
     525           0 :           if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     526           0 :             MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     527           0 :             return false;
     528             :           }
     529           0 :           return true;
     530             :         } while (0);
     531             :       }
     532           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     533           0 :       binding_detail::FakeString arg0;
     534           0 :       if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     535           0 :         return false;
     536             :       }
     537           0 :       Maybe<JSAutoCompartment> ac;
     538           0 :       if (objIsXray) {
     539           0 :         obj = js::CheckedUnwrap(obj);
     540           0 :         if (!obj) {
     541           0 :           return false;
     542             :         }
     543           0 :         ac.emplace(cx, obj);
     544           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
     545           0 :           return false;
     546             :         }
     547             :       }
     548           0 :       binding_detail::FastErrorResult rv;
     549           0 :       auto result(StrongOrRawPtr<mozilla::dom::PresentationRequest>(mozilla::dom::PresentationRequest::Constructor(global, NonNullHelper(Constify(arg0)), rv)));
     550           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     551           0 :         return false;
     552             :       }
     553           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     554             :       static_assert(!IsPointer<decltype(result)>::value,
     555             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
     556           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     557           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     558           0 :         return false;
     559             :       }
     560           0 :       return true;
     561             :       break;
     562             :     }
     563             :     default: {
     564           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PresentationRequest");
     565             :       break;
     566             :     }
     567             :   }
     568             :   MOZ_CRASH("We have an always-returning default case");
     569             :   return false;
     570             : }
     571             : 
     572             : static const js::ClassOps sInterfaceObjectClassOps = {
     573             :     nullptr,               /* addProperty */
     574             :     nullptr,               /* delProperty */
     575             :     nullptr,               /* getProperty */
     576             :     nullptr,               /* setProperty */
     577             :     nullptr,               /* enumerate */
     578             :     nullptr,               /* newEnumerate */
     579             :     nullptr,               /* resolve */
     580             :     nullptr,               /* mayResolve */
     581             :     nullptr,               /* finalize */
     582             :     _constructor, /* call */
     583             :     nullptr,               /* hasInstance */
     584             :     _constructor, /* construct */
     585             :     nullptr,               /* trace */
     586             : };
     587             : 
     588             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     589             :   {
     590             :     "Function",
     591             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     592             :     &sInterfaceObjectClassOps,
     593             :     JS_NULL_CLASS_SPEC,
     594             :     JS_NULL_CLASS_EXT,
     595             :     &sInterfaceObjectClassObjectOps
     596             :   },
     597             :   eInterface,
     598             :   true,
     599             :   prototypes::id::PresentationRequest,
     600             :   PrototypeTraits<prototypes::id::PresentationRequest>::Depth,
     601             :   sNativePropertyHooks,
     602             :   "function PresentationRequest() {\n    [native code]\n}",
     603             :   EventTargetBinding::GetConstructorObject
     604             : };
     605             : 
     606             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     607             :   {
     608             :     "PresentationRequestPrototype",
     609             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     610             :     JS_NULL_CLASS_OPS,
     611             :     JS_NULL_CLASS_SPEC,
     612             :     JS_NULL_CLASS_EXT,
     613             :     JS_NULL_OBJECT_OPS
     614             :   },
     615             :   eInterfacePrototype,
     616             :   false,
     617             :   prototypes::id::PresentationRequest,
     618             :   PrototypeTraits<prototypes::id::PresentationRequest>::Depth,
     619             :   sNativePropertyHooks,
     620             :   "[object PresentationRequestPrototype]",
     621             :   EventTargetBinding::GetProtoObject
     622             : };
     623             : 
     624             : bool
     625           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     626             : {
     627             :   static bool sPrefValue;
     628             :   static bool sPrefCacheSetUp = false;
     629           0 :   if (!sPrefCacheSetUp) {
     630           0 :     sPrefCacheSetUp = true;
     631           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.presentation.controller.enabled");
     632             :   }
     633             : 
     634           0 :   return sPrefValue;
     635             : }
     636             : 
     637             : JSObject*
     638           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     639             : {
     640           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     641             : }
     642             : 
     643             : static const js::ClassOps sClassOps = {
     644             :   _addProperty, /* addProperty */
     645             :   nullptr,               /* delProperty */
     646             :   nullptr,               /* getProperty */
     647             :   nullptr,               /* setProperty */
     648             :   nullptr,               /* enumerate */
     649             :   nullptr, /* newEnumerate */
     650             :   nullptr, /* resolve */
     651             :   nullptr, /* mayResolve */
     652             :   _finalize, /* finalize */
     653             :   nullptr, /* call */
     654             :   nullptr,               /* hasInstance */
     655             :   nullptr,               /* construct */
     656             :   nullptr, /* trace */
     657             : };
     658             : 
     659             : static const js::ClassExtension sClassExtension = {
     660             :   nullptr, /* weakmapKeyDelegateOp */
     661             :   _objectMoved /* objectMovedOp */
     662             : };
     663             : 
     664             : static const DOMJSClass sClass = {
     665             :   { "PresentationRequest",
     666             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     667             :     &sClassOps,
     668             :     JS_NULL_CLASS_SPEC,
     669             :     &sClassExtension,
     670             :     JS_NULL_OBJECT_OPS
     671             :   },
     672             :   { prototypes::id::EventTarget, prototypes::id::PresentationRequest, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     673             :   IsBaseOf<nsISupports, mozilla::dom::PresentationRequest >::value,
     674             :   sNativePropertyHooks,
     675             :   FindAssociatedGlobalForNative<mozilla::dom::PresentationRequest>::Get,
     676             :   GetProtoObjectHandle,
     677             :   GetCCParticipant<mozilla::dom::PresentationRequest>::Get()
     678             : };
     679             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     680             :               "Must have the right minimal number of reserved slots.");
     681             : static_assert(1 >= 1,
     682             :               "Must have enough reserved slots.");
     683             : 
     684             : const JSClass*
     685           0 : GetJSClass()
     686             : {
     687           0 :   return sClass.ToJSClass();
     688             : }
     689             : 
     690             : bool
     691           0 : Wrap(JSContext* aCx, mozilla::dom::PresentationRequest* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     692             : {
     693             :   MOZ_ASSERT(static_cast<mozilla::dom::PresentationRequest*>(aObject) ==
     694             :              reinterpret_cast<mozilla::dom::PresentationRequest*>(aObject),
     695             :              "Multiple inheritance for mozilla::dom::PresentationRequest is broken.");
     696             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     697             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     698             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     699           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     700           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     701           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     702             :              "You should probably not be using Wrap() directly; use "
     703             :              "GetOrCreateDOMReflector instead");
     704             : 
     705           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     706             :              "nsISupports must be on our primary inheritance chain");
     707             : 
     708           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     709           0 :   if (!global) {
     710           0 :     return false;
     711             :   }
     712           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     713           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     714             : 
     715             :   // That might have ended up wrapping us already, due to the wonders
     716             :   // of XBL.  Check for that, and bail out as needed.
     717           0 :   aReflector.set(aCache->GetWrapper());
     718           0 :   if (aReflector) {
     719             : #ifdef DEBUG
     720           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     721             : #endif // DEBUG
     722           0 :     return true;
     723             :   }
     724             : 
     725           0 :   JSAutoCompartment ac(aCx, global);
     726           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     727           0 :   if (!canonicalProto) {
     728           0 :     return false;
     729             :   }
     730           0 :   JS::Rooted<JSObject*> proto(aCx);
     731           0 :   if (aGivenProto) {
     732           0 :     proto = aGivenProto;
     733             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     734             :     // coming in, we changed compartments to that of "parent" so may need
     735             :     // to wrap the proto here.
     736           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     737           0 :       if (!JS_WrapObject(aCx, &proto)) {
     738           0 :         return false;
     739             :       }
     740             :     }
     741             :   } else {
     742           0 :     proto = canonicalProto;
     743             :   }
     744             : 
     745           0 :   BindingJSObjectCreator<mozilla::dom::PresentationRequest> creator(aCx);
     746           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     747           0 :   if (!aReflector) {
     748           0 :     return false;
     749             :   }
     750             : 
     751           0 :   aCache->SetWrapper(aReflector);
     752           0 :   creator.InitializationSucceeded();
     753             : 
     754           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     755             :              aCache->GetWrapperPreserveColor() == aReflector);
     756             :   // If proto != canonicalProto, we have to preserve our wrapper;
     757             :   // otherwise we won't be able to properly recreate it later, since
     758             :   // we won't know what proto to use.  Note that we don't check
     759             :   // aGivenProto here, since it's entirely possible (and even
     760             :   // somewhat common) to have a non-null aGivenProto which is the
     761             :   // same as canonicalProto.
     762           0 :   if (proto != canonicalProto) {
     763           0 :     PreserveWrapper(aObject);
     764             :   }
     765             : 
     766           0 :   return true;
     767             : }
     768             : 
     769             : const NativePropertyHooks sNativePropertyHooks[] = { {
     770             :   nullptr,
     771             :   nullptr,
     772             :   nullptr,
     773             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
     774             :   prototypes::id::PresentationRequest,
     775             :   constructors::id::PresentationRequest,
     776             :   EventTargetBinding::sNativePropertyHooks,
     777             :   &DefaultXrayExpandoObjectClass
     778             : } };
     779             : 
     780             : void
     781           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     782             : {
     783           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     784           0 :   if (!parentProto) {
     785           0 :     return;
     786             :   }
     787             : 
     788           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     789           0 :   if (!constructorProto) {
     790           0 :     return;
     791             :   }
     792             : 
     793             :   static bool sIdsInited = false;
     794           0 :   if (!sIdsInited && NS_IsMainThread()) {
     795           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     796           0 :       return;
     797             :     }
     798           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
     799           0 :       return;
     800             :     }
     801           0 :     sIdsInited = true;
     802             :   }
     803             : 
     804           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PresentationRequest);
     805           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PresentationRequest);
     806           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     807             :                               &sPrototypeClass.mBase, protoCache,
     808             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
     809             :                               interfaceCache,
     810             :                               sNativeProperties.Upcast(),
     811           0 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
     812             :                               "PresentationRequest", aDefineOnGlobal,
     813             :                               nullptr,
     814           0 :                               false);
     815             : }
     816             : 
     817             : JS::Handle<JSObject*>
     818           0 : GetProtoObjectHandle(JSContext* aCx)
     819             : {
     820             :   /* Get the interface prototype object for this class.  This will create the
     821             :      object as needed. */
     822           0 :   bool aDefineOnGlobal = true;
     823             : 
     824             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     825           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     826           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     827           0 :     return nullptr;
     828             :   }
     829             : 
     830             :   /* Check to see whether the interface objects are already installed */
     831           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     832           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PresentationRequest)) {
     833           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     834           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     835             :   }
     836             : 
     837             :   /*
     838             :    * The object might _still_ be null, but that's OK.
     839             :    *
     840             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     841             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     842             :    * changed after they have been set.
     843             :    *
     844             :    * Calling address() avoids the read read barrier that does gray
     845             :    * unmarking, but it's not possible for the object to be gray here.
     846             :    */
     847             : 
     848           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PresentationRequest);
     849           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     850           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     851             : }
     852             : 
     853             : JS::Handle<JSObject*>
     854           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     855             : {
     856             :   /* Get the interface object for this class.  This will create the object as
     857             :      needed. */
     858             : 
     859             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     860           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     861           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     862           0 :     return nullptr;
     863             :   }
     864             : 
     865             :   /* Check to see whether the interface objects are already installed */
     866           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     867           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::PresentationRequest)) {
     868           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     869           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     870             :   }
     871             : 
     872             :   /*
     873             :    * The object might _still_ be null, but that's OK.
     874             :    *
     875             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     876             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     877             :    * changed after they have been set.
     878             :    *
     879             :    * Calling address() avoids the read read barrier that does gray
     880             :    * unmarking, but it's not possible for the object to be gray here.
     881             :    */
     882             : 
     883           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::PresentationRequest);
     884           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     885           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     886             : }
     887             : 
     888             : JSObject*
     889           0 : GetConstructorObject(JSContext* aCx)
     890             : {
     891           0 :   return GetConstructorObjectHandle(aCx);
     892             : }
     893             : 
     894             : } // namespace PresentationRequestBinding
     895             : 
     896             : 
     897             : 
     898             : } // namespace dom
     899             : } // namespace mozilla

Generated by: LCOV version 1.13