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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM WindowRoot.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventTargetBinding.h"
       4             : #include "WindowRootBinding.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/XrayExpandoClass.h"
      11             : #include "nsContentUtils.h"
      12             : #include "nsWindowRoot.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : namespace WindowRootBinding {
      18             : 
      19             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      20             :               "Can't inherit from an interface with a different ownership model.");
      21             : 
      22             : static bool
      23           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      24             : {
      25           0 :   nsWindowRoot* self = UnwrapPossiblyNotInitializedDOMObject<nsWindowRoot>(obj);
      26             :   // We don't want to preserve if we don't have a wrapper, and we
      27             :   // obviously can't preserve if we're not initialized.
      28           0 :   if (self && self->GetWrapperPreserveColor()) {
      29           0 :     PreserveWrapper(self);
      30             :   }
      31           0 :   return true;
      32             : }
      33             : 
      34             : static void
      35           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      36             : {
      37           0 :   nsWindowRoot* self = UnwrapPossiblyNotInitializedDOMObject<nsWindowRoot>(obj);
      38           0 :   if (self) {
      39           0 :     ClearWrapper(self, self, obj);
      40           0 :     AddForDeferredFinalization<nsWindowRoot>(self);
      41             :   }
      42           0 : }
      43             : 
      44             : static void
      45           0 : _objectMoved(JSObject* obj, const JSObject* old)
      46             : {
      47           0 :   nsWindowRoot* self = UnwrapPossiblyNotInitializedDOMObject<nsWindowRoot>(obj);
      48           0 :   if (self) {
      49           0 :     UpdateWrapper(self, self, obj, old);
      50             :   }
      51           0 : }
      52             : 
      53             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
      54             :   {
      55             :     "Function",
      56             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
      57             :     &sBoringInterfaceObjectClassClassOps,
      58             :     JS_NULL_CLASS_SPEC,
      59             :     JS_NULL_CLASS_EXT,
      60             :     &sInterfaceObjectClassObjectOps
      61             :   },
      62             :   eInterface,
      63             :   true,
      64             :   prototypes::id::WindowRoot,
      65             :   PrototypeTraits<prototypes::id::WindowRoot>::Depth,
      66             :   sNativePropertyHooks,
      67             :   "function WindowRoot() {\n    [native code]\n}",
      68             :   EventTargetBinding::GetConstructorObject
      69             : };
      70             : 
      71             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
      72             :   {
      73             :     "WindowRootPrototype",
      74             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
      75             :     JS_NULL_CLASS_OPS,
      76             :     JS_NULL_CLASS_SPEC,
      77             :     JS_NULL_CLASS_EXT,
      78             :     JS_NULL_OBJECT_OPS
      79             :   },
      80             :   eInterfacePrototype,
      81             :   false,
      82             :   prototypes::id::WindowRoot,
      83             :   PrototypeTraits<prototypes::id::WindowRoot>::Depth,
      84             :   sNativePropertyHooks,
      85             :   "[object WindowRootPrototype]",
      86             :   EventTargetBinding::GetProtoObject
      87             : };
      88             : 
      89             : bool
      90           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
      91             : {
      92           0 :   return nsContentUtils::ThreadsafeIsSystemCaller(aCx);
      93             : }
      94             : 
      95             : JSObject*
      96           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
      97             : {
      98           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
      99             : }
     100             : 
     101             : static const js::ClassOps sClassOps = {
     102             :   _addProperty, /* addProperty */
     103             :   nullptr,               /* delProperty */
     104             :   nullptr,               /* getProperty */
     105             :   nullptr,               /* setProperty */
     106             :   nullptr,               /* enumerate */
     107             :   nullptr, /* newEnumerate */
     108             :   nullptr, /* resolve */
     109             :   nullptr, /* mayResolve */
     110             :   _finalize, /* finalize */
     111             :   nullptr, /* call */
     112             :   nullptr,               /* hasInstance */
     113             :   nullptr,               /* construct */
     114             :   nullptr, /* trace */
     115             : };
     116             : 
     117             : static const js::ClassExtension sClassExtension = {
     118             :   nullptr, /* weakmapKeyDelegateOp */
     119             :   _objectMoved /* objectMovedOp */
     120             : };
     121             : 
     122             : static const DOMJSClass sClass = {
     123             :   { "WindowRoot",
     124             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     125             :     &sClassOps,
     126             :     JS_NULL_CLASS_SPEC,
     127             :     &sClassExtension,
     128             :     JS_NULL_OBJECT_OPS
     129             :   },
     130             :   { prototypes::id::EventTarget, prototypes::id::WindowRoot, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     131             :   IsBaseOf<nsISupports, nsWindowRoot >::value,
     132             :   sNativePropertyHooks,
     133             :   FindAssociatedGlobalForNative<nsWindowRoot>::Get,
     134             :   GetProtoObjectHandle,
     135             :   GetCCParticipant<nsWindowRoot>::Get()
     136             : };
     137             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     138             :               "Must have the right minimal number of reserved slots.");
     139             : static_assert(1 >= 1,
     140             :               "Must have enough reserved slots.");
     141             : 
     142             : const JSClass*
     143           0 : GetJSClass()
     144             : {
     145           0 :   return sClass.ToJSClass();
     146             : }
     147             : 
     148             : bool
     149           0 : Wrap(JSContext* aCx, nsWindowRoot* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     150             : {
     151             :   MOZ_ASSERT(static_cast<nsWindowRoot*>(aObject) ==
     152             :              reinterpret_cast<nsWindowRoot*>(aObject),
     153             :              "Multiple inheritance for nsWindowRoot is broken.");
     154             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     155             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     156             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     157           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     158           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     159           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     160             :              "You should probably not be using Wrap() directly; use "
     161             :              "GetOrCreateDOMReflector instead");
     162             : 
     163           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     164             :              "nsISupports must be on our primary inheritance chain");
     165             : 
     166           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     167           0 :   if (!global) {
     168           0 :     return false;
     169             :   }
     170           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     171           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     172             : 
     173             :   // That might have ended up wrapping us already, due to the wonders
     174             :   // of XBL.  Check for that, and bail out as needed.
     175           0 :   aReflector.set(aCache->GetWrapper());
     176           0 :   if (aReflector) {
     177             : #ifdef DEBUG
     178           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     179             : #endif // DEBUG
     180           0 :     return true;
     181             :   }
     182             : 
     183           0 :   JSAutoCompartment ac(aCx, global);
     184           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     185           0 :   if (!canonicalProto) {
     186           0 :     return false;
     187             :   }
     188           0 :   JS::Rooted<JSObject*> proto(aCx);
     189           0 :   if (aGivenProto) {
     190           0 :     proto = aGivenProto;
     191             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     192             :     // coming in, we changed compartments to that of "parent" so may need
     193             :     // to wrap the proto here.
     194           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     195           0 :       if (!JS_WrapObject(aCx, &proto)) {
     196           0 :         return false;
     197             :       }
     198             :     }
     199             :   } else {
     200           0 :     proto = canonicalProto;
     201             :   }
     202             : 
     203           0 :   BindingJSObjectCreator<nsWindowRoot> creator(aCx);
     204           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     205           0 :   if (!aReflector) {
     206           0 :     return false;
     207             :   }
     208             : 
     209           0 :   aCache->SetWrapper(aReflector);
     210           0 :   creator.InitializationSucceeded();
     211             : 
     212           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     213             :              aCache->GetWrapperPreserveColor() == aReflector);
     214             :   // If proto != canonicalProto, we have to preserve our wrapper;
     215             :   // otherwise we won't be able to properly recreate it later, since
     216             :   // we won't know what proto to use.  Note that we don't check
     217             :   // aGivenProto here, since it's entirely possible (and even
     218             :   // somewhat common) to have a non-null aGivenProto which is the
     219             :   // same as canonicalProto.
     220           0 :   if (proto != canonicalProto) {
     221           0 :     PreserveWrapper(aObject);
     222             :   }
     223             : 
     224           0 :   return true;
     225             : }
     226             : 
     227             : const NativePropertyHooks sNativePropertyHooks[] = { {
     228             :   nullptr,
     229             :   nullptr,
     230             :   nullptr,
     231             :   { nullptr, nullptr },
     232             :   prototypes::id::WindowRoot,
     233             :   constructors::id::WindowRoot,
     234             :   EventTargetBinding::sNativePropertyHooks,
     235             :   &DefaultXrayExpandoObjectClass
     236             : } };
     237             : 
     238             : void
     239           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     240             : {
     241           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     242           0 :   if (!parentProto) {
     243           0 :     return;
     244             :   }
     245             : 
     246           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     247           0 :   if (!constructorProto) {
     248           0 :     return;
     249             :   }
     250             : 
     251           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::WindowRoot);
     252           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::WindowRoot);
     253           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     254             :                               &sPrototypeClass.mBase, protoCache,
     255             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     256             :                               interfaceCache,
     257             :                               nullptr,
     258             :                               nullptr,
     259             :                               "WindowRoot", aDefineOnGlobal,
     260             :                               nullptr,
     261           0 :                               false);
     262             : }
     263             : 
     264             : JS::Handle<JSObject*>
     265           0 : GetProtoObjectHandle(JSContext* aCx)
     266             : {
     267             :   /* Get the interface prototype object for this class.  This will create the
     268             :      object as needed. */
     269           0 :   bool aDefineOnGlobal = true;
     270             : 
     271             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     272           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     273           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     274           0 :     return nullptr;
     275             :   }
     276             : 
     277             :   /* Check to see whether the interface objects are already installed */
     278           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     279           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::WindowRoot)) {
     280           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     281           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     282             :   }
     283             : 
     284             :   /*
     285             :    * The object might _still_ be null, but that's OK.
     286             :    *
     287             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     288             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     289             :    * changed after they have been set.
     290             :    *
     291             :    * Calling address() avoids the read read barrier that does gray
     292             :    * unmarking, but it's not possible for the object to be gray here.
     293             :    */
     294             : 
     295           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::WindowRoot);
     296           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     297           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     298             : }
     299             : 
     300             : JS::Handle<JSObject*>
     301           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     302             : {
     303             :   /* Get the interface object for this class.  This will create the object as
     304             :      needed. */
     305             : 
     306             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     307           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     308           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     309           0 :     return nullptr;
     310             :   }
     311             : 
     312             :   /* Check to see whether the interface objects are already installed */
     313           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     314           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::WindowRoot)) {
     315           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     316           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     317             :   }
     318             : 
     319             :   /*
     320             :    * The object might _still_ be null, but that's OK.
     321             :    *
     322             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     323             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     324             :    * changed after they have been set.
     325             :    *
     326             :    * Calling address() avoids the read read barrier that does gray
     327             :    * unmarking, but it's not possible for the object to be gray here.
     328             :    */
     329             : 
     330           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::WindowRoot);
     331           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     332           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     333             : }
     334             : 
     335             : JSObject*
     336           0 : GetConstructorObject(JSContext* aCx)
     337             : {
     338           0 :   return GetConstructorObjectHandle(aCx);
     339             : }
     340             : 
     341             : } // namespace WindowRootBinding
     342             : 
     343             : 
     344             : 
     345             : } // namespace dom
     346             : } // namespace mozilla

Generated by: LCOV version 1.13