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

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

Generated by: LCOV version 1.13