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

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

Generated by: LCOV version 1.13