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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM SVGUseElement.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "SVGGraphicsElementBinding.h"
       4             : #include "SVGUseElementBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      10             : #include "mozilla/dom/SVGAnimatedLength.h"
      11             : #include "mozilla/dom/SVGAnimatedString.h"
      12             : #include "mozilla/dom/SVGUseElement.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : namespace SVGUseElementBinding {
      19             : 
      20             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<SVGGraphicsElementBinding::NativeType>::value,
      21             :               "Can't inherit from an interface with a different ownership model.");
      22             : 
      23             : static bool
      24           0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGUseElement* self, JSJitGetterCallArgs args)
      25             : {
      26           0 :   auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->X()));
      27           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      28           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      29           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      30           0 :     return false;
      31             :   }
      32           0 :   return true;
      33             : }
      34             : 
      35             : static const JSJitInfo x_getterinfo = {
      36             :   { (JSJitGetterOp)get_x },
      37             :   { prototypes::id::SVGUseElement },
      38             :   { PrototypeTraits<prototypes::id::SVGUseElement>::Depth },
      39             :   JSJitInfo::Getter,
      40             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      41             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      42             :   false,  /* isInfallible. False in setters. */
      43             :   true,  /* isMovable.  Not relevant for setters. */
      44             :   true, /* isEliminatable.  Not relevant for setters. */
      45             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      46             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      47             :   false,  /* isTypedMethod.  Only relevant for methods. */
      48             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      49             : };
      50             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      51             : static_assert(0 < 1, "There is no slot for us");
      52             : 
      53             : static bool
      54           0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGUseElement* self, JSJitGetterCallArgs args)
      55             : {
      56           0 :   auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Y()));
      57           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      58           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      59           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      60           0 :     return false;
      61             :   }
      62           0 :   return true;
      63             : }
      64             : 
      65             : static const JSJitInfo y_getterinfo = {
      66             :   { (JSJitGetterOp)get_y },
      67             :   { prototypes::id::SVGUseElement },
      68             :   { PrototypeTraits<prototypes::id::SVGUseElement>::Depth },
      69             :   JSJitInfo::Getter,
      70             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      71             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      72             :   false,  /* isInfallible. False in setters. */
      73             :   true,  /* isMovable.  Not relevant for setters. */
      74             :   true, /* isEliminatable.  Not relevant for setters. */
      75             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      76             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      77             :   false,  /* isTypedMethod.  Only relevant for methods. */
      78             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      79             : };
      80             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      81             : static_assert(0 < 1, "There is no slot for us");
      82             : 
      83             : static bool
      84           0 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGUseElement* self, JSJitGetterCallArgs args)
      85             : {
      86           0 :   auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Width()));
      87           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      88           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      89           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      90           0 :     return false;
      91             :   }
      92           0 :   return true;
      93             : }
      94             : 
      95             : static const JSJitInfo width_getterinfo = {
      96             :   { (JSJitGetterOp)get_width },
      97             :   { prototypes::id::SVGUseElement },
      98             :   { PrototypeTraits<prototypes::id::SVGUseElement>::Depth },
      99             :   JSJitInfo::Getter,
     100             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     101             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     102             :   false,  /* isInfallible. False in setters. */
     103             :   true,  /* isMovable.  Not relevant for setters. */
     104             :   true, /* isEliminatable.  Not relevant for setters. */
     105             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     106             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     107             :   false,  /* isTypedMethod.  Only relevant for methods. */
     108             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     109             : };
     110             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     111             : static_assert(0 < 1, "There is no slot for us");
     112             : 
     113             : static bool
     114           0 : get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGUseElement* self, JSJitGetterCallArgs args)
     115             : {
     116           0 :   auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedLength>(self->Height()));
     117           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     118           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     119           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     120           0 :     return false;
     121             :   }
     122           0 :   return true;
     123             : }
     124             : 
     125             : static const JSJitInfo height_getterinfo = {
     126             :   { (JSJitGetterOp)get_height },
     127             :   { prototypes::id::SVGUseElement },
     128             :   { PrototypeTraits<prototypes::id::SVGUseElement>::Depth },
     129             :   JSJitInfo::Getter,
     130             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     131             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     132             :   false,  /* isInfallible. False in setters. */
     133             :   true,  /* isMovable.  Not relevant for setters. */
     134             :   true, /* isEliminatable.  Not relevant for setters. */
     135             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     136             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     137             :   false,  /* isTypedMethod.  Only relevant for methods. */
     138             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     139             : };
     140             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     141             : static_assert(0 < 1, "There is no slot for us");
     142             : 
     143             : static bool
     144           0 : get_href(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::SVGUseElement* self, JSJitGetterCallArgs args)
     145             : {
     146           0 :   auto result(StrongOrRawPtr<mozilla::dom::SVGAnimatedString>(self->Href()));
     147           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     148           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     149           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     150           0 :     return false;
     151             :   }
     152           0 :   return true;
     153             : }
     154             : 
     155             : static const JSJitInfo href_getterinfo = {
     156             :   { (JSJitGetterOp)get_href },
     157             :   { prototypes::id::SVGUseElement },
     158             :   { PrototypeTraits<prototypes::id::SVGUseElement>::Depth },
     159             :   JSJitInfo::Getter,
     160             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     161             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     162             :   false,  /* isInfallible. False in setters. */
     163             :   true,  /* isMovable.  Not relevant for setters. */
     164             :   true, /* isEliminatable.  Not relevant for setters. */
     165             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     166             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     167             :   false,  /* isTypedMethod.  Only relevant for methods. */
     168             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     169             : };
     170             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     171             : static_assert(0 < 1, "There is no slot for us");
     172             : 
     173             : static bool
     174           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     175             : {
     176           0 :   mozilla::dom::SVGUseElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGUseElement>(obj);
     177             :   // We don't want to preserve if we don't have a wrapper, and we
     178             :   // obviously can't preserve if we're not initialized.
     179           0 :   if (self && self->GetWrapperPreserveColor()) {
     180           0 :     PreserveWrapper(self);
     181             :   }
     182           0 :   return true;
     183             : }
     184             : 
     185             : static void
     186           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     187             : {
     188           0 :   mozilla::dom::SVGUseElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGUseElement>(obj);
     189           0 :   if (self) {
     190           0 :     ClearWrapper(self, self, obj);
     191           0 :     AddForDeferredFinalization<mozilla::dom::SVGUseElement>(self);
     192             :   }
     193           0 : }
     194             : 
     195             : static void
     196           0 : _objectMoved(JSObject* obj, const JSObject* old)
     197             : {
     198           0 :   mozilla::dom::SVGUseElement* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::SVGUseElement>(obj);
     199           0 :   if (self) {
     200           0 :     UpdateWrapper(self, self, obj, old);
     201             :   }
     202           0 : }
     203             : 
     204             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     205             : #if defined(__clang__)
     206             : #pragma clang diagnostic push
     207             : #pragma clang diagnostic ignored "-Wmissing-braces"
     208             : #endif
     209             : static const JSPropertySpec sAttributes_specs[] = {
     210             :   { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, nullptr, nullptr },
     211             :   { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, nullptr, nullptr },
     212             :   { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, nullptr, nullptr },
     213             :   { "height", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &height_getterinfo, nullptr, nullptr },
     214             :   { "href", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &href_getterinfo, nullptr, nullptr },
     215             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     216             : };
     217             : #if defined(__clang__)
     218             : #pragma clang diagnostic pop
     219             : #endif
     220             : 
     221             : 
     222             : // Can't be const because the pref-enabled boolean needs to be writable
     223             : static Prefable<const JSPropertySpec> sAttributes[] = {
     224             :   { nullptr, &sAttributes_specs[0] },
     225             :   { nullptr, nullptr }
     226             : };
     227             : 
     228             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     229             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     230             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     231             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     232             : 
     233             : 
     234             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
     235             : static PropertyInfo sNativeProperties_propertyInfos[5];
     236             : 
     237             : static const NativePropertiesN<1> sNativeProperties = {
     238             :   false, 0,
     239             :   false, 0,
     240             :   false, 0,
     241             :   true,  0 /* sAttributes */,
     242             :   false, 0,
     243             :   false, 0,
     244             :   false, 0,
     245             :   -1,
     246             :   5,
     247             :   sNativeProperties_sortedPropertyIndices,
     248             :   {
     249             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     250             :   }
     251             : };
     252             : static_assert(5 < 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::SVGUseElement,
     267             :   PrototypeTraits<prototypes::id::SVGUseElement>::Depth,
     268             :   sNativePropertyHooks,
     269             :   "function SVGUseElement() {\n    [native code]\n}",
     270             :   SVGGraphicsElementBinding::GetConstructorObject
     271             : };
     272             : 
     273             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     274             :   {
     275             :     "SVGUseElementPrototype",
     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::SVGUseElement,
     285             :   PrototypeTraits<prototypes::id::SVGUseElement>::Depth,
     286             :   sNativePropertyHooks,
     287             :   "[object SVGUseElementPrototype]",
     288             :   SVGGraphicsElementBinding::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             :   { "SVGUseElement",
     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::EventTarget, prototypes::id::Node, prototypes::id::Element, prototypes::id::SVGElement, prototypes::id::SVGGraphicsElement, prototypes::id::SVGUseElement, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     327             :   IsBaseOf<nsISupports, mozilla::dom::SVGUseElement >::value,
     328             :   sNativePropertyHooks,
     329             :   FindAssociatedGlobalForNative<mozilla::dom::SVGUseElement>::Get,
     330             :   GetProtoObjectHandle,
     331             :   GetCCParticipant<mozilla::dom::SVGUseElement>::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::dom::SVGUseElement* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     346             : {
     347             :   MOZ_ASSERT(static_cast<mozilla::dom::SVGUseElement*>(aObject) ==
     348             :              reinterpret_cast<mozilla::dom::SVGUseElement*>(aObject),
     349             :              "Multiple inheritance for mozilla::dom::SVGUseElement is broken.");
     350             :   MOZ_ASSERT(static_cast<mozilla::dom::SVGGraphicsElement*>(aObject) ==
     351             :              reinterpret_cast<mozilla::dom::SVGGraphicsElement*>(aObject),
     352             :              "Multiple inheritance for mozilla::dom::SVGGraphicsElement is broken.");
     353             :   MOZ_ASSERT(static_cast<nsSVGElement*>(aObject) ==
     354             :              reinterpret_cast<nsSVGElement*>(aObject),
     355             :              "Multiple inheritance for nsSVGElement is broken.");
     356             :   MOZ_ASSERT(static_cast<mozilla::dom::Element*>(aObject) ==
     357             :              reinterpret_cast<mozilla::dom::Element*>(aObject),
     358             :              "Multiple inheritance for mozilla::dom::Element is broken.");
     359             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     360             :              reinterpret_cast<nsINode*>(aObject),
     361             :              "Multiple inheritance for nsINode is broken.");
     362             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     363             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     364             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     365           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     366           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     367           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     368             :              "You should probably not be using Wrap() directly; use "
     369             :              "GetOrCreateDOMReflector instead");
     370             : 
     371           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     372             :              "nsISupports must be on our primary inheritance chain");
     373             : 
     374           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     375           0 :   if (!global) {
     376           0 :     return false;
     377             :   }
     378           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     379           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     380             : 
     381             :   // That might have ended up wrapping us already, due to the wonders
     382             :   // of XBL.  Check for that, and bail out as needed.
     383           0 :   aReflector.set(aCache->GetWrapper());
     384           0 :   if (aReflector) {
     385             : #ifdef DEBUG
     386           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     387             : #endif // DEBUG
     388           0 :     return true;
     389             :   }
     390             : 
     391           0 :   JSAutoCompartment ac(aCx, global);
     392           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     393           0 :   if (!canonicalProto) {
     394           0 :     return false;
     395             :   }
     396           0 :   JS::Rooted<JSObject*> proto(aCx);
     397           0 :   if (aGivenProto) {
     398           0 :     proto = aGivenProto;
     399             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     400             :     // coming in, we changed compartments to that of "parent" so may need
     401             :     // to wrap the proto here.
     402           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     403           0 :       if (!JS_WrapObject(aCx, &proto)) {
     404           0 :         return false;
     405             :       }
     406             :     }
     407             :   } else {
     408           0 :     proto = canonicalProto;
     409             :   }
     410             : 
     411           0 :   BindingJSObjectCreator<mozilla::dom::SVGUseElement> creator(aCx);
     412           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     413           0 :   if (!aReflector) {
     414           0 :     return false;
     415             :   }
     416             : 
     417           0 :   aCache->SetWrapper(aReflector);
     418           0 :   creator.InitializationSucceeded();
     419             : 
     420           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     421             :              aCache->GetWrapperPreserveColor() == aReflector);
     422             :   // If proto != canonicalProto, we have to preserve our wrapper;
     423             :   // otherwise we won't be able to properly recreate it later, since
     424             :   // we won't know what proto to use.  Note that we don't check
     425             :   // aGivenProto here, since it's entirely possible (and even
     426             :   // somewhat common) to have a non-null aGivenProto which is the
     427             :   // same as canonicalProto.
     428           0 :   if (proto != canonicalProto) {
     429           0 :     PreserveWrapper(aObject);
     430             :   }
     431             : 
     432           0 :   return true;
     433             : }
     434             : 
     435             : const NativePropertyHooks sNativePropertyHooks[] = { {
     436             :   nullptr,
     437             :   nullptr,
     438             :   nullptr,
     439             :   { sNativeProperties.Upcast(), nullptr },
     440             :   prototypes::id::SVGUseElement,
     441             :   constructors::id::SVGUseElement,
     442             :   SVGGraphicsElementBinding::sNativePropertyHooks,
     443             :   &DefaultXrayExpandoObjectClass
     444             : } };
     445             : 
     446             : void
     447           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     448             : {
     449           0 :   JS::Handle<JSObject*> parentProto(SVGGraphicsElementBinding::GetProtoObjectHandle(aCx));
     450           0 :   if (!parentProto) {
     451           0 :     return;
     452             :   }
     453             : 
     454           0 :   JS::Handle<JSObject*> constructorProto(SVGGraphicsElementBinding::GetConstructorObjectHandle(aCx));
     455           0 :   if (!constructorProto) {
     456           0 :     return;
     457             :   }
     458             : 
     459             :   static bool sIdsInited = false;
     460           0 :   if (!sIdsInited && NS_IsMainThread()) {
     461           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     462           0 :       return;
     463             :     }
     464           0 :     sIdsInited = true;
     465             :   }
     466             : 
     467           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::SVGUseElement);
     468           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGUseElement);
     469           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     470             :                               &sPrototypeClass.mBase, protoCache,
     471             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     472             :                               interfaceCache,
     473             :                               sNativeProperties.Upcast(),
     474             :                               nullptr,
     475             :                               "SVGUseElement", aDefineOnGlobal,
     476             :                               nullptr,
     477           0 :                               false);
     478             : }
     479             : 
     480             : JS::Handle<JSObject*>
     481           0 : GetProtoObjectHandle(JSContext* aCx)
     482             : {
     483             :   /* Get the interface prototype object for this class.  This will create the
     484             :      object as needed. */
     485           0 :   bool aDefineOnGlobal = true;
     486             : 
     487             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     488           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     489           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     490           0 :     return nullptr;
     491             :   }
     492             : 
     493             :   /* Check to see whether the interface objects are already installed */
     494           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     495           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::SVGUseElement)) {
     496           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     497           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     498             :   }
     499             : 
     500             :   /*
     501             :    * The object might _still_ be null, but that's OK.
     502             :    *
     503             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     504             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     505             :    * changed after they have been set.
     506             :    *
     507             :    * Calling address() avoids the read read barrier that does gray
     508             :    * unmarking, but it's not possible for the object to be gray here.
     509             :    */
     510             : 
     511           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::SVGUseElement);
     512           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     513           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     514             : }
     515             : 
     516             : JS::Handle<JSObject*>
     517           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     518             : {
     519             :   /* Get the interface object for this class.  This will create the object as
     520             :      needed. */
     521             : 
     522             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     523           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     524           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     525           0 :     return nullptr;
     526             :   }
     527             : 
     528             :   /* Check to see whether the interface objects are already installed */
     529           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     530           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::SVGUseElement)) {
     531           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     532           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     533             :   }
     534             : 
     535             :   /*
     536             :    * The object might _still_ be null, but that's OK.
     537             :    *
     538             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     539             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     540             :    * changed after they have been set.
     541             :    *
     542             :    * Calling address() avoids the read read barrier that does gray
     543             :    * unmarking, but it's not possible for the object to be gray here.
     544             :    */
     545             : 
     546           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::SVGUseElement);
     547           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     548           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     549             : }
     550             : 
     551             : JSObject*
     552           0 : GetConstructorObject(JSContext* aCx)
     553             : {
     554           0 :   return GetConstructorObjectHandle(aCx);
     555             : }
     556             : 
     557             : } // namespace SVGUseElementBinding
     558             : 
     559             : 
     560             : 
     561             : } // namespace dom
     562             : } // namespace mozilla

Generated by: LCOV version 1.13