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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM CSSStyleRule.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "CSSRuleBinding.h"
       4             : #include "CSSStyleRuleBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/BindingStyleRule.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/XrayExpandoClass.h"
      12             : #include "nsICSSDeclaration.h"
      13             : #include "nsISupports.h"
      14             : #include "xpcjsid.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : namespace CSSStyleRuleBinding {
      20             : 
      21             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CSSRuleBinding::NativeType>::value,
      22             :               "Can't inherit from an interface with a different ownership model.");
      23             : 
      24             : static bool
      25           0 : get_selectorText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::BindingStyleRule* self, JSJitGetterCallArgs args)
      26             : {
      27           0 :   DOMString result;
      28           0 :   self->GetSelectorText(result);
      29           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      30           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      31           0 :     return false;
      32             :   }
      33           0 :   return true;
      34             : }
      35             : 
      36             : static bool
      37           0 : set_selectorText(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::BindingStyleRule* self, JSJitSetterCallArgs args)
      38             : {
      39           0 :   binding_detail::FakeString arg0;
      40           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
      41           0 :     return false;
      42             :   }
      43           0 :   self->SetSelectorText(NonNullHelper(Constify(arg0)));
      44           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      45             : 
      46           0 :   return true;
      47             : }
      48             : 
      49             : static const JSJitInfo selectorText_getterinfo = {
      50             :   { (JSJitGetterOp)get_selectorText },
      51             :   { prototypes::id::CSSStyleRule },
      52             :   { PrototypeTraits<prototypes::id::CSSStyleRule>::Depth },
      53             :   JSJitInfo::Getter,
      54             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      55             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      56             :   false,  /* isInfallible. False in setters. */
      57             :   false,  /* isMovable.  Not relevant for setters. */
      58             :   false, /* isEliminatable.  Not relevant for setters. */
      59             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      60             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      61             :   false,  /* isTypedMethod.  Only relevant for methods. */
      62             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      63             : };
      64             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      65             : static_assert(0 < 1, "There is no slot for us");
      66             : static const JSJitInfo selectorText_setterinfo = {
      67             :   { (JSJitGetterOp)set_selectorText },
      68             :   { prototypes::id::CSSStyleRule },
      69             :   { PrototypeTraits<prototypes::id::CSSStyleRule>::Depth },
      70             :   JSJitInfo::Setter,
      71             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      72             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
      73             :   false,  /* isInfallible. False in setters. */
      74             :   false,  /* isMovable.  Not relevant for setters. */
      75             :   false, /* isEliminatable.  Not relevant for setters. */
      76             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      77             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      78             :   false,  /* isTypedMethod.  Only relevant for methods. */
      79             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      80             : };
      81             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      82             : static_assert(0 < 1, "There is no slot for us");
      83             : 
      84             : static bool
      85           0 : get_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::BindingStyleRule* self, JSJitGetterCallArgs args)
      86             : {
      87           0 :   auto result(StrongOrRawPtr<nsICSSDeclaration>(self->Style()));
      88           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      89           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      90           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      91           0 :     return false;
      92             :   }
      93           0 :   return true;
      94             : }
      95             : 
      96             : static bool
      97           0 : set_style(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::BindingStyleRule* self, JSJitSetterCallArgs args)
      98             : {
      99           0 :   JS::Rooted<JS::Value> v(cx);
     100           0 :   if (!JS_GetProperty(cx, obj, "style", &v)) {
     101           0 :     return false;
     102             :   }
     103             : 
     104           0 :   if (!v.isObject()) {
     105           0 :     return ThrowErrorMessage(cx, MSG_NOT_OBJECT, "CSSStyleRule.style");
     106             :   }
     107             : 
     108           0 :   JS::Rooted<JSObject*> targetObj(cx, &v.toObject());
     109           0 :   return JS_SetProperty(cx, targetObj, "cssText", args[0]);
     110             : }
     111             : 
     112             : static const JSJitInfo style_getterinfo = {
     113             :   { (JSJitGetterOp)get_style },
     114             :   { prototypes::id::CSSStyleRule },
     115             :   { PrototypeTraits<prototypes::id::CSSStyleRule>::Depth },
     116             :   JSJitInfo::Getter,
     117             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     118             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     119             :   false,  /* isInfallible. False in setters. */
     120             :   true,  /* isMovable.  Not relevant for setters. */
     121             :   true, /* isEliminatable.  Not relevant for setters. */
     122             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     123             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     124             :   false,  /* isTypedMethod.  Only relevant for methods. */
     125             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     126             : };
     127             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     128             : static_assert(0 < 1, "There is no slot for us");
     129             : static const JSJitInfo style_setterinfo = {
     130             :   { (JSJitGetterOp)set_style },
     131             :   { prototypes::id::CSSStyleRule },
     132             :   { PrototypeTraits<prototypes::id::CSSStyleRule>::Depth },
     133             :   JSJitInfo::Setter,
     134             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     135             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     136             :   false,  /* isInfallible. False in setters. */
     137             :   false,  /* isMovable.  Not relevant for setters. */
     138             :   false, /* isEliminatable.  Not relevant for setters. */
     139             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     140             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     141             :   false,  /* isTypedMethod.  Only relevant for methods. */
     142             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     143             : };
     144             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     145             : static_assert(0 < 1, "There is no slot for us");
     146             : 
     147             : static bool
     148           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     149             : {
     150           0 :   mozilla::BindingStyleRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::BindingStyleRule>(obj);
     151             :   // We don't want to preserve if we don't have a wrapper, and we
     152             :   // obviously can't preserve if we're not initialized.
     153           0 :   if (self && self->GetWrapperPreserveColor()) {
     154           0 :     PreserveWrapper(self);
     155             :   }
     156           0 :   return true;
     157             : }
     158             : 
     159             : static void
     160           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     161             : {
     162           0 :   mozilla::BindingStyleRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::BindingStyleRule>(obj);
     163           0 :   if (self) {
     164           0 :     ClearWrapper(self, self, obj);
     165           0 :     AddForDeferredFinalization<mozilla::BindingStyleRule>(self);
     166             :   }
     167           0 : }
     168             : 
     169             : static void
     170           0 : _objectMoved(JSObject* obj, const JSObject* old)
     171             : {
     172           0 :   mozilla::BindingStyleRule* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::BindingStyleRule>(obj);
     173           0 :   if (self) {
     174           0 :     UpdateWrapper(self, self, obj, old);
     175             :   }
     176           0 : }
     177             : 
     178             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     179             : #if defined(__clang__)
     180             : #pragma clang diagnostic push
     181             : #pragma clang diagnostic ignored "-Wmissing-braces"
     182             : #endif
     183             : static const JSFunctionSpec sMethods_specs[] = {
     184             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
     185             :   JS_FS_END
     186             : };
     187             : #if defined(__clang__)
     188             : #pragma clang diagnostic pop
     189             : #endif
     190             : 
     191             : static PrefableDisablers sMethods_disablers0 = {
     192             :   true, false, 0, &WantsQueryInterface<mozilla::BindingStyleRule>::Enabled
     193             : };
     194             : 
     195             : // Can't be const because the pref-enabled boolean needs to be writable
     196             : static Prefable<const JSFunctionSpec> sMethods[] = {
     197             :   { &sMethods_disablers0, &sMethods_specs[0] },
     198             :   { nullptr, nullptr }
     199             : };
     200             : 
     201             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     202             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     203             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     204             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     205             : 
     206             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     207             : #if defined(__clang__)
     208             : #pragma clang diagnostic push
     209             : #pragma clang diagnostic ignored "-Wmissing-braces"
     210             : #endif
     211             : static const JSPropertySpec sAttributes_specs[] = {
     212             :   { "selectorText", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &selectorText_getterinfo, GenericBindingSetter, &selectorText_setterinfo },
     213             :   { "style", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &style_getterinfo, GenericBindingSetter, &style_setterinfo },
     214             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     215             : };
     216             : #if defined(__clang__)
     217             : #pragma clang diagnostic pop
     218             : #endif
     219             : 
     220             : 
     221             : // Can't be const because the pref-enabled boolean needs to be writable
     222             : static Prefable<const JSPropertySpec> sAttributes[] = {
     223             :   { nullptr, &sAttributes_specs[0] },
     224             :   { nullptr, nullptr }
     225             : };
     226             : 
     227             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     228             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     229             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     230             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     231             : 
     232             : 
     233             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
     234             : static PropertyInfo sNativeProperties_propertyInfos[3];
     235             : 
     236             : static const NativePropertiesN<2> sNativeProperties = {
     237             :   false, 0,
     238             :   false, 0,
     239             :   true,  0 /* sMethods */,
     240             :   true,  1 /* sAttributes */,
     241             :   false, 0,
     242             :   false, 0,
     243             :   false, 0,
     244             :   -1,
     245             :   3,
     246             :   sNativeProperties_sortedPropertyIndices,
     247             :   {
     248             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     249             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
     250             :   }
     251             : };
     252             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     253             :     "We have a property info count that is oversized");
     254             : 
     255             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     256             :   {
     257             :     "Function",
     258             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     259             :     &sBoringInterfaceObjectClassClassOps,
     260             :     JS_NULL_CLASS_SPEC,
     261             :     JS_NULL_CLASS_EXT,
     262             :     &sInterfaceObjectClassObjectOps
     263             :   },
     264             :   eInterface,
     265             :   true,
     266             :   prototypes::id::CSSStyleRule,
     267             :   PrototypeTraits<prototypes::id::CSSStyleRule>::Depth,
     268             :   sNativePropertyHooks,
     269             :   "function CSSStyleRule() {\n    [native code]\n}",
     270             :   CSSRuleBinding::GetConstructorObject
     271             : };
     272             : 
     273             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     274             :   {
     275             :     "CSSStyleRulePrototype",
     276             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     277             :     JS_NULL_CLASS_OPS,
     278             :     JS_NULL_CLASS_SPEC,
     279             :     JS_NULL_CLASS_EXT,
     280             :     JS_NULL_OBJECT_OPS
     281             :   },
     282             :   eInterfacePrototype,
     283             :   false,
     284             :   prototypes::id::CSSStyleRule,
     285             :   PrototypeTraits<prototypes::id::CSSStyleRule>::Depth,
     286             :   sNativePropertyHooks,
     287             :   "[object CSSStyleRulePrototype]",
     288             :   CSSRuleBinding::GetProtoObject
     289             : };
     290             : 
     291             : JSObject*
     292           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     293             : {
     294           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     295             : }
     296             : 
     297             : static const js::ClassOps sClassOps = {
     298             :   _addProperty, /* addProperty */
     299             :   nullptr,               /* delProperty */
     300             :   nullptr,               /* getProperty */
     301             :   nullptr,               /* setProperty */
     302             :   nullptr,               /* enumerate */
     303             :   nullptr, /* newEnumerate */
     304             :   nullptr, /* resolve */
     305             :   nullptr, /* mayResolve */
     306             :   _finalize, /* finalize */
     307             :   nullptr, /* call */
     308             :   nullptr,               /* hasInstance */
     309             :   nullptr,               /* construct */
     310             :   nullptr, /* trace */
     311             : };
     312             : 
     313             : static const js::ClassExtension sClassExtension = {
     314             :   nullptr, /* weakmapKeyDelegateOp */
     315             :   _objectMoved /* objectMovedOp */
     316             : };
     317             : 
     318             : static const DOMJSClass sClass = {
     319             :   { "CSSStyleRule",
     320             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     321             :     &sClassOps,
     322             :     JS_NULL_CLASS_SPEC,
     323             :     &sClassExtension,
     324             :     JS_NULL_OBJECT_OPS
     325             :   },
     326             :   { prototypes::id::CSSRule, prototypes::id::CSSStyleRule, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     327             :   IsBaseOf<nsISupports, mozilla::BindingStyleRule >::value,
     328             :   sNativePropertyHooks,
     329             :   FindAssociatedGlobalForNative<mozilla::BindingStyleRule>::Get,
     330             :   GetProtoObjectHandle,
     331             :   GetCCParticipant<mozilla::BindingStyleRule>::Get()
     332             : };
     333             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     334             :               "Must have the right minimal number of reserved slots.");
     335             : static_assert(1 >= 1,
     336             :               "Must have enough reserved slots.");
     337             : 
     338             : const JSClass*
     339           0 : GetJSClass()
     340             : {
     341           0 :   return sClass.ToJSClass();
     342             : }
     343             : 
     344             : bool
     345           0 : Wrap(JSContext* aCx, mozilla::BindingStyleRule* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     346             : {
     347             :   MOZ_ASSERT(static_cast<mozilla::BindingStyleRule*>(aObject) ==
     348             :              reinterpret_cast<mozilla::BindingStyleRule*>(aObject),
     349             :              "Multiple inheritance for mozilla::BindingStyleRule is broken.");
     350             :   MOZ_ASSERT(static_cast<mozilla::css::Rule*>(aObject) ==
     351             :              reinterpret_cast<mozilla::css::Rule*>(aObject),
     352             :              "Multiple inheritance for mozilla::css::Rule is broken.");
     353           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     354           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     355           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     356             :              "You should probably not be using Wrap() directly; use "
     357             :              "GetOrCreateDOMReflector instead");
     358             : 
     359           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     360             :              "nsISupports must be on our primary inheritance chain");
     361             : 
     362           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     363           0 :   if (!global) {
     364           0 :     return false;
     365             :   }
     366           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     367           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     368             : 
     369             :   // That might have ended up wrapping us already, due to the wonders
     370             :   // of XBL.  Check for that, and bail out as needed.
     371           0 :   aReflector.set(aCache->GetWrapper());
     372           0 :   if (aReflector) {
     373             : #ifdef DEBUG
     374           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     375             : #endif // DEBUG
     376           0 :     return true;
     377             :   }
     378             : 
     379           0 :   JSAutoCompartment ac(aCx, global);
     380           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     381           0 :   if (!canonicalProto) {
     382           0 :     return false;
     383             :   }
     384           0 :   JS::Rooted<JSObject*> proto(aCx);
     385           0 :   if (aGivenProto) {
     386           0 :     proto = aGivenProto;
     387             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     388             :     // coming in, we changed compartments to that of "parent" so may need
     389             :     // to wrap the proto here.
     390           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     391           0 :       if (!JS_WrapObject(aCx, &proto)) {
     392           0 :         return false;
     393             :       }
     394             :     }
     395             :   } else {
     396           0 :     proto = canonicalProto;
     397             :   }
     398             : 
     399           0 :   BindingJSObjectCreator<mozilla::BindingStyleRule> creator(aCx);
     400           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     401           0 :   if (!aReflector) {
     402           0 :     return false;
     403             :   }
     404             : 
     405           0 :   aCache->SetWrapper(aReflector);
     406           0 :   creator.InitializationSucceeded();
     407             : 
     408           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     409             :              aCache->GetWrapperPreserveColor() == aReflector);
     410             :   // If proto != canonicalProto, we have to preserve our wrapper;
     411             :   // otherwise we won't be able to properly recreate it later, since
     412             :   // we won't know what proto to use.  Note that we don't check
     413             :   // aGivenProto here, since it's entirely possible (and even
     414             :   // somewhat common) to have a non-null aGivenProto which is the
     415             :   // same as canonicalProto.
     416           0 :   if (proto != canonicalProto) {
     417           0 :     PreserveWrapper(aObject);
     418             :   }
     419             : 
     420           0 :   return true;
     421             : }
     422             : 
     423             : const NativePropertyHooks sNativePropertyHooks[] = { {
     424             :   nullptr,
     425             :   nullptr,
     426             :   nullptr,
     427             :   { sNativeProperties.Upcast(), nullptr },
     428             :   prototypes::id::CSSStyleRule,
     429             :   constructors::id::CSSStyleRule,
     430             :   CSSRuleBinding::sNativePropertyHooks,
     431             :   &DefaultXrayExpandoObjectClass
     432             : } };
     433             : 
     434             : void
     435           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     436             : {
     437           0 :   JS::Handle<JSObject*> parentProto(CSSRuleBinding::GetProtoObjectHandle(aCx));
     438           0 :   if (!parentProto) {
     439           0 :     return;
     440             :   }
     441             : 
     442           0 :   JS::Handle<JSObject*> constructorProto(CSSRuleBinding::GetConstructorObjectHandle(aCx));
     443           0 :   if (!constructorProto) {
     444           0 :     return;
     445             :   }
     446             : 
     447             :   static bool sIdsInited = false;
     448           0 :   if (!sIdsInited && NS_IsMainThread()) {
     449           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     450           0 :       return;
     451             :     }
     452           0 :     sIdsInited = true;
     453             :   }
     454             : 
     455           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CSSStyleRule);
     456           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CSSStyleRule);
     457           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     458             :                               &sPrototypeClass.mBase, protoCache,
     459             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     460             :                               interfaceCache,
     461             :                               sNativeProperties.Upcast(),
     462             :                               nullptr,
     463             :                               "CSSStyleRule", aDefineOnGlobal,
     464             :                               nullptr,
     465           0 :                               false);
     466             : }
     467             : 
     468             : JS::Handle<JSObject*>
     469           0 : GetProtoObjectHandle(JSContext* aCx)
     470             : {
     471             :   /* Get the interface prototype object for this class.  This will create the
     472             :      object as needed. */
     473           0 :   bool aDefineOnGlobal = true;
     474             : 
     475             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     476           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     477           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     478           0 :     return nullptr;
     479             :   }
     480             : 
     481             :   /* Check to see whether the interface objects are already installed */
     482           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     483           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CSSStyleRule)) {
     484           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     485           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     486             :   }
     487             : 
     488             :   /*
     489             :    * The object might _still_ be null, but that's OK.
     490             :    *
     491             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     492             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     493             :    * changed after they have been set.
     494             :    *
     495             :    * Calling address() avoids the read read barrier that does gray
     496             :    * unmarking, but it's not possible for the object to be gray here.
     497             :    */
     498             : 
     499           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CSSStyleRule);
     500           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     501           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     502             : }
     503             : 
     504             : JS::Handle<JSObject*>
     505           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     506             : {
     507             :   /* Get the interface object for this class.  This will create the object as
     508             :      needed. */
     509             : 
     510             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     511           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     512           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     513           0 :     return nullptr;
     514             :   }
     515             : 
     516             :   /* Check to see whether the interface objects are already installed */
     517           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     518           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CSSStyleRule)) {
     519           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     520           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     521             :   }
     522             : 
     523             :   /*
     524             :    * The object might _still_ be null, but that's OK.
     525             :    *
     526             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     527             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     528             :    * changed after they have been set.
     529             :    *
     530             :    * Calling address() avoids the read read barrier that does gray
     531             :    * unmarking, but it's not possible for the object to be gray here.
     532             :    */
     533             : 
     534           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CSSStyleRule);
     535           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     536           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     537             : }
     538             : 
     539             : JSObject*
     540           0 : GetConstructorObject(JSContext* aCx)
     541             : {
     542           0 :   return GetConstructorObjectHandle(aCx);
     543             : }
     544             : 
     545             : } // namespace CSSStyleRuleBinding
     546             : 
     547             : 
     548             : 
     549             : } // namespace dom
     550             : } // namespace mozilla

Generated by: LCOV version 1.13