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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM WorkletGlobalScope.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "WorkletGlobalScopeBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/DOMJSClass.h"
       8             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       9             : #include "mozilla/dom/WorkletGlobalScope.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14             : namespace WorkletGlobalScopeBinding {
      15             : 
      16             : static bool
      17           0 : dump(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::WorkletGlobalScope* self, const JSJitMethodCallArgs& args)
      18             : {
      19           0 :   Optional<nsAString> arg0;
      20           0 :   binding_detail::FakeString arg0_holder;
      21           0 :   if (args.hasDefined(0)) {
      22           0 :     if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0_holder)) {
      23           0 :       return false;
      24             :     }
      25           0 :     arg0 = &arg0_holder;
      26             :   }
      27           0 :   self->Dump(NonNullHelper(Constify(arg0)));
      28           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      29           0 :   args.rval().setUndefined();
      30           0 :   return true;
      31             : }
      32             : 
      33             : static const JSJitInfo dump_methodinfo = {
      34             :   { (JSJitGetterOp)dump },
      35             :   { prototypes::id::WorkletGlobalScope },
      36             :   { PrototypeTraits<prototypes::id::WorkletGlobalScope>::Depth },
      37             :   JSJitInfo::Method,
      38             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      39             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
      40             :   false,  /* isInfallible. False in setters. */
      41             :   false,  /* isMovable.  Not relevant for setters. */
      42             :   false, /* isEliminatable.  Not relevant for setters. */
      43             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      44             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      45             :   false,  /* isTypedMethod.  Only relevant for methods. */
      46             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      47             : };
      48             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      49             : static_assert(0 < 1, "There is no slot for us");
      50             : 
      51             : static bool
      52           0 : genericMethod(JSContext* cx, unsigned argc, JS::Value* vp)
      53             : {
      54           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
      55           0 :   if (!args.thisv().isNullOrUndefined() && !args.thisv().isObject()) {
      56           0 :     return ThrowInvalidThis(cx, args, false, "WorkletGlobalScope");
      57             :   }
      58           0 :   JS::Rooted<JSObject*> obj(cx, args.thisv().isObject() ? &args.thisv().toObject() : js::GetGlobalForObjectCrossCompartment(&args.callee()));
      59             : 
      60             :   mozilla::dom::WorkletGlobalScope* self;
      61           0 :   JS::Rooted<JS::Value> rootSelf(cx, JS::ObjectValue(*obj));
      62             :   {
      63           0 :     nsresult rv = UnwrapObject<prototypes::id::WorkletGlobalScope, mozilla::dom::WorkletGlobalScope>(&rootSelf, self);
      64           0 :     if (NS_FAILED(rv)) {
      65           0 :       return ThrowInvalidThis(cx, args, rv == NS_ERROR_XPC_SECURITY_MANAGER_VETO, "WorkletGlobalScope");
      66             :     }
      67             :   }
      68           0 :   const JSJitInfo *info = FUNCTION_VALUE_TO_JITINFO(args.calleev());
      69           0 :   MOZ_ASSERT(info->type() == JSJitInfo::Method);
      70           0 :   JSJitMethodOp method = info->method;
      71           0 :   bool ok = method(cx, obj, self, JSJitMethodCallArgs(args));
      72             : #ifdef DEBUG
      73           0 :   if (ok) {
      74           0 :     AssertReturnTypeMatchesJitinfo(info, args.rval());
      75             :   }
      76             : #endif
      77           0 :   return ok;
      78             : }
      79             : 
      80             : static bool
      81           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      82             : {
      83           0 :   mozilla::dom::WorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkletGlobalScope>(obj);
      84             :   // We don't want to preserve if we don't have a wrapper, and we
      85             :   // obviously can't preserve if we're not initialized.
      86           0 :   if (self && self->GetWrapperPreserveColor()) {
      87           0 :     PreserveWrapper(self);
      88             :   }
      89           0 :   return true;
      90             : }
      91             : 
      92             : static void
      93           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      94             : {
      95           0 :   mozilla::dom::WorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkletGlobalScope>(obj);
      96           0 :   if (self) {
      97           0 :     ClearWrapper(self, self, obj);
      98           0 :     AddForDeferredFinalization<mozilla::dom::WorkletGlobalScope>(self);
      99             :   }
     100           0 : }
     101             : 
     102             : static void
     103           0 : _objectMoved(JSObject* obj, const JSObject* old)
     104             : {
     105           0 :   mozilla::dom::WorkletGlobalScope* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::WorkletGlobalScope>(obj);
     106           0 :   if (self) {
     107           0 :     UpdateWrapper(self, self, obj, old);
     108             :   }
     109           0 : }
     110             : 
     111             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     112             : #if defined(__clang__)
     113             : #pragma clang diagnostic push
     114             : #pragma clang diagnostic ignored "-Wmissing-braces"
     115             : #endif
     116             : static const JSFunctionSpec sMethods_specs[] = {
     117             :   JS_FNSPEC("dump", genericMethod, reinterpret_cast<const JSJitInfo*>(&dump_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     118             :   JS_FS_END
     119             : };
     120             : #if defined(__clang__)
     121             : #pragma clang diagnostic pop
     122             : #endif
     123             : 
     124             : 
     125             : // Can't be const because the pref-enabled boolean needs to be writable
     126             : static Prefable<const JSFunctionSpec> sMethods[] = {
     127             :   { nullptr, &sMethods_specs[0] },
     128             :   { nullptr, nullptr }
     129             : };
     130             : 
     131             : 
     132             : static const NativePropertiesN<1> sNativeProperties = {
     133             :   false, 0,
     134             :   false, 0,
     135             :   true,  0 /* sMethods */,
     136             :   false, 0,
     137             :   false, 0,
     138             :   false, 0,
     139             :   false, 0,
     140             :   -1,
     141             :   0,
     142             :   nullptr,
     143             :   {
     144             :     { sMethods, nullptr }
     145             :   }
     146             : };
     147             : 
     148             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     149             :   {
     150             :     "Function",
     151             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     152             :     &sBoringInterfaceObjectClassClassOps,
     153             :     JS_NULL_CLASS_SPEC,
     154             :     JS_NULL_CLASS_EXT,
     155             :     &sInterfaceObjectClassObjectOps
     156             :   },
     157             :   eInterface,
     158             :   true,
     159             :   prototypes::id::WorkletGlobalScope,
     160             :   PrototypeTraits<prototypes::id::WorkletGlobalScope>::Depth,
     161             :   &sEmptyNativePropertyHooks,
     162             :   "function WorkletGlobalScope() {\n    [native code]\n}",
     163             :   JS::GetRealmFunctionPrototype
     164             : };
     165             : 
     166             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     167             :   {
     168             :     "WorkletGlobalScopePrototype",
     169             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     170             :     JS_NULL_CLASS_OPS,
     171             :     JS_NULL_CLASS_SPEC,
     172             :     JS_NULL_CLASS_EXT,
     173             :     JS_NULL_OBJECT_OPS
     174             :   },
     175             :   eInterfacePrototype,
     176             :   false,
     177             :   prototypes::id::WorkletGlobalScope,
     178             :   PrototypeTraits<prototypes::id::WorkletGlobalScope>::Depth,
     179             :   &sEmptyNativePropertyHooks,
     180             :   "[object WorkletGlobalScopePrototype]",
     181             :   JS::GetRealmObjectPrototype
     182             : };
     183             : 
     184             : static const js::ClassOps sClassOps = {
     185             :   _addProperty, /* addProperty */
     186             :   nullptr,               /* delProperty */
     187             :   nullptr,               /* getProperty */
     188             :   nullptr,               /* setProperty */
     189             :   nullptr,               /* enumerate */
     190             :   nullptr, /* newEnumerate */
     191             :   nullptr, /* resolve */
     192             :   nullptr, /* mayResolve */
     193             :   _finalize, /* finalize */
     194             :   nullptr, /* call */
     195             :   nullptr,               /* hasInstance */
     196             :   nullptr,               /* construct */
     197             :   nullptr, /* trace */
     198             : };
     199             : 
     200             : static const js::ClassExtension sClassExtension = {
     201             :   nullptr, /* weakmapKeyDelegateOp */
     202             :   _objectMoved /* objectMovedOp */
     203             : };
     204             : 
     205             : static const DOMJSClass sClass = {
     206             :   { "WorkletGlobalScope",
     207             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     208             :     &sClassOps,
     209             :     JS_NULL_CLASS_SPEC,
     210             :     &sClassExtension,
     211             :     JS_NULL_OBJECT_OPS
     212             :   },
     213             :   { prototypes::id::WorkletGlobalScope, 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 },
     214             :   IsBaseOf<nsISupports, mozilla::dom::WorkletGlobalScope >::value,
     215             :   &sEmptyNativePropertyHooks,
     216             :   FindAssociatedGlobalForNative<mozilla::dom::WorkletGlobalScope>::Get,
     217             :   GetProtoObjectHandle,
     218             :   GetCCParticipant<mozilla::dom::WorkletGlobalScope>::Get()
     219             : };
     220             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     221             :               "Must have the right minimal number of reserved slots.");
     222             : static_assert(1 >= 1,
     223             :               "Must have enough reserved slots.");
     224             : 
     225             : const JSClass*
     226           0 : GetJSClass()
     227             : {
     228           0 :   return sClass.ToJSClass();
     229             : }
     230             : 
     231             : bool
     232           0 : Wrap(JSContext* aCx, mozilla::dom::WorkletGlobalScope* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     233             : {
     234             :   MOZ_ASSERT(static_cast<mozilla::dom::WorkletGlobalScope*>(aObject) ==
     235             :              reinterpret_cast<mozilla::dom::WorkletGlobalScope*>(aObject),
     236             :              "Multiple inheritance for mozilla::dom::WorkletGlobalScope is broken.");
     237           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     238           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     239           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     240             :              "You should probably not be using Wrap() directly; use "
     241             :              "GetOrCreateDOMReflector instead");
     242             : 
     243           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     244             :              "nsISupports must be on our primary inheritance chain");
     245             : 
     246           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     247           0 :   if (!global) {
     248           0 :     return false;
     249             :   }
     250           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     251           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     252             : 
     253             :   // That might have ended up wrapping us already, due to the wonders
     254             :   // of XBL.  Check for that, and bail out as needed.
     255           0 :   aReflector.set(aCache->GetWrapper());
     256           0 :   if (aReflector) {
     257             : #ifdef DEBUG
     258           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     259             : #endif // DEBUG
     260           0 :     return true;
     261             :   }
     262             : 
     263           0 :   JSAutoCompartment ac(aCx, global);
     264           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     265           0 :   if (!canonicalProto) {
     266           0 :     return false;
     267             :   }
     268           0 :   JS::Rooted<JSObject*> proto(aCx);
     269           0 :   if (aGivenProto) {
     270           0 :     proto = aGivenProto;
     271             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     272             :     // coming in, we changed compartments to that of "parent" so may need
     273             :     // to wrap the proto here.
     274           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     275           0 :       if (!JS_WrapObject(aCx, &proto)) {
     276           0 :         return false;
     277             :       }
     278             :     }
     279             :   } else {
     280           0 :     proto = canonicalProto;
     281             :   }
     282             : 
     283           0 :   BindingJSObjectCreator<mozilla::dom::WorkletGlobalScope> creator(aCx);
     284           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     285           0 :   if (!aReflector) {
     286           0 :     return false;
     287             :   }
     288             : 
     289           0 :   aCache->SetWrapper(aReflector);
     290           0 :   creator.InitializationSucceeded();
     291             : 
     292           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     293             :              aCache->GetWrapperPreserveColor() == aReflector);
     294             :   // If proto != canonicalProto, we have to preserve our wrapper;
     295             :   // otherwise we won't be able to properly recreate it later, since
     296             :   // we won't know what proto to use.  Note that we don't check
     297             :   // aGivenProto here, since it's entirely possible (and even
     298             :   // somewhat common) to have a non-null aGivenProto which is the
     299             :   // same as canonicalProto.
     300           0 :   if (proto != canonicalProto) {
     301           0 :     PreserveWrapper(aObject);
     302             :   }
     303             : 
     304           0 :   return true;
     305             : }
     306             : 
     307             : void
     308           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     309             : {
     310           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     311           0 :   if (!parentProto) {
     312           0 :     return;
     313             :   }
     314             : 
     315           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     316           0 :   if (!constructorProto) {
     317           0 :     return;
     318             :   }
     319             : 
     320           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WorkletGlobalScope);
     321           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WorkletGlobalScope);
     322           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     323             :                               &sPrototypeClass.mBase, protoCache,
     324             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     325             :                               interfaceCache,
     326             :                               sNativeProperties.Upcast(),
     327             :                               nullptr,
     328             :                               "WorkletGlobalScope", aDefineOnGlobal,
     329             :                               nullptr,
     330           0 :                               false);
     331             : 
     332           0 :   if (*&aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WorkletGlobalScope)) {
     333             :     bool succeeded;
     334           0 :     JS::Handle<JSObject*> prot = GetProtoObjectHandle(aCx);
     335           0 :     if (!JS_SetImmutablePrototype(aCx, prot, &succeeded)) {
     336           0 :       *protoCache = nullptr;
     337           0 :       if (interfaceCache) {
     338           0 :         *interfaceCache = nullptr;
     339             :       }
     340           0 :       return;
     341             :     }
     342             : 
     343           0 :     MOZ_ASSERT(succeeded,
     344             :                "making a fresh prototype object's [[Prototype]] "
     345             :                "immutable can internally fail, but it should "
     346             :                "never be unsuccessful");
     347             :   }
     348             : }
     349             : 
     350             : JS::Handle<JSObject*>
     351           0 : GetProtoObjectHandle(JSContext* aCx)
     352             : {
     353             :   /* Get the interface prototype object for this class.  This will create the
     354             :      object as needed. */
     355           0 :   bool aDefineOnGlobal = true;
     356             : 
     357             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     358           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     359           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     360           0 :     return nullptr;
     361             :   }
     362             : 
     363             :   /* Check to see whether the interface objects are already installed */
     364           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     365           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::WorkletGlobalScope)) {
     366           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     367           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     368             :   }
     369             : 
     370             :   /*
     371             :    * The object might _still_ be null, but that's OK.
     372             :    *
     373             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     374             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     375             :    * changed after they have been set.
     376             :    *
     377             :    * Calling address() avoids the read read barrier that does gray
     378             :    * unmarking, but it's not possible for the object to be gray here.
     379             :    */
     380             : 
     381           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::WorkletGlobalScope);
     382           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     383           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     384             : }
     385             : 
     386             : JSObject*
     387           0 : GetProtoObject(JSContext* aCx)
     388             : {
     389           0 :   return GetProtoObjectHandle(aCx);
     390             : }
     391             : 
     392             : JS::Handle<JSObject*>
     393           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     394             : {
     395             :   /* Get the interface object for this class.  This will create the object as
     396             :      needed. */
     397             : 
     398             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     399           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     400           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     401           0 :     return nullptr;
     402             :   }
     403             : 
     404             :   /* Check to see whether the interface objects are already installed */
     405           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     406           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::WorkletGlobalScope)) {
     407           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     408           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     409             :   }
     410             : 
     411             :   /*
     412             :    * The object might _still_ be null, but that's OK.
     413             :    *
     414             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     415             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     416             :    * changed after they have been set.
     417             :    *
     418             :    * Calling address() avoids the read read barrier that does gray
     419             :    * unmarking, but it's not possible for the object to be gray here.
     420             :    */
     421             : 
     422           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::WorkletGlobalScope);
     423           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     424           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     425             : }
     426             : 
     427             : JSObject*
     428           0 : GetConstructorObject(JSContext* aCx)
     429             : {
     430           0 :   return GetConstructorObjectHandle(aCx);
     431             : }
     432             : 
     433             : } // namespace WorkletGlobalScopeBinding
     434             : 
     435             : 
     436             : 
     437             : } // namespace dom
     438             : } // namespace mozilla

Generated by: LCOV version 1.13