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

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

Generated by: LCOV version 1.13