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

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

Generated by: LCOV version 1.13