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

Generated by: LCOV version 1.13