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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM DOMPoint.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "DOMPointBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/Preferences.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/DOMPoint.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/ScriptSettings.h"
      14             : #include "mozilla/dom/XrayExpandoClass.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : 
      20           0 : DOMPointInit::DOMPointInit()
      21             : {
      22             :   // Safe to pass a null context if we pass a null value
      23           0 :   Init(nullptr, JS::NullHandleValue);
      24           0 : }
      25             : 
      26             : 
      27             : 
      28             : bool
      29           0 : DOMPointInit::InitIds(JSContext* cx, DOMPointInitAtoms* atomsCache)
      30             : {
      31           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      32             : 
      33             :   // Initialize these in reverse order so that any failure leaves the first one
      34             :   // uninitialized.
      35           0 :   if (!atomsCache->z_id.init(cx, "z") ||
      36           0 :       !atomsCache->y_id.init(cx, "y") ||
      37           0 :       !atomsCache->x_id.init(cx, "x") ||
      38           0 :       !atomsCache->w_id.init(cx, "w")) {
      39           0 :     return false;
      40             :   }
      41           0 :   return true;
      42             : }
      43             : 
      44             : bool
      45           0 : DOMPointInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      46             : {
      47             :   // Passing a null JSContext is OK only if we're initing from null,
      48             :   // Since in that case we will not have to do any property gets
      49             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      50             :   // checkers by static analysis tools
      51           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      52           0 :   DOMPointInitAtoms* atomsCache = nullptr;
      53           0 :   if (cx) {
      54           0 :     atomsCache = GetAtomCache<DOMPointInitAtoms>(cx);
      55           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      56           0 :       return false;
      57             :     }
      58             :   }
      59             : 
      60           0 :   if (!IsConvertibleToDictionary(val)) {
      61           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      62             :   }
      63             : 
      64           0 :   bool isNull = val.isNullOrUndefined();
      65             :   // We only need these if !isNull, in which case we have |cx|.
      66           0 :   Maybe<JS::Rooted<JSObject *> > object;
      67           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      68           0 :   if (!isNull) {
      69           0 :     MOZ_ASSERT(cx);
      70           0 :     object.emplace(cx, &val.toObject());
      71           0 :     temp.emplace(cx);
      72             :   }
      73           0 :   if (!isNull) {
      74           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->w_id, temp.ptr())) {
      75           0 :       return false;
      76             :     }
      77             :   }
      78           0 :   if (!isNull && !temp->isUndefined()) {
      79           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mW)) {
      80           0 :       return false;
      81             :     }
      82             :   } else {
      83           0 :     mW = 1.0;
      84             :   }
      85           0 :   mIsAnyMemberPresent = true;
      86             : 
      87           0 :   if (!isNull) {
      88           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->x_id, temp.ptr())) {
      89           0 :       return false;
      90             :     }
      91             :   }
      92           0 :   if (!isNull && !temp->isUndefined()) {
      93           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mX)) {
      94           0 :       return false;
      95             :     }
      96             :   } else {
      97           0 :     mX = 0.0;
      98             :   }
      99           0 :   mIsAnyMemberPresent = true;
     100             : 
     101           0 :   if (!isNull) {
     102           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->y_id, temp.ptr())) {
     103           0 :       return false;
     104             :     }
     105             :   }
     106           0 :   if (!isNull && !temp->isUndefined()) {
     107           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mY)) {
     108           0 :       return false;
     109             :     }
     110             :   } else {
     111           0 :     mY = 0.0;
     112             :   }
     113           0 :   mIsAnyMemberPresent = true;
     114             : 
     115           0 :   if (!isNull) {
     116           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->z_id, temp.ptr())) {
     117           0 :       return false;
     118             :     }
     119             :   }
     120           0 :   if (!isNull && !temp->isUndefined()) {
     121           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mZ)) {
     122           0 :       return false;
     123             :     }
     124             :   } else {
     125           0 :     mZ = 0.0;
     126             :   }
     127           0 :   mIsAnyMemberPresent = true;
     128           0 :   return true;
     129             : }
     130             : 
     131             : bool
     132           0 : DOMPointInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     133             : {
     134           0 :   DOMPointInitAtoms* atomsCache = GetAtomCache<DOMPointInitAtoms>(cx);
     135           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     136           0 :     return false;
     137             :   }
     138             : 
     139           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     140           0 :   if (!obj) {
     141           0 :     return false;
     142             :   }
     143           0 :   rval.set(JS::ObjectValue(*obj));
     144             : 
     145             :   do {
     146             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     147           0 :     JS::Rooted<JS::Value> temp(cx);
     148           0 :     double const & currentValue = mW;
     149           0 :     temp.set(JS_NumberValue(double(currentValue)));
     150           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->w_id, temp, JSPROP_ENUMERATE)) {
     151           0 :       return false;
     152             :     }
     153           0 :     break;
     154             :   } while(0);
     155             : 
     156             :   do {
     157             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     158           0 :     JS::Rooted<JS::Value> temp(cx);
     159           0 :     double const & currentValue = mX;
     160           0 :     temp.set(JS_NumberValue(double(currentValue)));
     161           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->x_id, temp, JSPROP_ENUMERATE)) {
     162           0 :       return false;
     163             :     }
     164           0 :     break;
     165             :   } while(0);
     166             : 
     167             :   do {
     168             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     169           0 :     JS::Rooted<JS::Value> temp(cx);
     170           0 :     double const & currentValue = mY;
     171           0 :     temp.set(JS_NumberValue(double(currentValue)));
     172           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->y_id, temp, JSPROP_ENUMERATE)) {
     173           0 :       return false;
     174             :     }
     175           0 :     break;
     176             :   } while(0);
     177             : 
     178             :   do {
     179             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     180           0 :     JS::Rooted<JS::Value> temp(cx);
     181           0 :     double const & currentValue = mZ;
     182           0 :     temp.set(JS_NumberValue(double(currentValue)));
     183           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->z_id, temp, JSPROP_ENUMERATE)) {
     184           0 :       return false;
     185             :     }
     186           0 :     break;
     187             :   } while(0);
     188             : 
     189           0 :   return true;
     190             : }
     191             : 
     192             : void
     193           0 : DOMPointInit::TraceDictionary(JSTracer* trc)
     194             : {
     195           0 : }
     196             : 
     197             : DOMPointInit&
     198           0 : DOMPointInit::operator=(const DOMPointInit& aOther)
     199             : {
     200           0 :   mW = aOther.mW;
     201           0 :   mX = aOther.mX;
     202           0 :   mY = aOther.mY;
     203           0 :   mZ = aOther.mZ;
     204           0 :   return *this;
     205             : }
     206             : 
     207             : namespace binding_detail {
     208             : } // namespace binding_detail
     209             : 
     210             : 
     211             : namespace DOMPointBinding {
     212             : 
     213             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<DOMPointReadOnlyBinding::NativeType>::value,
     214             :               "Can't inherit from an interface with a different ownership model.");
     215             : 
     216             : static bool
     217           0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitGetterCallArgs args)
     218             : {
     219           0 :   double result(self->X());
     220           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     221           0 :   args.rval().set(JS_NumberValue(double(result)));
     222           0 :   return true;
     223             : }
     224             : 
     225             : static bool
     226           0 : set_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitSetterCallArgs args)
     227             : {
     228             :   double arg0;
     229           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     230           0 :     return false;
     231             :   }
     232           0 :   self->SetX(arg0);
     233           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     234             : 
     235           0 :   return true;
     236             : }
     237             : 
     238             : static const JSJitInfo x_getterinfo = {
     239             :   { (JSJitGetterOp)get_x },
     240             :   { prototypes::id::DOMPoint },
     241             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     242             :   JSJitInfo::Getter,
     243             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     244             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     245             :   true,  /* isInfallible. False in setters. */
     246             :   false,  /* isMovable.  Not relevant for setters. */
     247             :   false, /* isEliminatable.  Not relevant for setters. */
     248             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     249             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     250             :   false,  /* isTypedMethod.  Only relevant for methods. */
     251             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     252             : };
     253             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     254             : static_assert(0 < 1, "There is no slot for us");
     255             : static const JSJitInfo x_setterinfo = {
     256             :   { (JSJitGetterOp)set_x },
     257             :   { prototypes::id::DOMPoint },
     258             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     259             :   JSJitInfo::Setter,
     260             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     261             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     262             :   false,  /* isInfallible. False in setters. */
     263             :   false,  /* isMovable.  Not relevant for setters. */
     264             :   false, /* isEliminatable.  Not relevant for setters. */
     265             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     266             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     267             :   false,  /* isTypedMethod.  Only relevant for methods. */
     268             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     269             : };
     270             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     271             : static_assert(0 < 1, "There is no slot for us");
     272             : 
     273             : static bool
     274           0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitGetterCallArgs args)
     275             : {
     276           0 :   double result(self->Y());
     277           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     278           0 :   args.rval().set(JS_NumberValue(double(result)));
     279           0 :   return true;
     280             : }
     281             : 
     282             : static bool
     283           0 : set_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitSetterCallArgs args)
     284             : {
     285             :   double arg0;
     286           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     287           0 :     return false;
     288             :   }
     289           0 :   self->SetY(arg0);
     290           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     291             : 
     292           0 :   return true;
     293             : }
     294             : 
     295             : static const JSJitInfo y_getterinfo = {
     296             :   { (JSJitGetterOp)get_y },
     297             :   { prototypes::id::DOMPoint },
     298             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     299             :   JSJitInfo::Getter,
     300             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     301             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     302             :   true,  /* isInfallible. False in setters. */
     303             :   false,  /* isMovable.  Not relevant for setters. */
     304             :   false, /* isEliminatable.  Not relevant for setters. */
     305             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     306             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     307             :   false,  /* isTypedMethod.  Only relevant for methods. */
     308             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     309             : };
     310             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     311             : static_assert(0 < 1, "There is no slot for us");
     312             : static const JSJitInfo y_setterinfo = {
     313             :   { (JSJitGetterOp)set_y },
     314             :   { prototypes::id::DOMPoint },
     315             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     316             :   JSJitInfo::Setter,
     317             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     318             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     319             :   false,  /* isInfallible. False in setters. */
     320             :   false,  /* isMovable.  Not relevant for setters. */
     321             :   false, /* isEliminatable.  Not relevant for setters. */
     322             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     323             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     324             :   false,  /* isTypedMethod.  Only relevant for methods. */
     325             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     326             : };
     327             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     328             : static_assert(0 < 1, "There is no slot for us");
     329             : 
     330             : static bool
     331           0 : get_z(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitGetterCallArgs args)
     332             : {
     333           0 :   double result(self->Z());
     334           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     335           0 :   args.rval().set(JS_NumberValue(double(result)));
     336           0 :   return true;
     337             : }
     338             : 
     339             : static bool
     340           0 : set_z(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitSetterCallArgs args)
     341             : {
     342             :   double arg0;
     343           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     344           0 :     return false;
     345             :   }
     346           0 :   self->SetZ(arg0);
     347           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     348             : 
     349           0 :   return true;
     350             : }
     351             : 
     352             : static const JSJitInfo z_getterinfo = {
     353             :   { (JSJitGetterOp)get_z },
     354             :   { prototypes::id::DOMPoint },
     355             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     356             :   JSJitInfo::Getter,
     357             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     358             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     359             :   true,  /* isInfallible. False in setters. */
     360             :   false,  /* isMovable.  Not relevant for setters. */
     361             :   false, /* isEliminatable.  Not relevant for setters. */
     362             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     363             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     364             :   false,  /* isTypedMethod.  Only relevant for methods. */
     365             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     366             : };
     367             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     368             : static_assert(0 < 1, "There is no slot for us");
     369             : static const JSJitInfo z_setterinfo = {
     370             :   { (JSJitGetterOp)set_z },
     371             :   { prototypes::id::DOMPoint },
     372             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     373             :   JSJitInfo::Setter,
     374             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     375             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     376             :   false,  /* isInfallible. False in setters. */
     377             :   false,  /* isMovable.  Not relevant for setters. */
     378             :   false, /* isEliminatable.  Not relevant for setters. */
     379             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     380             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     381             :   false,  /* isTypedMethod.  Only relevant for methods. */
     382             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     383             : };
     384             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     385             : static_assert(0 < 1, "There is no slot for us");
     386             : 
     387             : static bool
     388           0 : get_w(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitGetterCallArgs args)
     389             : {
     390           0 :   double result(self->W());
     391           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     392           0 :   args.rval().set(JS_NumberValue(double(result)));
     393           0 :   return true;
     394             : }
     395             : 
     396             : static bool
     397           0 : set_w(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPoint* self, JSJitSetterCallArgs args)
     398             : {
     399             :   double arg0;
     400           0 :   if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     401           0 :     return false;
     402             :   }
     403           0 :   self->SetW(arg0);
     404           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     405             : 
     406           0 :   return true;
     407             : }
     408             : 
     409             : static const JSJitInfo w_getterinfo = {
     410             :   { (JSJitGetterOp)get_w },
     411             :   { prototypes::id::DOMPoint },
     412             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     413             :   JSJitInfo::Getter,
     414             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     415             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     416             :   true,  /* isInfallible. False in setters. */
     417             :   false,  /* isMovable.  Not relevant for setters. */
     418             :   false, /* isEliminatable.  Not relevant for setters. */
     419             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     420             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     421             :   false,  /* isTypedMethod.  Only relevant for methods. */
     422             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     423             : };
     424             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     425             : static_assert(0 < 1, "There is no slot for us");
     426             : static const JSJitInfo w_setterinfo = {
     427             :   { (JSJitGetterOp)set_w },
     428             :   { prototypes::id::DOMPoint },
     429             :   { PrototypeTraits<prototypes::id::DOMPoint>::Depth },
     430             :   JSJitInfo::Setter,
     431             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     432             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     433             :   false,  /* isInfallible. False in setters. */
     434             :   false,  /* isMovable.  Not relevant for setters. */
     435             :   false, /* isEliminatable.  Not relevant for setters. */
     436             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     437             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     438             :   false,  /* isTypedMethod.  Only relevant for methods. */
     439             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     440             : };
     441             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     442             : static_assert(0 < 1, "There is no slot for us");
     443             : 
     444             : static bool
     445           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     446             : {
     447           0 :   mozilla::dom::DOMPoint* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMPoint>(obj);
     448             :   // We don't want to preserve if we don't have a wrapper, and we
     449             :   // obviously can't preserve if we're not initialized.
     450           0 :   if (self && self->GetWrapperPreserveColor()) {
     451           0 :     PreserveWrapper(self);
     452             :   }
     453           0 :   return true;
     454             : }
     455             : 
     456             : static void
     457           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     458             : {
     459           0 :   mozilla::dom::DOMPoint* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMPoint>(obj);
     460           0 :   if (self) {
     461           0 :     ClearWrapper(self, self, obj);
     462           0 :     AddForDeferredFinalization<mozilla::dom::DOMPoint>(self);
     463             :   }
     464           0 : }
     465             : 
     466             : static void
     467           0 : _objectMoved(JSObject* obj, const JSObject* old)
     468             : {
     469           0 :   mozilla::dom::DOMPoint* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMPoint>(obj);
     470           0 :   if (self) {
     471           0 :     UpdateWrapper(self, self, obj, old);
     472             :   }
     473           0 : }
     474             : 
     475             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     476             : #if defined(__clang__)
     477             : #pragma clang diagnostic push
     478             : #pragma clang diagnostic ignored "-Wmissing-braces"
     479             : #endif
     480             : static const JSPropertySpec sAttributes_specs[] = {
     481             :   { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, GenericBindingSetter, &x_setterinfo },
     482             :   { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, GenericBindingSetter, &y_setterinfo },
     483             :   { "z", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &z_getterinfo, GenericBindingSetter, &z_setterinfo },
     484             :   { "w", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &w_getterinfo, GenericBindingSetter, &w_setterinfo },
     485             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     486             : };
     487             : #if defined(__clang__)
     488             : #pragma clang diagnostic pop
     489             : #endif
     490             : 
     491             : 
     492             : // Can't be const because the pref-enabled boolean needs to be writable
     493             : static Prefable<const JSPropertySpec> sAttributes[] = {
     494             :   { nullptr, &sAttributes_specs[0] },
     495             :   { nullptr, nullptr }
     496             : };
     497             : 
     498             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     499             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     500             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     501             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     502             : 
     503             : 
     504             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
     505             : static PropertyInfo sNativeProperties_propertyInfos[4];
     506             : 
     507             : static const NativePropertiesN<1> sNativeProperties = {
     508             :   false, 0,
     509             :   false, 0,
     510             :   false, 0,
     511             :   true,  0 /* sAttributes */,
     512             :   false, 0,
     513             :   false, 0,
     514             :   false, 0,
     515             :   -1,
     516             :   4,
     517             :   sNativeProperties_sortedPropertyIndices,
     518             :   {
     519             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     520             :   }
     521             : };
     522             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     523             :     "We have a property info count that is oversized");
     524             : 
     525             : static bool
     526           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     527             : {
     528           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     529           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     530           0 :   if (!args.isConstructing()) {
     531             :     // XXXbz wish I could get the name from the callee instead of
     532             :     // Adding more relocations
     533           0 :     return ThrowConstructorWithoutNew(cx, "DOMPoint");
     534             :   }
     535             : 
     536           0 :   GlobalObject global(cx, obj);
     537           0 :   if (global.Failed()) {
     538           0 :     return false;
     539             :   }
     540             : 
     541           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     542           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     543           0 :     return false;
     544             :   }
     545             : 
     546           0 :   unsigned argcount = std::min(args.length(), 4u);
     547           0 :   switch (argcount) {
     548             :     case 0: {
     549             :       MOZ_FALLTHROUGH;
     550             :     }
     551             :     case 1: {
     552           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     553           0 :       binding_detail::FastDOMPointInit arg0;
     554           0 :       if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of DOMPoint.constructor", false)) {
     555           0 :         return false;
     556             :       }
     557           0 :       Maybe<JSAutoCompartment> ac;
     558           0 :       if (objIsXray) {
     559           0 :         obj = js::CheckedUnwrap(obj);
     560           0 :         if (!obj) {
     561           0 :           return false;
     562             :         }
     563           0 :         ac.emplace(cx, obj);
     564           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
     565           0 :           return false;
     566             :         }
     567             :       }
     568           0 :       binding_detail::FastErrorResult rv;
     569           0 :       auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(mozilla::dom::DOMPoint::Constructor(global, Constify(arg0), rv)));
     570           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     571           0 :         return false;
     572             :       }
     573           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     574             :       static_assert(!IsPointer<decltype(result)>::value,
     575             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
     576           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     577           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     578           0 :         return false;
     579             :       }
     580           0 :       return true;
     581             :       break;
     582             :     }
     583             :     case 2: {
     584             :       MOZ_FALLTHROUGH;
     585             :     }
     586             :     case 3: {
     587             :       MOZ_FALLTHROUGH;
     588             :     }
     589             :     case 4: {
     590           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     591             :       double arg0;
     592           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     593           0 :         return false;
     594             :       }
     595             :       double arg1;
     596           0 :       if (!ValueToPrimitive<double, eDefault>(cx, args[1], &arg1)) {
     597           0 :         return false;
     598             :       }
     599             :       double arg2;
     600           0 :       if (args.hasDefined(2)) {
     601           0 :         if (!ValueToPrimitive<double, eDefault>(cx, args[2], &arg2)) {
     602           0 :           return false;
     603             :         }
     604             :       } else {
     605           0 :         arg2 = 0.0;
     606             :       }
     607             :       double arg3;
     608           0 :       if (args.hasDefined(3)) {
     609           0 :         if (!ValueToPrimitive<double, eDefault>(cx, args[3], &arg3)) {
     610           0 :           return false;
     611             :         }
     612             :       } else {
     613           0 :         arg3 = 1.0;
     614             :       }
     615           0 :       Maybe<JSAutoCompartment> ac;
     616           0 :       if (objIsXray) {
     617           0 :         obj = js::CheckedUnwrap(obj);
     618           0 :         if (!obj) {
     619           0 :           return false;
     620             :         }
     621           0 :         ac.emplace(cx, obj);
     622           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
     623           0 :           return false;
     624             :         }
     625             :       }
     626           0 :       binding_detail::FastErrorResult rv;
     627           0 :       auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(mozilla::dom::DOMPoint::Constructor(global, arg0, arg1, arg2, arg3, rv)));
     628           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     629           0 :         return false;
     630             :       }
     631           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     632             :       static_assert(!IsPointer<decltype(result)>::value,
     633             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
     634           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     635           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     636           0 :         return false;
     637             :       }
     638           0 :       return true;
     639             :       break;
     640             :     }
     641             :     default: {
     642           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DOMPoint");
     643             :       break;
     644             :     }
     645             :   }
     646             :   MOZ_CRASH("We have an always-returning default case");
     647             :   return false;
     648             : }
     649             : 
     650             : static const js::ClassOps sInterfaceObjectClassOps = {
     651             :     nullptr,               /* addProperty */
     652             :     nullptr,               /* delProperty */
     653             :     nullptr,               /* getProperty */
     654             :     nullptr,               /* setProperty */
     655             :     nullptr,               /* enumerate */
     656             :     nullptr,               /* newEnumerate */
     657             :     nullptr,               /* resolve */
     658             :     nullptr,               /* mayResolve */
     659             :     nullptr,               /* finalize */
     660             :     _constructor, /* call */
     661             :     nullptr,               /* hasInstance */
     662             :     _constructor, /* construct */
     663             :     nullptr,               /* trace */
     664             : };
     665             : 
     666             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     667             :   {
     668             :     "Function",
     669             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     670             :     &sInterfaceObjectClassOps,
     671             :     JS_NULL_CLASS_SPEC,
     672             :     JS_NULL_CLASS_EXT,
     673             :     &sInterfaceObjectClassObjectOps
     674             :   },
     675             :   eInterface,
     676             :   true,
     677             :   prototypes::id::DOMPoint,
     678             :   PrototypeTraits<prototypes::id::DOMPoint>::Depth,
     679             :   sNativePropertyHooks,
     680             :   "function DOMPoint() {\n    [native code]\n}",
     681             :   DOMPointReadOnlyBinding::GetConstructorObject
     682             : };
     683             : 
     684             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     685             :   {
     686             :     "DOMPointPrototype",
     687             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     688             :     JS_NULL_CLASS_OPS,
     689             :     JS_NULL_CLASS_SPEC,
     690             :     JS_NULL_CLASS_EXT,
     691             :     JS_NULL_OBJECT_OPS
     692             :   },
     693             :   eInterfacePrototype,
     694             :   false,
     695             :   prototypes::id::DOMPoint,
     696             :   PrototypeTraits<prototypes::id::DOMPoint>::Depth,
     697             :   sNativePropertyHooks,
     698             :   "[object DOMPointPrototype]",
     699             :   DOMPointReadOnlyBinding::GetProtoObject
     700             : };
     701             : 
     702             : bool
     703           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     704             : {
     705             :   static bool sPrefValue;
     706             :   static bool sPrefCacheSetUp = false;
     707           0 :   if (!sPrefCacheSetUp) {
     708           0 :     sPrefCacheSetUp = true;
     709           0 :     Preferences::AddBoolVarCache(&sPrefValue, "layout.css.DOMPoint.enabled");
     710             :   }
     711             : 
     712           0 :   return sPrefValue;
     713             : }
     714             : 
     715             : JSObject*
     716           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     717             : {
     718           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     719             : }
     720             : 
     721             : static const js::ClassOps sClassOps = {
     722             :   _addProperty, /* addProperty */
     723             :   nullptr,               /* delProperty */
     724             :   nullptr,               /* getProperty */
     725             :   nullptr,               /* setProperty */
     726             :   nullptr,               /* enumerate */
     727             :   nullptr, /* newEnumerate */
     728             :   nullptr, /* resolve */
     729             :   nullptr, /* mayResolve */
     730             :   _finalize, /* finalize */
     731             :   nullptr, /* call */
     732             :   nullptr,               /* hasInstance */
     733             :   nullptr,               /* construct */
     734             :   nullptr, /* trace */
     735             : };
     736             : 
     737             : static const js::ClassExtension sClassExtension = {
     738             :   nullptr, /* weakmapKeyDelegateOp */
     739             :   _objectMoved /* objectMovedOp */
     740             : };
     741             : 
     742             : static const DOMJSClass sClass = {
     743             :   { "DOMPoint",
     744             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     745             :     &sClassOps,
     746             :     JS_NULL_CLASS_SPEC,
     747             :     &sClassExtension,
     748             :     JS_NULL_OBJECT_OPS
     749             :   },
     750             :   { prototypes::id::DOMPointReadOnly, prototypes::id::DOMPoint, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     751             :   IsBaseOf<nsISupports, mozilla::dom::DOMPoint >::value,
     752             :   sNativePropertyHooks,
     753             :   FindAssociatedGlobalForNative<mozilla::dom::DOMPoint>::Get,
     754             :   GetProtoObjectHandle,
     755             :   GetCCParticipant<mozilla::dom::DOMPoint>::Get()
     756             : };
     757             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     758             :               "Must have the right minimal number of reserved slots.");
     759             : static_assert(1 >= 1,
     760             :               "Must have enough reserved slots.");
     761             : 
     762             : const JSClass*
     763           0 : GetJSClass()
     764             : {
     765           0 :   return sClass.ToJSClass();
     766             : }
     767             : 
     768             : bool
     769           0 : Wrap(JSContext* aCx, mozilla::dom::DOMPoint* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     770             : {
     771             :   MOZ_ASSERT(static_cast<mozilla::dom::DOMPoint*>(aObject) ==
     772             :              reinterpret_cast<mozilla::dom::DOMPoint*>(aObject),
     773             :              "Multiple inheritance for mozilla::dom::DOMPoint is broken.");
     774             :   MOZ_ASSERT(static_cast<mozilla::dom::DOMPointReadOnly*>(aObject) ==
     775             :              reinterpret_cast<mozilla::dom::DOMPointReadOnly*>(aObject),
     776             :              "Multiple inheritance for mozilla::dom::DOMPointReadOnly is broken.");
     777           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     778           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     779           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     780             :              "You should probably not be using Wrap() directly; use "
     781             :              "GetOrCreateDOMReflector instead");
     782             : 
     783           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     784             :              "nsISupports must be on our primary inheritance chain");
     785             : 
     786           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     787           0 :   if (!global) {
     788           0 :     return false;
     789             :   }
     790           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     791           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     792             : 
     793             :   // That might have ended up wrapping us already, due to the wonders
     794             :   // of XBL.  Check for that, and bail out as needed.
     795           0 :   aReflector.set(aCache->GetWrapper());
     796           0 :   if (aReflector) {
     797             : #ifdef DEBUG
     798           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     799             : #endif // DEBUG
     800           0 :     return true;
     801             :   }
     802             : 
     803           0 :   JSAutoCompartment ac(aCx, global);
     804           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     805           0 :   if (!canonicalProto) {
     806           0 :     return false;
     807             :   }
     808           0 :   JS::Rooted<JSObject*> proto(aCx);
     809           0 :   if (aGivenProto) {
     810           0 :     proto = aGivenProto;
     811             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     812             :     // coming in, we changed compartments to that of "parent" so may need
     813             :     // to wrap the proto here.
     814           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     815           0 :       if (!JS_WrapObject(aCx, &proto)) {
     816           0 :         return false;
     817             :       }
     818             :     }
     819             :   } else {
     820           0 :     proto = canonicalProto;
     821             :   }
     822             : 
     823           0 :   BindingJSObjectCreator<mozilla::dom::DOMPoint> creator(aCx);
     824           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     825           0 :   if (!aReflector) {
     826           0 :     return false;
     827             :   }
     828             : 
     829           0 :   aCache->SetWrapper(aReflector);
     830           0 :   creator.InitializationSucceeded();
     831             : 
     832           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     833             :              aCache->GetWrapperPreserveColor() == aReflector);
     834             :   // If proto != canonicalProto, we have to preserve our wrapper;
     835             :   // otherwise we won't be able to properly recreate it later, since
     836             :   // we won't know what proto to use.  Note that we don't check
     837             :   // aGivenProto here, since it's entirely possible (and even
     838             :   // somewhat common) to have a non-null aGivenProto which is the
     839             :   // same as canonicalProto.
     840           0 :   if (proto != canonicalProto) {
     841           0 :     PreserveWrapper(aObject);
     842             :   }
     843             : 
     844           0 :   return true;
     845             : }
     846             : 
     847             : const NativePropertyHooks sNativePropertyHooks[] = { {
     848             :   nullptr,
     849             :   nullptr,
     850             :   nullptr,
     851             :   { sNativeProperties.Upcast(), nullptr },
     852             :   prototypes::id::DOMPoint,
     853             :   constructors::id::DOMPoint,
     854             :   DOMPointReadOnlyBinding::sNativePropertyHooks,
     855             :   &DefaultXrayExpandoObjectClass
     856             : } };
     857             : 
     858             : void
     859           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     860             : {
     861           0 :   JS::Handle<JSObject*> parentProto(DOMPointReadOnlyBinding::GetProtoObjectHandle(aCx));
     862           0 :   if (!parentProto) {
     863           0 :     return;
     864             :   }
     865             : 
     866           0 :   JS::Handle<JSObject*> constructorProto(DOMPointReadOnlyBinding::GetConstructorObjectHandle(aCx));
     867           0 :   if (!constructorProto) {
     868           0 :     return;
     869             :   }
     870             : 
     871             :   static bool sIdsInited = false;
     872           0 :   if (!sIdsInited && NS_IsMainThread()) {
     873           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     874           0 :       return;
     875             :     }
     876           0 :     sIdsInited = true;
     877             :   }
     878             : 
     879           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DOMPoint);
     880           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DOMPoint);
     881           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     882             :                               &sPrototypeClass.mBase, protoCache,
     883             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     884             :                               interfaceCache,
     885             :                               sNativeProperties.Upcast(),
     886             :                               nullptr,
     887             :                               "DOMPoint", aDefineOnGlobal,
     888             :                               nullptr,
     889           0 :                               false);
     890             : }
     891             : 
     892             : JS::Handle<JSObject*>
     893           0 : GetProtoObjectHandle(JSContext* aCx)
     894             : {
     895             :   /* Get the interface prototype object for this class.  This will create the
     896             :      object as needed. */
     897           0 :   bool aDefineOnGlobal = true;
     898             : 
     899             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     900           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     901           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     902           0 :     return nullptr;
     903             :   }
     904             : 
     905             :   /* Check to see whether the interface objects are already installed */
     906           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     907           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DOMPoint)) {
     908           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     909           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     910             :   }
     911             : 
     912             :   /*
     913             :    * The object might _still_ be null, but that's OK.
     914             :    *
     915             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     916             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     917             :    * changed after they have been set.
     918             :    *
     919             :    * Calling address() avoids the read read barrier that does gray
     920             :    * unmarking, but it's not possible for the object to be gray here.
     921             :    */
     922             : 
     923           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DOMPoint);
     924           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     925           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     926             : }
     927             : 
     928             : JS::Handle<JSObject*>
     929           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     930             : {
     931             :   /* Get the interface object for this class.  This will create the object as
     932             :      needed. */
     933             : 
     934             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     935           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     936           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     937           0 :     return nullptr;
     938             :   }
     939             : 
     940             :   /* Check to see whether the interface objects are already installed */
     941           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     942           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DOMPoint)) {
     943           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     944           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     945             :   }
     946             : 
     947             :   /*
     948             :    * The object might _still_ be null, but that's OK.
     949             :    *
     950             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     951             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     952             :    * changed after they have been set.
     953             :    *
     954             :    * Calling address() avoids the read read barrier that does gray
     955             :    * unmarking, but it's not possible for the object to be gray here.
     956             :    */
     957             : 
     958           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DOMPoint);
     959           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     960           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     961             : }
     962             : 
     963             : JSObject*
     964           0 : GetConstructorObject(JSContext* aCx)
     965             : {
     966           0 :   return GetConstructorObjectHandle(aCx);
     967             : }
     968             : 
     969             : } // namespace DOMPointBinding
     970             : 
     971             : 
     972             : 
     973             : namespace DOMPointReadOnlyBinding {
     974             : 
     975             : static bool
     976           0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPointReadOnly* self, JSJitGetterCallArgs args)
     977             : {
     978           0 :   double result(self->X());
     979           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     980           0 :   args.rval().set(JS_NumberValue(double(result)));
     981           0 :   return true;
     982             : }
     983             : 
     984             : static const JSJitInfo x_getterinfo = {
     985             :   { (JSJitGetterOp)get_x },
     986             :   { prototypes::id::DOMPointReadOnly },
     987             :   { PrototypeTraits<prototypes::id::DOMPointReadOnly>::Depth },
     988             :   JSJitInfo::Getter,
     989             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     990             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     991             :   true,  /* isInfallible. False in setters. */
     992             :   false,  /* isMovable.  Not relevant for setters. */
     993             :   false, /* isEliminatable.  Not relevant for setters. */
     994             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     995             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     996             :   false,  /* isTypedMethod.  Only relevant for methods. */
     997             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     998             : };
     999             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1000             : static_assert(0 < 1, "There is no slot for us");
    1001             : 
    1002             : static bool
    1003           0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPointReadOnly* self, JSJitGetterCallArgs args)
    1004             : {
    1005           0 :   double result(self->Y());
    1006           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1007           0 :   args.rval().set(JS_NumberValue(double(result)));
    1008           0 :   return true;
    1009             : }
    1010             : 
    1011             : static const JSJitInfo y_getterinfo = {
    1012             :   { (JSJitGetterOp)get_y },
    1013             :   { prototypes::id::DOMPointReadOnly },
    1014             :   { PrototypeTraits<prototypes::id::DOMPointReadOnly>::Depth },
    1015             :   JSJitInfo::Getter,
    1016             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1017             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1018             :   true,  /* isInfallible. False in setters. */
    1019             :   false,  /* isMovable.  Not relevant for setters. */
    1020             :   false, /* isEliminatable.  Not relevant for setters. */
    1021             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1022             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1023             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1024             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1025             : };
    1026             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1027             : static_assert(0 < 1, "There is no slot for us");
    1028             : 
    1029             : static bool
    1030           0 : get_z(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPointReadOnly* self, JSJitGetterCallArgs args)
    1031             : {
    1032           0 :   double result(self->Z());
    1033           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1034           0 :   args.rval().set(JS_NumberValue(double(result)));
    1035           0 :   return true;
    1036             : }
    1037             : 
    1038             : static const JSJitInfo z_getterinfo = {
    1039             :   { (JSJitGetterOp)get_z },
    1040             :   { prototypes::id::DOMPointReadOnly },
    1041             :   { PrototypeTraits<prototypes::id::DOMPointReadOnly>::Depth },
    1042             :   JSJitInfo::Getter,
    1043             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1044             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1045             :   true,  /* isInfallible. False in setters. */
    1046             :   false,  /* isMovable.  Not relevant for setters. */
    1047             :   false, /* isEliminatable.  Not relevant for setters. */
    1048             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1049             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1050             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1051             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1052             : };
    1053             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1054             : static_assert(0 < 1, "There is no slot for us");
    1055             : 
    1056             : static bool
    1057           0 : get_w(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMPointReadOnly* self, JSJitGetterCallArgs args)
    1058             : {
    1059           0 :   double result(self->W());
    1060           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1061           0 :   args.rval().set(JS_NumberValue(double(result)));
    1062           0 :   return true;
    1063             : }
    1064             : 
    1065             : static const JSJitInfo w_getterinfo = {
    1066             :   { (JSJitGetterOp)get_w },
    1067             :   { prototypes::id::DOMPointReadOnly },
    1068             :   { PrototypeTraits<prototypes::id::DOMPointReadOnly>::Depth },
    1069             :   JSJitInfo::Getter,
    1070             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1071             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
    1072             :   true,  /* isInfallible. False in setters. */
    1073             :   false,  /* isMovable.  Not relevant for setters. */
    1074             :   false, /* isEliminatable.  Not relevant for setters. */
    1075             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1076             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1077             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1078             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1079             : };
    1080             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1081             : static_assert(0 < 1, "There is no slot for us");
    1082             : 
    1083             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1084             : #if defined(__clang__)
    1085             : #pragma clang diagnostic push
    1086             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1087             : #endif
    1088             : static const JSPropertySpec sAttributes_specs[] = {
    1089             :   { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, nullptr, nullptr },
    1090             :   { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, nullptr, nullptr },
    1091             :   { "z", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &z_getterinfo, nullptr, nullptr },
    1092             :   { "w", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &w_getterinfo, nullptr, nullptr },
    1093             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1094             : };
    1095             : #if defined(__clang__)
    1096             : #pragma clang diagnostic pop
    1097             : #endif
    1098             : 
    1099             : 
    1100             : // Can't be const because the pref-enabled boolean needs to be writable
    1101             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1102             :   { nullptr, &sAttributes_specs[0] },
    1103             :   { nullptr, nullptr }
    1104             : };
    1105             : 
    1106             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1107             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1108             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1109             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1110             : 
    1111             : 
    1112             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
    1113             : static PropertyInfo sNativeProperties_propertyInfos[4];
    1114             : 
    1115             : static const NativePropertiesN<1> sNativeProperties = {
    1116             :   false, 0,
    1117             :   false, 0,
    1118             :   false, 0,
    1119             :   true,  0 /* sAttributes */,
    1120             :   false, 0,
    1121             :   false, 0,
    1122             :   false, 0,
    1123             :   -1,
    1124             :   4,
    1125             :   sNativeProperties_sortedPropertyIndices,
    1126             :   {
    1127             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
    1128             :   }
    1129             : };
    1130             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1131             :     "We have a property info count that is oversized");
    1132             : 
    1133             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1134             :   {
    1135             :     "Function",
    1136             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1137             :     &sBoringInterfaceObjectClassClassOps,
    1138             :     JS_NULL_CLASS_SPEC,
    1139             :     JS_NULL_CLASS_EXT,
    1140             :     &sInterfaceObjectClassObjectOps
    1141             :   },
    1142             :   eInterface,
    1143             :   true,
    1144             :   prototypes::id::DOMPointReadOnly,
    1145             :   PrototypeTraits<prototypes::id::DOMPointReadOnly>::Depth,
    1146             :   sNativePropertyHooks,
    1147             :   "function DOMPointReadOnly() {\n    [native code]\n}",
    1148             :   JS::GetRealmFunctionPrototype
    1149             : };
    1150             : 
    1151             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1152             :   {
    1153             :     "DOMPointReadOnlyPrototype",
    1154             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1155             :     JS_NULL_CLASS_OPS,
    1156             :     JS_NULL_CLASS_SPEC,
    1157             :     JS_NULL_CLASS_EXT,
    1158             :     JS_NULL_OBJECT_OPS
    1159             :   },
    1160             :   eInterfacePrototype,
    1161             :   false,
    1162             :   prototypes::id::DOMPointReadOnly,
    1163             :   PrototypeTraits<prototypes::id::DOMPointReadOnly>::Depth,
    1164             :   sNativePropertyHooks,
    1165             :   "[object DOMPointReadOnlyPrototype]",
    1166             :   JS::GetRealmObjectPrototype
    1167             : };
    1168             : 
    1169             : bool
    1170           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1171             : {
    1172             :   static bool sPrefValue;
    1173             :   static bool sPrefCacheSetUp = false;
    1174           0 :   if (!sPrefCacheSetUp) {
    1175           0 :     sPrefCacheSetUp = true;
    1176           0 :     Preferences::AddBoolVarCache(&sPrefValue, "layout.css.DOMPoint.enabled");
    1177             :   }
    1178             : 
    1179           0 :   return sPrefValue;
    1180             : }
    1181             : 
    1182             : JSObject*
    1183           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1184             : {
    1185           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1186             : }
    1187             : 
    1188             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1189             :   nullptr,
    1190             :   nullptr,
    1191             :   nullptr,
    1192             :   { sNativeProperties.Upcast(), nullptr },
    1193             :   prototypes::id::DOMPointReadOnly,
    1194             :   constructors::id::DOMPointReadOnly,
    1195             :   nullptr,
    1196             :   &DefaultXrayExpandoObjectClass
    1197             : } };
    1198             : 
    1199             : void
    1200           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1201             : {
    1202           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1203           0 :   if (!parentProto) {
    1204           0 :     return;
    1205             :   }
    1206             : 
    1207           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1208           0 :   if (!constructorProto) {
    1209           0 :     return;
    1210             :   }
    1211             : 
    1212             :   static bool sIdsInited = false;
    1213           0 :   if (!sIdsInited && NS_IsMainThread()) {
    1214           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1215           0 :       return;
    1216             :     }
    1217           0 :     sIdsInited = true;
    1218             :   }
    1219             : 
    1220           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DOMPointReadOnly);
    1221           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DOMPointReadOnly);
    1222           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1223             :                               &sPrototypeClass.mBase, protoCache,
    1224             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1225             :                               interfaceCache,
    1226             :                               sNativeProperties.Upcast(),
    1227             :                               nullptr,
    1228             :                               "DOMPointReadOnly", aDefineOnGlobal,
    1229             :                               nullptr,
    1230           0 :                               false);
    1231             : }
    1232             : 
    1233             : JS::Handle<JSObject*>
    1234           0 : GetProtoObjectHandle(JSContext* aCx)
    1235             : {
    1236             :   /* Get the interface prototype object for this class.  This will create the
    1237             :      object as needed. */
    1238           0 :   bool aDefineOnGlobal = true;
    1239             : 
    1240             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1241           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1242           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1243           0 :     return nullptr;
    1244             :   }
    1245             : 
    1246             :   /* Check to see whether the interface objects are already installed */
    1247           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1248           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DOMPointReadOnly)) {
    1249           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1250           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1251             :   }
    1252             : 
    1253             :   /*
    1254             :    * The object might _still_ be null, but that's OK.
    1255             :    *
    1256             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1257             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1258             :    * changed after they have been set.
    1259             :    *
    1260             :    * Calling address() avoids the read read barrier that does gray
    1261             :    * unmarking, but it's not possible for the object to be gray here.
    1262             :    */
    1263             : 
    1264           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DOMPointReadOnly);
    1265           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1266           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1267             : }
    1268             : 
    1269             : JSObject*
    1270           0 : GetProtoObject(JSContext* aCx)
    1271             : {
    1272           0 :   return GetProtoObjectHandle(aCx);
    1273             : }
    1274             : 
    1275             : JS::Handle<JSObject*>
    1276           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1277             : {
    1278             :   /* Get the interface object for this class.  This will create the object as
    1279             :      needed. */
    1280             : 
    1281             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1282           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1283           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1284           0 :     return nullptr;
    1285             :   }
    1286             : 
    1287             :   /* Check to see whether the interface objects are already installed */
    1288           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1289           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DOMPointReadOnly)) {
    1290           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1291           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1292             :   }
    1293             : 
    1294             :   /*
    1295             :    * The object might _still_ be null, but that's OK.
    1296             :    *
    1297             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1298             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1299             :    * changed after they have been set.
    1300             :    *
    1301             :    * Calling address() avoids the read read barrier that does gray
    1302             :    * unmarking, but it's not possible for the object to be gray here.
    1303             :    */
    1304             : 
    1305           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DOMPointReadOnly);
    1306           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1307           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1308             : }
    1309             : 
    1310             : JSObject*
    1311           0 : GetConstructorObject(JSContext* aCx)
    1312             : {
    1313           0 :   return GetConstructorObjectHandle(aCx);
    1314             : }
    1315             : 
    1316             : } // namespace DOMPointReadOnlyBinding
    1317             : 
    1318             : 
    1319             : 
    1320             : } // namespace dom
    1321             : } // namespace mozilla

Generated by: LCOV version 1.13