LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - HTMLShadowElementBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 107 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 HTMLShadowElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "HTMLElementBinding.h"
       4             : #include "HTMLShadowElementBinding.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/HTMLShadowElement.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/Nullable.h"
      12             : #include "mozilla/dom/ShadowRoot.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : #include "nsDocument.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : namespace HTMLShadowElementBinding {
      20             : 
      21             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<HTMLElementBinding::NativeType>::value,
      22             :               "Can't inherit from an interface with a different ownership model.");
      23             : 
      24             : static bool
      25           0 : get_olderShadowRoot(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::HTMLShadowElement* self, JSJitGetterCallArgs args)
      26             : {
      27           0 :   auto result(StrongOrRawPtr<mozilla::dom::ShadowRoot>(self->GetOlderShadowRoot()));
      28           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      29           0 :   if (!result) {
      30           0 :     args.rval().setNull();
      31           0 :     return true;
      32             :   }
      33           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      34           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      35           0 :     return false;
      36             :   }
      37           0 :   return true;
      38             : }
      39             : 
      40             : static const JSJitInfo olderShadowRoot_getterinfo = {
      41             :   { (JSJitGetterOp)get_olderShadowRoot },
      42             :   { prototypes::id::HTMLShadowElement },
      43             :   { PrototypeTraits<prototypes::id::HTMLShadowElement>::Depth },
      44             :   JSJitInfo::Getter,
      45             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      46             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      47             :   false,  /* isInfallible. False in setters. */
      48             :   false,  /* isMovable.  Not relevant for setters. */
      49             :   false, /* isEliminatable.  Not relevant for setters. */
      50             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      51             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      52             :   false,  /* isTypedMethod.  Only relevant for methods. */
      53             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      54             : };
      55             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      56             : static_assert(0 < 1, "There is no slot for us");
      57             : 
      58             : static bool
      59           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      60             : {
      61           0 :   mozilla::dom::HTMLShadowElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLShadowElement>(obj);
      62             :   // We don't want to preserve if we don't have a wrapper, and we
      63             :   // obviously can't preserve if we're not initialized.
      64           0 :   if (self && self->GetWrapperPreserveColor()) {
      65           0 :     PreserveWrapper(self);
      66             :   }
      67           0 :   return true;
      68             : }
      69             : 
      70             : static void
      71           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      72             : {
      73           0 :   mozilla::dom::HTMLShadowElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLShadowElement>(obj);
      74           0 :   if (self) {
      75           0 :     ClearWrapper(self, self, obj);
      76           0 :     AddForDeferredFinalization<mozilla::dom::HTMLShadowElement>(self);
      77             :   }
      78           0 : }
      79             : 
      80             : static void
      81           0 : _objectMoved(JSObject* obj, const JSObject* old)
      82             : {
      83           0 :   mozilla::dom::HTMLShadowElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::HTMLShadowElement>(obj);
      84           0 :   if (self) {
      85           0 :     UpdateWrapper(self, self, obj, old);
      86             :   }
      87           0 : }
      88             : 
      89             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
      90             : #if defined(__clang__)
      91             : #pragma clang diagnostic push
      92             : #pragma clang diagnostic ignored "-Wmissing-braces"
      93             : #endif
      94             : static const JSPropertySpec sAttributes_specs[] = {
      95             :   { "olderShadowRoot", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &olderShadowRoot_getterinfo, nullptr, nullptr },
      96             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
      97             : };
      98             : #if defined(__clang__)
      99             : #pragma clang diagnostic pop
     100             : #endif
     101             : 
     102             : 
     103             : // Can't be const because the pref-enabled boolean needs to be writable
     104             : static Prefable<const JSPropertySpec> sAttributes[] = {
     105             :   { nullptr, &sAttributes_specs[0] },
     106             :   { nullptr, nullptr }
     107             : };
     108             : 
     109             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     110             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     111             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     112             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     113             : 
     114             : 
     115             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
     116             : static PropertyInfo sNativeProperties_propertyInfos[1];
     117             : 
     118             : static const NativePropertiesN<1> sNativeProperties = {
     119             :   false, 0,
     120             :   false, 0,
     121             :   false, 0,
     122             :   true,  0 /* sAttributes */,
     123             :   false, 0,
     124             :   false, 0,
     125             :   false, 0,
     126             :   -1,
     127             :   1,
     128             :   sNativeProperties_sortedPropertyIndices,
     129             :   {
     130             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     131             :   }
     132             : };
     133             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     134             :     "We have a property info count that is oversized");
     135             : 
     136             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     137             :   {
     138             :     "Function",
     139             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     140             :     &sBoringInterfaceObjectClassClassOps,
     141             :     JS_NULL_CLASS_SPEC,
     142             :     JS_NULL_CLASS_EXT,
     143             :     &sInterfaceObjectClassObjectOps
     144             :   },
     145             :   eInterface,
     146             :   true,
     147             :   prototypes::id::HTMLShadowElement,
     148             :   PrototypeTraits<prototypes::id::HTMLShadowElement>::Depth,
     149             :   sNativePropertyHooks,
     150             :   "function HTMLShadowElement() {\n    [native code]\n}",
     151             :   HTMLElementBinding::GetConstructorObject
     152             : };
     153             : 
     154             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     155             :   {
     156             :     "HTMLShadowElementPrototype",
     157             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     158             :     JS_NULL_CLASS_OPS,
     159             :     JS_NULL_CLASS_SPEC,
     160             :     JS_NULL_CLASS_EXT,
     161             :     JS_NULL_OBJECT_OPS
     162             :   },
     163             :   eInterfacePrototype,
     164             :   false,
     165             :   prototypes::id::HTMLShadowElement,
     166             :   PrototypeTraits<prototypes::id::HTMLShadowElement>::Depth,
     167             :   sNativePropertyHooks,
     168             :   "[object HTMLShadowElementPrototype]",
     169             :   HTMLElementBinding::GetProtoObject
     170             : };
     171             : 
     172             : bool
     173           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     174             : {
     175           0 :   return nsDocument::IsWebComponentsEnabled(aCx, aObj);
     176             : }
     177             : 
     178             : JSObject*
     179           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     180             : {
     181           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     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             :   { "HTMLShadowElement",
     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::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::HTMLElement, prototypes::id::HTMLShadowElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     214             :   IsBaseOf<nsISupports, mozilla::dom::HTMLShadowElement >::value,
     215             :   sNativePropertyHooks,
     216             :   FindAssociatedGlobalForNative<mozilla::dom::HTMLShadowElement>::Get,
     217             :   GetProtoObjectHandle,
     218             :   GetCCParticipant<mozilla::dom::HTMLShadowElement>::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::HTMLShadowElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     233             : {
     234             :   MOZ_ASSERT(static_cast<mozilla::dom::HTMLShadowElement*>(aObject) ==
     235             :              reinterpret_cast<mozilla::dom::HTMLShadowElement*>(aObject),
     236             :              "Multiple inheritance for mozilla::dom::HTMLShadowElement is broken.");
     237             :   MOZ_ASSERT(static_cast<nsGenericHTMLElement*>(aObject) ==
     238             :              reinterpret_cast<nsGenericHTMLElement*>(aObject),
     239             :              "Multiple inheritance for nsGenericHTMLElement is broken.");
     240             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     241             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     242             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     243             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     244             :              reinterpret_cast<nsINode*>(aObject),
     245             :              "Multiple inheritance for nsINode is broken.");
     246             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     247             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     248             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     249           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     250           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     251           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     252             :              "You should probably not be using Wrap() directly; use "
     253             :              "GetOrCreateDOMReflector instead");
     254             : 
     255           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     256             :              "nsISupports must be on our primary inheritance chain");
     257             : 
     258           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     259           0 :   if (!global) {
     260           0 :     return false;
     261             :   }
     262           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     263           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     264             : 
     265             :   // That might have ended up wrapping us already, due to the wonders
     266             :   // of XBL.  Check for that, and bail out as needed.
     267           0 :   aReflector.set(aCache->GetWrapper());
     268           0 :   if (aReflector) {
     269             : #ifdef DEBUG
     270           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     271             : #endif // DEBUG
     272           0 :     return true;
     273             :   }
     274             : 
     275           0 :   JSAutoCompartment ac(aCx, global);
     276           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     277           0 :   if (!canonicalProto) {
     278           0 :     return false;
     279             :   }
     280           0 :   JS::Rooted<JSObject*> proto(aCx);
     281           0 :   if (aGivenProto) {
     282           0 :     proto = aGivenProto;
     283             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     284             :     // coming in, we changed compartments to that of "parent" so may need
     285             :     // to wrap the proto here.
     286           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     287           0 :       if (!JS_WrapObject(aCx, &proto)) {
     288           0 :         return false;
     289             :       }
     290             :     }
     291             :   } else {
     292           0 :     proto = canonicalProto;
     293             :   }
     294             : 
     295           0 :   BindingJSObjectCreator<mozilla::dom::HTMLShadowElement> creator(aCx);
     296           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     297           0 :   if (!aReflector) {
     298           0 :     return false;
     299             :   }
     300             : 
     301           0 :   aCache->SetWrapper(aReflector);
     302           0 :   creator.InitializationSucceeded();
     303             : 
     304           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     305             :              aCache->GetWrapperPreserveColor() == aReflector);
     306             :   // If proto != canonicalProto, we have to preserve our wrapper;
     307             :   // otherwise we won't be able to properly recreate it later, since
     308             :   // we won't know what proto to use.  Note that we don't check
     309             :   // aGivenProto here, since it's entirely possible (and even
     310             :   // somewhat common) to have a non-null aGivenProto which is the
     311             :   // same as canonicalProto.
     312           0 :   if (proto != canonicalProto) {
     313           0 :     PreserveWrapper(aObject);
     314             :   }
     315             : 
     316           0 :   return true;
     317             : }
     318             : 
     319             : const NativePropertyHooks sNativePropertyHooks[] = { {
     320             :   nullptr,
     321             :   nullptr,
     322             :   nullptr,
     323             :   { sNativeProperties.Upcast(), nullptr },
     324             :   prototypes::id::HTMLShadowElement,
     325             :   constructors::id::HTMLShadowElement,
     326             :   HTMLElementBinding::sNativePropertyHooks,
     327             :   &DefaultXrayExpandoObjectClass
     328             : } };
     329             : 
     330             : void
     331           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     332             : {
     333           0 :   JS::Handle<JSObject*> parentProto(HTMLElementBinding::GetProtoObjectHandle(aCx));
     334           0 :   if (!parentProto) {
     335           0 :     return;
     336             :   }
     337             : 
     338           0 :   JS::Handle<JSObject*> constructorProto(HTMLElementBinding::GetConstructorObjectHandle(aCx));
     339           0 :   if (!constructorProto) {
     340           0 :     return;
     341             :   }
     342             : 
     343             :   static bool sIdsInited = false;
     344           0 :   if (!sIdsInited && NS_IsMainThread()) {
     345           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     346           0 :       return;
     347             :     }
     348           0 :     sIdsInited = true;
     349             :   }
     350             : 
     351           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::HTMLShadowElement);
     352           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::HTMLShadowElement);
     353           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     354             :                               &sPrototypeClass.mBase, protoCache,
     355             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     356             :                               interfaceCache,
     357             :                               sNativeProperties.Upcast(),
     358             :                               nullptr,
     359             :                               "HTMLShadowElement", aDefineOnGlobal,
     360             :                               nullptr,
     361           0 :                               false);
     362             : }
     363             : 
     364             : JS::Handle<JSObject*>
     365           0 : GetProtoObjectHandle(JSContext* aCx)
     366             : {
     367             :   /* Get the interface prototype object for this class.  This will create the
     368             :      object as needed. */
     369           0 :   bool aDefineOnGlobal = true;
     370             : 
     371             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     372           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     373           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     374           0 :     return nullptr;
     375             :   }
     376             : 
     377             :   /* Check to see whether the interface objects are already installed */
     378           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     379           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::HTMLShadowElement)) {
     380           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     381           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     382             :   }
     383             : 
     384             :   /*
     385             :    * The object might _still_ be null, but that's OK.
     386             :    *
     387             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     388             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     389             :    * changed after they have been set.
     390             :    *
     391             :    * Calling address() avoids the read read barrier that does gray
     392             :    * unmarking, but it's not possible for the object to be gray here.
     393             :    */
     394             : 
     395           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::HTMLShadowElement);
     396           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     397           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     398             : }
     399             : 
     400             : JS::Handle<JSObject*>
     401           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     402             : {
     403             :   /* Get the interface object for this class.  This will create the object as
     404             :      needed. */
     405             : 
     406             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     407           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     408           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     409           0 :     return nullptr;
     410             :   }
     411             : 
     412             :   /* Check to see whether the interface objects are already installed */
     413           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     414           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::HTMLShadowElement)) {
     415           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     416           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     417             :   }
     418             : 
     419             :   /*
     420             :    * The object might _still_ be null, but that's OK.
     421             :    *
     422             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     423             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     424             :    * changed after they have been set.
     425             :    *
     426             :    * Calling address() avoids the read read barrier that does gray
     427             :    * unmarking, but it's not possible for the object to be gray here.
     428             :    */
     429             : 
     430           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::HTMLShadowElement);
     431           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     432           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     433             : }
     434             : 
     435             : JSObject*
     436           0 : GetConstructorObject(JSContext* aCx)
     437             : {
     438           0 :   return GetConstructorObjectHandle(aCx);
     439             : }
     440             : 
     441             : } // namespace HTMLShadowElementBinding
     442             : 
     443             : 
     444             : 
     445             : } // namespace dom
     446             : } // namespace mozilla

Generated by: LCOV version 1.13