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

Generated by: LCOV version 1.13