LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - DOMRectBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 105 435 24.1 %
Date: 2017-07-14 16:53:18 Functions: 11 44 25.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13