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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM StyleSheet.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "StyleSheetBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/StyleSheetInlines.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/MediaList.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/Nullable.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : #include "nsContentUtils.h"
      15             : #include "nsINode.h"
      16             : #include "nsISupports.h"
      17             : #include "xpcjsid.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace StyleSheetBinding {
      23             : 
      24             : static bool
      25           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
      26             : {
      27           0 :   DOMString result;
      28           0 :   self->GetType(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 const JSJitInfo type_getterinfo = {
      37             :   { (JSJitGetterOp)get_type },
      38             :   { prototypes::id::StyleSheet },
      39             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
      40             :   JSJitInfo::Getter,
      41             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      42             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      43             :   false,  /* isInfallible. False in setters. */
      44             :   true,  /* isMovable.  Not relevant for setters. */
      45             :   true, /* isEliminatable.  Not relevant for setters. */
      46             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      47             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      48             :   false,  /* isTypedMethod.  Only relevant for methods. */
      49             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      50             : };
      51             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      52             : static_assert(0 < 1, "There is no slot for us");
      53             : 
      54             : static bool
      55           0 : get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
      56             : {
      57           0 :   DOMString result;
      58           0 :   self->GetHref(result);
      59           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      60           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
      61           0 :     return false;
      62             :   }
      63           0 :   return true;
      64             : }
      65             : 
      66             : static const JSJitInfo href_getterinfo = {
      67             :   { (JSJitGetterOp)get_href },
      68             :   { prototypes::id::StyleSheet },
      69             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
      70             :   JSJitInfo::Getter,
      71             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      72             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      73             :   false,  /* isInfallible. False in setters. */
      74             :   true,  /* isMovable.  Not relevant for setters. */
      75             :   true, /* 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_ownerNode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
      86             : {
      87           0 :   auto result(StrongOrRawPtr<nsINode>(self->GetOwnerNode()));
      88           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      89           0 :   if (!result) {
      90           0 :     args.rval().setNull();
      91           0 :     return true;
      92             :   }
      93           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      94           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      95           0 :     return false;
      96             :   }
      97           0 :   return true;
      98             : }
      99             : 
     100             : static const JSJitInfo ownerNode_getterinfo = {
     101             :   { (JSJitGetterOp)get_ownerNode },
     102             :   { prototypes::id::StyleSheet },
     103             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     104             :   JSJitInfo::Getter,
     105             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     106             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     107             :   false,  /* isInfallible. False in setters. */
     108             :   true,  /* isMovable.  Not relevant for setters. */
     109             :   true, /* isEliminatable.  Not relevant for setters. */
     110             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     111             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     112             :   false,  /* isTypedMethod.  Only relevant for methods. */
     113             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     114             : };
     115             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     116             : static_assert(0 < 1, "There is no slot for us");
     117             : 
     118             : static bool
     119           0 : get_parentStyleSheet(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
     120             : {
     121           0 :   auto result(StrongOrRawPtr<mozilla::StyleSheet>(self->GetParentStyleSheet()));
     122           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     123           0 :   if (!result) {
     124           0 :     args.rval().setNull();
     125           0 :     return true;
     126             :   }
     127           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     128           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     129           0 :     return false;
     130             :   }
     131           0 :   return true;
     132             : }
     133             : 
     134             : static const JSJitInfo parentStyleSheet_getterinfo = {
     135             :   { (JSJitGetterOp)get_parentStyleSheet },
     136             :   { prototypes::id::StyleSheet },
     137             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     138             :   JSJitInfo::Getter,
     139             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     140             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     141             :   false,  /* isInfallible. False in setters. */
     142             :   true,  /* isMovable.  Not relevant for setters. */
     143             :   true, /* isEliminatable.  Not relevant for setters. */
     144             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     145             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     146             :   false,  /* isTypedMethod.  Only relevant for methods. */
     147             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     148             : };
     149             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     150             : static_assert(0 < 1, "There is no slot for us");
     151             : 
     152             : static bool
     153           0 : get_title(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
     154             : {
     155           0 :   DOMString result;
     156           0 :   self->GetTitle(result);
     157           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     158           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
     159           0 :     return false;
     160             :   }
     161           0 :   return true;
     162             : }
     163             : 
     164             : static const JSJitInfo title_getterinfo = {
     165             :   { (JSJitGetterOp)get_title },
     166             :   { prototypes::id::StyleSheet },
     167             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     168             :   JSJitInfo::Getter,
     169             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     170             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     171             :   false,  /* isInfallible. False in setters. */
     172             :   true,  /* isMovable.  Not relevant for setters. */
     173             :   true, /* isEliminatable.  Not relevant for setters. */
     174             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     175             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     176             :   false,  /* isTypedMethod.  Only relevant for methods. */
     177             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     178             : };
     179             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     180             : static_assert(0 < 1, "There is no slot for us");
     181             : 
     182             : static bool
     183           0 : get_media(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
     184             : {
     185           0 :   auto result(StrongOrRawPtr<mozilla::dom::MediaList>(self->Media()));
     186           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     187           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     188           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     189           0 :     return false;
     190             :   }
     191           0 :   return true;
     192             : }
     193             : 
     194             : static const JSJitInfo media_getterinfo = {
     195             :   { (JSJitGetterOp)get_media },
     196             :   { prototypes::id::StyleSheet },
     197             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     198             :   JSJitInfo::Getter,
     199             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     200             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     201             :   false,  /* isInfallible. False in setters. */
     202             :   true,  /* isMovable.  Not relevant for setters. */
     203             :   true, /* isEliminatable.  Not relevant for setters. */
     204             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     205             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     206             :   false,  /* isTypedMethod.  Only relevant for methods. */
     207             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     208             : };
     209             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     210             : static_assert(0 < 1, "There is no slot for us");
     211             : 
     212             : static bool
     213           0 : get_disabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
     214             : {
     215           0 :   bool result(self->Disabled());
     216           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     217           0 :   args.rval().setBoolean(result);
     218           0 :   return true;
     219             : }
     220             : 
     221             : static bool
     222           0 : set_disabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitSetterCallArgs args)
     223             : {
     224             :   bool arg0;
     225           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
     226           0 :     return false;
     227             :   }
     228           0 :   self->SetDisabled(arg0);
     229           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     230             : 
     231           0 :   return true;
     232             : }
     233             : 
     234             : static const JSJitInfo disabled_getterinfo = {
     235             :   { (JSJitGetterOp)get_disabled },
     236             :   { prototypes::id::StyleSheet },
     237             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     238             :   JSJitInfo::Getter,
     239             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     240             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     241             :   true,  /* isInfallible. False in setters. */
     242             :   true,  /* isMovable.  Not relevant for setters. */
     243             :   true, /* isEliminatable.  Not relevant for setters. */
     244             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     245             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     246             :   false,  /* isTypedMethod.  Only relevant for methods. */
     247             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     248             : };
     249             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     250             : static_assert(0 < 1, "There is no slot for us");
     251             : static const JSJitInfo disabled_setterinfo = {
     252             :   { (JSJitGetterOp)set_disabled },
     253             :   { prototypes::id::StyleSheet },
     254             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     255             :   JSJitInfo::Setter,
     256             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     257             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     258             :   false,  /* isInfallible. False in setters. */
     259             :   false,  /* isMovable.  Not relevant for setters. */
     260             :   false, /* isEliminatable.  Not relevant for setters. */
     261             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     262             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     263             :   false,  /* isTypedMethod.  Only relevant for methods. */
     264             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     265             : };
     266             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     267             : static_assert(0 < 1, "There is no slot for us");
     268             : 
     269             : static bool
     270           0 : get_sourceMapURL(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::StyleSheet* self, JSJitGetterCallArgs args)
     271             : {
     272           0 :   DOMString result;
     273           0 :   self->GetSourceMapURL(result);
     274           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     275           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     276           0 :     return false;
     277             :   }
     278           0 :   return true;
     279             : }
     280             : 
     281             : static const JSJitInfo sourceMapURL_getterinfo = {
     282             :   { (JSJitGetterOp)get_sourceMapURL },
     283             :   { prototypes::id::StyleSheet },
     284             :   { PrototypeTraits<prototypes::id::StyleSheet>::Depth },
     285             :   JSJitInfo::Getter,
     286             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     287             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     288             :   false,  /* isInfallible. False in setters. */
     289             :   true,  /* isMovable.  Not relevant for setters. */
     290             :   true, /* isEliminatable.  Not relevant for setters. */
     291             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     292             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     293             :   false,  /* isTypedMethod.  Only relevant for methods. */
     294             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     295             : };
     296             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     297             : static_assert(0 < 1, "There is no slot for us");
     298             : 
     299             : static bool
     300           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     301             : {
     302           0 :   mozilla::StyleSheet* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::StyleSheet>(obj);
     303             :   // We don't want to preserve if we don't have a wrapper, and we
     304             :   // obviously can't preserve if we're not initialized.
     305           0 :   if (self && self->GetWrapperPreserveColor()) {
     306           0 :     PreserveWrapper(self);
     307             :   }
     308           0 :   return true;
     309             : }
     310             : 
     311             : static void
     312           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     313             : {
     314           0 :   mozilla::StyleSheet* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::StyleSheet>(obj);
     315           0 :   if (self) {
     316           0 :     ClearWrapper(self, self, obj);
     317           0 :     AddForDeferredFinalization<mozilla::StyleSheet>(self);
     318             :   }
     319           0 : }
     320             : 
     321             : static void
     322           0 : _objectMoved(JSObject* obj, const JSObject* old)
     323             : {
     324           0 :   mozilla::StyleSheet* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::StyleSheet>(obj);
     325           0 :   if (self) {
     326           0 :     UpdateWrapper(self, self, obj, old);
     327             :   }
     328           0 : }
     329             : 
     330             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     331             : #if defined(__clang__)
     332             : #pragma clang diagnostic push
     333             : #pragma clang diagnostic ignored "-Wmissing-braces"
     334             : #endif
     335             : static const JSFunctionSpec sMethods_specs[] = {
     336             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
     337             :   JS_FS_END
     338             : };
     339             : #if defined(__clang__)
     340             : #pragma clang diagnostic pop
     341             : #endif
     342             : 
     343             : static PrefableDisablers sMethods_disablers0 = {
     344             :   true, false, 0, &WantsQueryInterface<mozilla::StyleSheet>::Enabled
     345             : };
     346             : 
     347             : // Can't be const because the pref-enabled boolean needs to be writable
     348             : static Prefable<const JSFunctionSpec> sMethods[] = {
     349             :   { &sMethods_disablers0, &sMethods_specs[0] },
     350             :   { nullptr, nullptr }
     351             : };
     352             : 
     353             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     354             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     355             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     356             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     357             : 
     358             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     359             : #if defined(__clang__)
     360             : #pragma clang diagnostic push
     361             : #pragma clang diagnostic ignored "-Wmissing-braces"
     362             : #endif
     363             : static const JSPropertySpec sAttributes_specs[] = {
     364             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
     365             :   { "href", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &href_getterinfo, nullptr, nullptr },
     366             :   { "ownerNode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &ownerNode_getterinfo, nullptr, nullptr },
     367             :   { "parentStyleSheet", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &parentStyleSheet_getterinfo, nullptr, nullptr },
     368             :   { "title", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &title_getterinfo, nullptr, nullptr },
     369             :   { "media", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &media_getterinfo, nullptr, nullptr },
     370             :   { "disabled", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &disabled_getterinfo, GenericBindingSetter, &disabled_setterinfo },
     371             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     372             : };
     373             : #if defined(__clang__)
     374             : #pragma clang diagnostic pop
     375             : #endif
     376             : 
     377             : 
     378             : // Can't be const because the pref-enabled boolean needs to be writable
     379             : static Prefable<const JSPropertySpec> sAttributes[] = {
     380             :   { nullptr, &sAttributes_specs[0] },
     381             :   { nullptr, nullptr }
     382             : };
     383             : 
     384             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     385             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     386             : static_assert(7 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     387             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     388             : 
     389             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     390             : #if defined(__clang__)
     391             : #pragma clang diagnostic push
     392             : #pragma clang diagnostic ignored "-Wmissing-braces"
     393             : #endif
     394             : static const JSPropertySpec sChromeAttributes_specs[] = {
     395             :   { "sourceMapURL", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sourceMapURL_getterinfo, nullptr, nullptr },
     396             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     397             : };
     398             : #if defined(__clang__)
     399             : #pragma clang diagnostic pop
     400             : #endif
     401             : 
     402             : 
     403             : // Can't be const because the pref-enabled boolean needs to be writable
     404             : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
     405             :   { nullptr, &sChromeAttributes_specs[0] },
     406             :   { nullptr, nullptr }
     407             : };
     408             : 
     409             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     410             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     411             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     412             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     413             : 
     414             : 
     415             : static uint16_t sNativeProperties_sortedPropertyIndices[8];
     416             : static PropertyInfo sNativeProperties_propertyInfos[8];
     417             : 
     418             : static const NativePropertiesN<2> sNativeProperties = {
     419             :   false, 0,
     420             :   false, 0,
     421             :   true,  0 /* sMethods */,
     422             :   true,  1 /* sAttributes */,
     423             :   false, 0,
     424             :   false, 0,
     425             :   false, 0,
     426             :   -1,
     427             :   8,
     428             :   sNativeProperties_sortedPropertyIndices,
     429             :   {
     430             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     431             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
     432             :   }
     433             : };
     434             : static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     435             :     "We have a property info count that is oversized");
     436             : 
     437             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
     438             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
     439             : 
     440             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
     441             :   false, 0,
     442             :   false, 0,
     443             :   false, 0,
     444             :   true,  0 /* sChromeAttributes */,
     445             :   false, 0,
     446             :   false, 0,
     447             :   false, 0,
     448             :   -1,
     449             :   1,
     450             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
     451             :   {
     452             :     { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
     453             :   }
     454             : };
     455             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
     456             :     "We have a property info count that is oversized");
     457             : 
     458             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     459             :   {
     460             :     "Function",
     461             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     462             :     &sBoringInterfaceObjectClassClassOps,
     463             :     JS_NULL_CLASS_SPEC,
     464             :     JS_NULL_CLASS_EXT,
     465             :     &sInterfaceObjectClassObjectOps
     466             :   },
     467             :   eInterface,
     468             :   true,
     469             :   prototypes::id::StyleSheet,
     470             :   PrototypeTraits<prototypes::id::StyleSheet>::Depth,
     471             :   sNativePropertyHooks,
     472             :   "function StyleSheet() {\n    [native code]\n}",
     473             :   JS::GetRealmFunctionPrototype
     474             : };
     475             : 
     476             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     477             :   {
     478             :     "StyleSheetPrototype",
     479             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     480             :     JS_NULL_CLASS_OPS,
     481             :     JS_NULL_CLASS_SPEC,
     482             :     JS_NULL_CLASS_EXT,
     483             :     JS_NULL_OBJECT_OPS
     484             :   },
     485             :   eInterfacePrototype,
     486             :   false,
     487             :   prototypes::id::StyleSheet,
     488             :   PrototypeTraits<prototypes::id::StyleSheet>::Depth,
     489             :   sNativePropertyHooks,
     490             :   "[object StyleSheetPrototype]",
     491             :   JS::GetRealmObjectPrototype
     492             : };
     493             : 
     494             : JSObject*
     495           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     496             : {
     497           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     498             : }
     499             : 
     500             : static const js::ClassOps sClassOps = {
     501             :   _addProperty, /* addProperty */
     502             :   nullptr,               /* delProperty */
     503             :   nullptr,               /* getProperty */
     504             :   nullptr,               /* setProperty */
     505             :   nullptr,               /* enumerate */
     506             :   nullptr, /* newEnumerate */
     507             :   nullptr, /* resolve */
     508             :   nullptr, /* mayResolve */
     509             :   _finalize, /* finalize */
     510             :   nullptr, /* call */
     511             :   nullptr,               /* hasInstance */
     512             :   nullptr,               /* construct */
     513             :   nullptr, /* trace */
     514             : };
     515             : 
     516             : static const js::ClassExtension sClassExtension = {
     517             :   nullptr, /* weakmapKeyDelegateOp */
     518             :   _objectMoved /* objectMovedOp */
     519             : };
     520             : 
     521             : static const DOMJSClass sClass = {
     522             :   { "StyleSheet",
     523             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     524             :     &sClassOps,
     525             :     JS_NULL_CLASS_SPEC,
     526             :     &sClassExtension,
     527             :     JS_NULL_OBJECT_OPS
     528             :   },
     529             :   { prototypes::id::StyleSheet, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     530             :   IsBaseOf<nsISupports, mozilla::StyleSheet >::value,
     531             :   sNativePropertyHooks,
     532             :   FindAssociatedGlobalForNative<mozilla::StyleSheet>::Get,
     533             :   GetProtoObjectHandle,
     534             :   GetCCParticipant<mozilla::StyleSheet>::Get()
     535             : };
     536             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     537             :               "Must have the right minimal number of reserved slots.");
     538             : static_assert(1 >= 1,
     539             :               "Must have enough reserved slots.");
     540             : 
     541             : const JSClass*
     542           0 : GetJSClass()
     543             : {
     544           0 :   return sClass.ToJSClass();
     545             : }
     546             : 
     547             : bool
     548           0 : Wrap(JSContext* aCx, mozilla::StyleSheet* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     549             : {
     550             :   MOZ_ASSERT(static_cast<mozilla::StyleSheet*>(aObject) ==
     551             :              reinterpret_cast<mozilla::StyleSheet*>(aObject),
     552             :              "Multiple inheritance for mozilla::StyleSheet is broken.");
     553           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     554           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     555           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     556             :              "You should probably not be using Wrap() directly; use "
     557             :              "GetOrCreateDOMReflector instead");
     558             : 
     559           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     560             :              "nsISupports must be on our primary inheritance chain");
     561             : 
     562           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     563           0 :   if (!global) {
     564           0 :     return false;
     565             :   }
     566           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     567           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     568             : 
     569             :   // That might have ended up wrapping us already, due to the wonders
     570             :   // of XBL.  Check for that, and bail out as needed.
     571           0 :   aReflector.set(aCache->GetWrapper());
     572           0 :   if (aReflector) {
     573             : #ifdef DEBUG
     574           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     575             : #endif // DEBUG
     576           0 :     return true;
     577             :   }
     578             : 
     579           0 :   JSAutoCompartment ac(aCx, global);
     580           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     581           0 :   if (!canonicalProto) {
     582           0 :     return false;
     583             :   }
     584           0 :   JS::Rooted<JSObject*> proto(aCx);
     585           0 :   if (aGivenProto) {
     586           0 :     proto = aGivenProto;
     587             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     588             :     // coming in, we changed compartments to that of "parent" so may need
     589             :     // to wrap the proto here.
     590           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     591           0 :       if (!JS_WrapObject(aCx, &proto)) {
     592           0 :         return false;
     593             :       }
     594             :     }
     595             :   } else {
     596           0 :     proto = canonicalProto;
     597             :   }
     598             : 
     599           0 :   BindingJSObjectCreator<mozilla::StyleSheet> creator(aCx);
     600           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     601           0 :   if (!aReflector) {
     602           0 :     return false;
     603             :   }
     604             : 
     605           0 :   aCache->SetWrapper(aReflector);
     606           0 :   creator.InitializationSucceeded();
     607             : 
     608           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     609             :              aCache->GetWrapperPreserveColor() == aReflector);
     610             :   // If proto != canonicalProto, we have to preserve our wrapper;
     611             :   // otherwise we won't be able to properly recreate it later, since
     612             :   // we won't know what proto to use.  Note that we don't check
     613             :   // aGivenProto here, since it's entirely possible (and even
     614             :   // somewhat common) to have a non-null aGivenProto which is the
     615             :   // same as canonicalProto.
     616           0 :   if (proto != canonicalProto) {
     617           0 :     PreserveWrapper(aObject);
     618             :   }
     619             : 
     620           0 :   return true;
     621             : }
     622             : 
     623             : const NativePropertyHooks sNativePropertyHooks[] = { {
     624             :   nullptr,
     625             :   nullptr,
     626             :   nullptr,
     627             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
     628             :   prototypes::id::StyleSheet,
     629             :   constructors::id::StyleSheet,
     630             :   nullptr,
     631             :   &DefaultXrayExpandoObjectClass
     632             : } };
     633             : 
     634             : void
     635           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     636             : {
     637           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     638           0 :   if (!parentProto) {
     639           0 :     return;
     640             :   }
     641             : 
     642           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     643           0 :   if (!constructorProto) {
     644           0 :     return;
     645             :   }
     646             : 
     647             :   static bool sIdsInited = false;
     648           0 :   if (!sIdsInited && NS_IsMainThread()) {
     649           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     650           0 :       return;
     651             :     }
     652           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
     653           0 :       return;
     654             :     }
     655           0 :     sIdsInited = true;
     656             :   }
     657             : 
     658           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::StyleSheet);
     659           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::StyleSheet);
     660           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     661             :                               &sPrototypeClass.mBase, protoCache,
     662             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     663             :                               interfaceCache,
     664             :                               sNativeProperties.Upcast(),
     665           0 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
     666             :                               "StyleSheet", aDefineOnGlobal,
     667             :                               nullptr,
     668           0 :                               false);
     669             : }
     670             : 
     671             : JS::Handle<JSObject*>
     672           0 : GetProtoObjectHandle(JSContext* aCx)
     673             : {
     674             :   /* Get the interface prototype object for this class.  This will create the
     675             :      object as needed. */
     676           0 :   bool aDefineOnGlobal = true;
     677             : 
     678             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     679           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     680           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     681           0 :     return nullptr;
     682             :   }
     683             : 
     684             :   /* Check to see whether the interface objects are already installed */
     685           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     686           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::StyleSheet)) {
     687           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     688           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     689             :   }
     690             : 
     691             :   /*
     692             :    * The object might _still_ be null, but that's OK.
     693             :    *
     694             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     695             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     696             :    * changed after they have been set.
     697             :    *
     698             :    * Calling address() avoids the read read barrier that does gray
     699             :    * unmarking, but it's not possible for the object to be gray here.
     700             :    */
     701             : 
     702           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::StyleSheet);
     703           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     704           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     705             : }
     706             : 
     707             : JSObject*
     708           0 : GetProtoObject(JSContext* aCx)
     709             : {
     710           0 :   return GetProtoObjectHandle(aCx);
     711             : }
     712             : 
     713             : JS::Handle<JSObject*>
     714           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     715             : {
     716             :   /* Get the interface object for this class.  This will create the object as
     717             :      needed. */
     718             : 
     719             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     720           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     721           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     722           0 :     return nullptr;
     723             :   }
     724             : 
     725             :   /* Check to see whether the interface objects are already installed */
     726           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     727           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::StyleSheet)) {
     728           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     729           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     730             :   }
     731             : 
     732             :   /*
     733             :    * The object might _still_ be null, but that's OK.
     734             :    *
     735             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     736             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     737             :    * changed after they have been set.
     738             :    *
     739             :    * Calling address() avoids the read read barrier that does gray
     740             :    * unmarking, but it's not possible for the object to be gray here.
     741             :    */
     742             : 
     743           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::StyleSheet);
     744           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     745           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     746             : }
     747             : 
     748             : JSObject*
     749           0 : GetConstructorObject(JSContext* aCx)
     750             : {
     751           0 :   return GetConstructorObjectHandle(aCx);
     752             : }
     753             : 
     754             : } // namespace StyleSheetBinding
     755             : 
     756             : 
     757             : 
     758             : } // namespace dom
     759             : } // namespace mozilla

Generated by: LCOV version 1.13