LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - BoxObjectBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 72 267 27.0 %
Date: 2017-07-14 16:53:18 Functions: 6 29 20.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM BoxObject.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "BoxObjectBinding.h"
       4             : #include "WrapperFactory.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/BoxObject.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/Element.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/Nullable.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : #include "nsISupports.h"
      15             : #include "xpcjsid.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : namespace BoxObjectBinding {
      21             : 
      22             : static bool
      23           0 : get_element(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
      24             : {
      25           0 :   auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetElement()));
      26           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      27           0 :   if (!result) {
      28           0 :     args.rval().setNull();
      29           0 :     return true;
      30             :   }
      31           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      32           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      33           0 :     return false;
      34             :   }
      35           0 :   return true;
      36             : }
      37             : 
      38             : static const JSJitInfo element_getterinfo = {
      39             :   { (JSJitGetterOp)get_element },
      40             :   { prototypes::id::BoxObject },
      41             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
      42             :   JSJitInfo::Getter,
      43             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      44             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      45             :   false,  /* isInfallible. False in setters. */
      46             :   false,  /* isMovable.  Not relevant for setters. */
      47             :   false, /* isEliminatable.  Not relevant for setters. */
      48             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      49             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      50             :   false,  /* isTypedMethod.  Only relevant for methods. */
      51             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      52             : };
      53             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      54             : static_assert(0 < 1, "There is no slot for us");
      55             : 
      56             : static bool
      57           0 : get_x(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
      58             : {
      59           0 :   int32_t result(self->X());
      60           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      61           0 :   args.rval().setInt32(int32_t(result));
      62           0 :   return true;
      63             : }
      64             : 
      65             : static const JSJitInfo x_getterinfo = {
      66             :   { (JSJitGetterOp)get_x },
      67             :   { prototypes::id::BoxObject },
      68             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
      69             :   JSJitInfo::Getter,
      70             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      71             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
      72             :   true,  /* isInfallible. False in setters. */
      73             :   false,  /* isMovable.  Not relevant for setters. */
      74             :   false, /* isEliminatable.  Not relevant for setters. */
      75             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      76             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      77             :   false,  /* isTypedMethod.  Only relevant for methods. */
      78             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      79             : };
      80             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      81             : static_assert(0 < 1, "There is no slot for us");
      82             : 
      83             : static bool
      84           0 : get_y(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
      85             : {
      86           0 :   int32_t result(self->Y());
      87           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      88           0 :   args.rval().setInt32(int32_t(result));
      89           0 :   return true;
      90             : }
      91             : 
      92             : static const JSJitInfo y_getterinfo = {
      93             :   { (JSJitGetterOp)get_y },
      94             :   { prototypes::id::BoxObject },
      95             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
      96             :   JSJitInfo::Getter,
      97             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      98             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
      99             :   true,  /* isInfallible. False in setters. */
     100             :   false,  /* isMovable.  Not relevant for setters. */
     101             :   false, /* isEliminatable.  Not relevant for setters. */
     102             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     103             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     104             :   false,  /* isTypedMethod.  Only relevant for methods. */
     105             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     106             : };
     107             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     108             : static_assert(0 < 1, "There is no slot for us");
     109             : 
     110             : static bool
     111           0 : get_screenX(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     112             : {
     113           0 :   binding_detail::FastErrorResult rv;
     114           0 :   int32_t result(self->GetScreenX(rv));
     115           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     116           0 :     return false;
     117             :   }
     118           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     119           0 :   args.rval().setInt32(int32_t(result));
     120           0 :   return true;
     121             : }
     122             : 
     123             : static const JSJitInfo screenX_getterinfo = {
     124             :   { (JSJitGetterOp)get_screenX },
     125             :   { prototypes::id::BoxObject },
     126             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     127             :   JSJitInfo::Getter,
     128             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     129             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     130             :   false,  /* isInfallible. False in setters. */
     131             :   false,  /* isMovable.  Not relevant for setters. */
     132             :   false, /* isEliminatable.  Not relevant for setters. */
     133             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     134             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     135             :   false,  /* isTypedMethod.  Only relevant for methods. */
     136             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     137             : };
     138             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     139             : static_assert(0 < 1, "There is no slot for us");
     140             : 
     141             : static bool
     142           0 : get_screenY(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     143             : {
     144           0 :   binding_detail::FastErrorResult rv;
     145           0 :   int32_t result(self->GetScreenY(rv));
     146           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     147           0 :     return false;
     148             :   }
     149           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     150           0 :   args.rval().setInt32(int32_t(result));
     151           0 :   return true;
     152             : }
     153             : 
     154             : static const JSJitInfo screenY_getterinfo = {
     155             :   { (JSJitGetterOp)get_screenY },
     156             :   { prototypes::id::BoxObject },
     157             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     158             :   JSJitInfo::Getter,
     159             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     160             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     161             :   false,  /* isInfallible. False in setters. */
     162             :   false,  /* isMovable.  Not relevant for setters. */
     163             :   false, /* isEliminatable.  Not relevant for setters. */
     164             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     165             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     166             :   false,  /* isTypedMethod.  Only relevant for methods. */
     167             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     168             : };
     169             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     170             : static_assert(0 < 1, "There is no slot for us");
     171             : 
     172             : static bool
     173           2 : get_width(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     174             : {
     175           2 :   int32_t result(self->Width());
     176           2 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     177           2 :   args.rval().setInt32(int32_t(result));
     178           2 :   return true;
     179             : }
     180             : 
     181             : static const JSJitInfo width_getterinfo = {
     182             :   { (JSJitGetterOp)get_width },
     183             :   { prototypes::id::BoxObject },
     184             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     185             :   JSJitInfo::Getter,
     186             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     187             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     188             :   true,  /* isInfallible. False in setters. */
     189             :   false,  /* isMovable.  Not relevant for setters. */
     190             :   false, /* isEliminatable.  Not relevant for setters. */
     191             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     192             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     193             :   false,  /* isTypedMethod.  Only relevant for methods. */
     194             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     195             : };
     196             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     197             : static_assert(0 < 1, "There is no slot for us");
     198             : 
     199             : static bool
     200           0 : get_height(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     201             : {
     202           0 :   int32_t result(self->Height());
     203           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     204           0 :   args.rval().setInt32(int32_t(result));
     205           0 :   return true;
     206             : }
     207             : 
     208             : static const JSJitInfo height_getterinfo = {
     209             :   { (JSJitGetterOp)get_height },
     210             :   { prototypes::id::BoxObject },
     211             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     212             :   JSJitInfo::Getter,
     213             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     214             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
     215             :   true,  /* isInfallible. False in setters. */
     216             :   false,  /* isMovable.  Not relevant for setters. */
     217             :   false, /* isEliminatable.  Not relevant for setters. */
     218             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     219             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     220             :   false,  /* isTypedMethod.  Only relevant for methods. */
     221             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     222             : };
     223             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     224             : static_assert(0 < 1, "There is no slot for us");
     225             : 
     226             : static bool
     227           0 : getPropertyAsSupports(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, const JSJitMethodCallArgs& args)
     228             : {
     229           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     230           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BoxObject.getPropertyAsSupports");
     231             :   }
     232           0 :   binding_detail::FakeString arg0;
     233           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     234           0 :     return false;
     235             :   }
     236           0 :   auto result(StrongOrRawPtr<nsISupports>(self->GetPropertyAsSupports(NonNullHelper(Constify(arg0)))));
     237           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     238           0 :   if (!result) {
     239           0 :     args.rval().setNull();
     240           0 :     return true;
     241             :   }
     242           0 :   if (!WrapObject(cx, result, args.rval())) {
     243           0 :     return false;
     244             :   }
     245           0 :   return true;
     246             : }
     247             : 
     248             : static const JSJitInfo getPropertyAsSupports_methodinfo = {
     249             :   { (JSJitGetterOp)getPropertyAsSupports },
     250             :   { prototypes::id::BoxObject },
     251             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     252             :   JSJitInfo::Method,
     253             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     254             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     255             :   false,  /* isInfallible. False in setters. */
     256             :   false,  /* isMovable.  Not relevant for setters. */
     257             :   false, /* isEliminatable.  Not relevant for setters. */
     258             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     259             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     260             :   false,  /* isTypedMethod.  Only relevant for methods. */
     261             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     262             : };
     263             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     264             : static_assert(0 < 1, "There is no slot for us");
     265             : 
     266             : static bool
     267           0 : setPropertyAsSupports(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, const JSJitMethodCallArgs& args)
     268             : {
     269           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     270           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BoxObject.setPropertyAsSupports");
     271             :   }
     272           0 :   binding_detail::FakeString arg0;
     273           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     274           0 :     return false;
     275             :   }
     276             :   nsISupports* arg1;
     277           0 :   RefPtr<nsISupports> arg1_holder;
     278           0 :   if (args[1].isObject()) {
     279           0 :     JS::Rooted<JSObject*> source(cx, &args[1].toObject());
     280           0 :     if (NS_FAILED(UnwrapArg<nsISupports>(cx, source, getter_AddRefs(arg1_holder)))) {
     281           0 :       ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of BoxObject.setPropertyAsSupports", "nsISupports");
     282           0 :       return false;
     283             :     }
     284           0 :     MOZ_ASSERT(arg1_holder);
     285           0 :     arg1 = arg1_holder;
     286             :   } else {
     287           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of BoxObject.setPropertyAsSupports");
     288           0 :     return false;
     289             :   }
     290           0 :   self->SetPropertyAsSupports(NonNullHelper(Constify(arg0)), NonNullHelper(arg1));
     291           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     292           0 :   args.rval().setUndefined();
     293           0 :   return true;
     294             : }
     295             : 
     296             : static const JSJitInfo setPropertyAsSupports_methodinfo = {
     297             :   { (JSJitGetterOp)setPropertyAsSupports },
     298             :   { prototypes::id::BoxObject },
     299             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     300             :   JSJitInfo::Method,
     301             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     302             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     303             :   false,  /* isInfallible. False in setters. */
     304             :   false,  /* isMovable.  Not relevant for setters. */
     305             :   false, /* isEliminatable.  Not relevant for setters. */
     306             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     307             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     308             :   false,  /* isTypedMethod.  Only relevant for methods. */
     309             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     310             : };
     311             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     312             : static_assert(0 < 1, "There is no slot for us");
     313             : 
     314             : static bool
     315           2 : getProperty(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, const JSJitMethodCallArgs& args)
     316             : {
     317           2 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     318           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BoxObject.getProperty");
     319             :   }
     320           4 :   binding_detail::FakeString arg0;
     321           2 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     322           0 :     return false;
     323             :   }
     324           4 :   binding_detail::FastErrorResult rv;
     325           4 :   DOMString result;
     326           2 :   self->GetProperty(NonNullHelper(Constify(arg0)), result, rv);
     327           2 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     328           0 :     return false;
     329             :   }
     330           2 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     331           2 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
     332           0 :     return false;
     333             :   }
     334           2 :   return true;
     335             : }
     336             : 
     337             : static const JSJitInfo getProperty_methodinfo = {
     338             :   { (JSJitGetterOp)getProperty },
     339             :   { prototypes::id::BoxObject },
     340             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     341             :   JSJitInfo::Method,
     342             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     343             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     344             :   false,  /* isInfallible. False in setters. */
     345             :   false,  /* isMovable.  Not relevant for setters. */
     346             :   false, /* isEliminatable.  Not relevant for setters. */
     347             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     348             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     349             :   false,  /* isTypedMethod.  Only relevant for methods. */
     350             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     351             : };
     352             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     353             : static_assert(0 < 1, "There is no slot for us");
     354             : 
     355             : static bool
     356           0 : setProperty(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, const JSJitMethodCallArgs& args)
     357             : {
     358           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     359           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BoxObject.setProperty");
     360             :   }
     361           0 :   binding_detail::FakeString arg0;
     362           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     363           0 :     return false;
     364             :   }
     365           0 :   binding_detail::FakeString arg1;
     366           0 :   if (!ConvertJSValueToString(cx, args[1], eStringify, eStringify, arg1)) {
     367           0 :     return false;
     368             :   }
     369           0 :   self->SetProperty(NonNullHelper(Constify(arg0)), NonNullHelper(Constify(arg1)));
     370           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     371           0 :   args.rval().setUndefined();
     372           0 :   return true;
     373             : }
     374             : 
     375             : static const JSJitInfo setProperty_methodinfo = {
     376             :   { (JSJitGetterOp)setProperty },
     377             :   { prototypes::id::BoxObject },
     378             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     379             :   JSJitInfo::Method,
     380             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     381             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     382             :   false,  /* isInfallible. False in setters. */
     383             :   false,  /* isMovable.  Not relevant for setters. */
     384             :   false, /* isEliminatable.  Not relevant for setters. */
     385             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     386             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     387             :   false,  /* isTypedMethod.  Only relevant for methods. */
     388             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     389             : };
     390             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     391             : static_assert(0 < 1, "There is no slot for us");
     392             : 
     393             : static bool
     394           0 : removeProperty(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, const JSJitMethodCallArgs& args)
     395             : {
     396           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     397           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BoxObject.removeProperty");
     398             :   }
     399           0 :   binding_detail::FakeString arg0;
     400           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     401           0 :     return false;
     402             :   }
     403           0 :   self->RemoveProperty(NonNullHelper(Constify(arg0)));
     404           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     405           0 :   args.rval().setUndefined();
     406           0 :   return true;
     407             : }
     408             : 
     409             : static const JSJitInfo removeProperty_methodinfo = {
     410             :   { (JSJitGetterOp)removeProperty },
     411             :   { prototypes::id::BoxObject },
     412             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     413             :   JSJitInfo::Method,
     414             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     415             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     416             :   false,  /* 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             : 
     427             : static bool
     428           0 : get_parentBox(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     429             : {
     430           0 :   auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetParentBox()));
     431           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     432           0 :   if (!result) {
     433           0 :     args.rval().setNull();
     434           0 :     return true;
     435             :   }
     436           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     437           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     438           0 :     return false;
     439             :   }
     440           0 :   return true;
     441             : }
     442             : 
     443             : static const JSJitInfo parentBox_getterinfo = {
     444             :   { (JSJitGetterOp)get_parentBox },
     445             :   { prototypes::id::BoxObject },
     446             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     447             :   JSJitInfo::Getter,
     448             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     449             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     450             :   false,  /* isInfallible. False in setters. */
     451             :   false,  /* isMovable.  Not relevant for setters. */
     452             :   false, /* isEliminatable.  Not relevant for setters. */
     453             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     454             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     455             :   false,  /* isTypedMethod.  Only relevant for methods. */
     456             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     457             : };
     458             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     459             : static_assert(0 < 1, "There is no slot for us");
     460             : 
     461             : static bool
     462           0 : get_firstChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     463             : {
     464           0 :   auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetFirstChild()));
     465           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     466           0 :   if (!result) {
     467           0 :     args.rval().setNull();
     468           0 :     return true;
     469             :   }
     470           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     471           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     472           0 :     return false;
     473             :   }
     474           0 :   return true;
     475             : }
     476             : 
     477             : static const JSJitInfo firstChild_getterinfo = {
     478             :   { (JSJitGetterOp)get_firstChild },
     479             :   { prototypes::id::BoxObject },
     480             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     481             :   JSJitInfo::Getter,
     482             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     483             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     484             :   false,  /* isInfallible. False in setters. */
     485             :   false,  /* isMovable.  Not relevant for setters. */
     486             :   false, /* isEliminatable.  Not relevant for setters. */
     487             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     488             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     489             :   false,  /* isTypedMethod.  Only relevant for methods. */
     490             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     491             : };
     492             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     493             : static_assert(0 < 1, "There is no slot for us");
     494             : 
     495             : static bool
     496           0 : get_lastChild(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     497             : {
     498           0 :   auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetLastChild()));
     499           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     500           0 :   if (!result) {
     501           0 :     args.rval().setNull();
     502           0 :     return true;
     503             :   }
     504           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     505           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     506           0 :     return false;
     507             :   }
     508           0 :   return true;
     509             : }
     510             : 
     511             : static const JSJitInfo lastChild_getterinfo = {
     512             :   { (JSJitGetterOp)get_lastChild },
     513             :   { prototypes::id::BoxObject },
     514             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     515             :   JSJitInfo::Getter,
     516             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     517             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     518             :   false,  /* isInfallible. False in setters. */
     519             :   false,  /* isMovable.  Not relevant for setters. */
     520             :   false, /* isEliminatable.  Not relevant for setters. */
     521             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     522             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     523             :   false,  /* isTypedMethod.  Only relevant for methods. */
     524             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     525             : };
     526             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     527             : static_assert(0 < 1, "There is no slot for us");
     528             : 
     529             : static bool
     530           0 : get_nextSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     531             : {
     532           0 :   auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetNextSibling()));
     533           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     534           0 :   if (!result) {
     535           0 :     args.rval().setNull();
     536           0 :     return true;
     537             :   }
     538           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     539           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     540           0 :     return false;
     541             :   }
     542           0 :   return true;
     543             : }
     544             : 
     545             : static const JSJitInfo nextSibling_getterinfo = {
     546             :   { (JSJitGetterOp)get_nextSibling },
     547             :   { prototypes::id::BoxObject },
     548             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     549             :   JSJitInfo::Getter,
     550             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     551             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     552             :   false,  /* isInfallible. False in setters. */
     553             :   false,  /* isMovable.  Not relevant for setters. */
     554             :   false, /* isEliminatable.  Not relevant for setters. */
     555             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     556             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     557             :   false,  /* isTypedMethod.  Only relevant for methods. */
     558             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     559             : };
     560             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     561             : static_assert(0 < 1, "There is no slot for us");
     562             : 
     563             : static bool
     564           0 : get_previousSibling(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::BoxObject* self, JSJitGetterCallArgs args)
     565             : {
     566           0 :   auto result(StrongOrRawPtr<mozilla::dom::Element>(self->GetPreviousSibling()));
     567           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     568           0 :   if (!result) {
     569           0 :     args.rval().setNull();
     570           0 :     return true;
     571             :   }
     572           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     573           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     574           0 :     return false;
     575             :   }
     576           0 :   return true;
     577             : }
     578             : 
     579             : static const JSJitInfo previousSibling_getterinfo = {
     580             :   { (JSJitGetterOp)get_previousSibling },
     581             :   { prototypes::id::BoxObject },
     582             :   { PrototypeTraits<prototypes::id::BoxObject>::Depth },
     583             :   JSJitInfo::Getter,
     584             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     585             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     586             :   false,  /* isInfallible. False in setters. */
     587             :   false,  /* isMovable.  Not relevant for setters. */
     588             :   false, /* isEliminatable.  Not relevant for setters. */
     589             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     590             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     591             :   false,  /* isTypedMethod.  Only relevant for methods. */
     592             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     593             : };
     594             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     595             : static_assert(0 < 1, "There is no slot for us");
     596             : 
     597             : static bool
     598           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     599             : {
     600           0 :   mozilla::dom::BoxObject* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::BoxObject>(obj);
     601             :   // We don't want to preserve if we don't have a wrapper, and we
     602             :   // obviously can't preserve if we're not initialized.
     603           0 :   if (self && self->GetWrapperPreserveColor()) {
     604           0 :     PreserveWrapper(self);
     605             :   }
     606           0 :   return true;
     607             : }
     608             : 
     609             : static void
     610           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     611             : {
     612           0 :   mozilla::dom::BoxObject* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::BoxObject>(obj);
     613           0 :   if (self) {
     614           0 :     ClearWrapper(self, self, obj);
     615           0 :     AddForDeferredFinalization<mozilla::dom::BoxObject>(self);
     616             :   }
     617           0 : }
     618             : 
     619             : static void
     620           0 : _objectMoved(JSObject* obj, const JSObject* old)
     621             : {
     622           0 :   mozilla::dom::BoxObject* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::BoxObject>(obj);
     623           0 :   if (self) {
     624           0 :     UpdateWrapper(self, self, obj, old);
     625             :   }
     626           0 : }
     627             : 
     628             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     629             : #if defined(__clang__)
     630             : #pragma clang diagnostic push
     631             : #pragma clang diagnostic ignored "-Wmissing-braces"
     632             : #endif
     633             : static const JSFunctionSpec sMethods_specs[] = {
     634             :   JS_FNSPEC("getPropertyAsSupports", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getPropertyAsSupports_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     635             :   JS_FNSPEC("setPropertyAsSupports", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setPropertyAsSupports_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     636             :   JS_FNSPEC("getProperty", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getProperty_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     637             :   JS_FNSPEC("setProperty", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setProperty_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     638             :   JS_FNSPEC("removeProperty", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&removeProperty_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     639             :   JS_FS_END,
     640             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
     641             :   JS_FS_END
     642             : };
     643             : #if defined(__clang__)
     644             : #pragma clang diagnostic pop
     645             : #endif
     646             : 
     647             : static PrefableDisablers sMethods_disablers6 = {
     648             :   true, false, 0, &WantsQueryInterface<mozilla::dom::BoxObject>::Enabled
     649             : };
     650             : 
     651             : // Can't be const because the pref-enabled boolean needs to be writable
     652             : static Prefable<const JSFunctionSpec> sMethods[] = {
     653             :   { nullptr, &sMethods_specs[0] },
     654             :   { &sMethods_disablers6, &sMethods_specs[6] },
     655             :   { nullptr, nullptr }
     656             : };
     657             : 
     658             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     659             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     660             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     661             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     662             : 
     663             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     664             : #if defined(__clang__)
     665             : #pragma clang diagnostic push
     666             : #pragma clang diagnostic ignored "-Wmissing-braces"
     667             : #endif
     668             : static const JSPropertySpec sAttributes_specs[] = {
     669             :   { "element", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &element_getterinfo, nullptr, nullptr },
     670             :   { "x", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &x_getterinfo, nullptr, nullptr },
     671             :   { "y", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &y_getterinfo, nullptr, nullptr },
     672             :   { "screenX", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &screenX_getterinfo, nullptr, nullptr },
     673             :   { "screenY", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &screenY_getterinfo, nullptr, nullptr },
     674             :   { "width", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &width_getterinfo, nullptr, nullptr },
     675             :   { "height", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &height_getterinfo, nullptr, nullptr },
     676             :   { "parentBox", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &parentBox_getterinfo, nullptr, nullptr },
     677             :   { "firstChild", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &firstChild_getterinfo, nullptr, nullptr },
     678             :   { "lastChild", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &lastChild_getterinfo, nullptr, nullptr },
     679             :   { "nextSibling", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &nextSibling_getterinfo, nullptr, nullptr },
     680             :   { "previousSibling", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &previousSibling_getterinfo, nullptr, nullptr },
     681             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     682             : };
     683             : #if defined(__clang__)
     684             : #pragma clang diagnostic pop
     685             : #endif
     686             : 
     687             : 
     688             : // Can't be const because the pref-enabled boolean needs to be writable
     689             : static Prefable<const JSPropertySpec> sAttributes[] = {
     690             :   { nullptr, &sAttributes_specs[0] },
     691             :   { nullptr, nullptr }
     692             : };
     693             : 
     694             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     695             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     696             : static_assert(12 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     697             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     698             : 
     699             : 
     700             : static uint16_t sNativeProperties_sortedPropertyIndices[18];
     701             : static PropertyInfo sNativeProperties_propertyInfos[18];
     702             : 
     703             : static const NativePropertiesN<2> sNativeProperties = {
     704             :   false, 0,
     705             :   false, 0,
     706             :   true,  0 /* sMethods */,
     707             :   true,  1 /* sAttributes */,
     708             :   false, 0,
     709             :   false, 0,
     710             :   false, 0,
     711             :   -1,
     712             :   18,
     713             :   sNativeProperties_sortedPropertyIndices,
     714             :   {
     715             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     716             :     { sAttributes, &sNativeProperties_propertyInfos[6] }
     717             :   }
     718             : };
     719             : static_assert(18 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     720             :     "We have a property info count that is oversized");
     721             : 
     722             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     723             :   {
     724             :     "Function",
     725             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     726             :     &sBoringInterfaceObjectClassClassOps,
     727             :     JS_NULL_CLASS_SPEC,
     728             :     JS_NULL_CLASS_EXT,
     729             :     &sInterfaceObjectClassObjectOps
     730             :   },
     731             :   eInterface,
     732             :   true,
     733             :   prototypes::id::BoxObject,
     734             :   PrototypeTraits<prototypes::id::BoxObject>::Depth,
     735             :   sNativePropertyHooks,
     736             :   "function BoxObject() {\n    [native code]\n}",
     737             :   JS::GetRealmFunctionPrototype
     738             : };
     739             : 
     740             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     741             :   {
     742             :     "BoxObjectPrototype",
     743             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     744             :     JS_NULL_CLASS_OPS,
     745             :     JS_NULL_CLASS_SPEC,
     746             :     JS_NULL_CLASS_EXT,
     747             :     JS_NULL_OBJECT_OPS
     748             :   },
     749             :   eInterfacePrototype,
     750             :   false,
     751             :   prototypes::id::BoxObject,
     752             :   PrototypeTraits<prototypes::id::BoxObject>::Depth,
     753             :   sNativePropertyHooks,
     754             :   "[object BoxObjectPrototype]",
     755             :   JS::GetRealmObjectPrototype
     756             : };
     757             : 
     758             : bool
     759           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     760             : {
     761           0 :   return IsChromeOrXBL(aCx, aObj);
     762             : }
     763             : 
     764             : JSObject*
     765           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     766             : {
     767           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     768             : }
     769             : 
     770             : static const js::ClassOps sClassOps = {
     771             :   _addProperty, /* addProperty */
     772             :   nullptr,               /* delProperty */
     773             :   nullptr,               /* getProperty */
     774             :   nullptr,               /* setProperty */
     775             :   nullptr,               /* enumerate */
     776             :   nullptr, /* newEnumerate */
     777             :   nullptr, /* resolve */
     778             :   nullptr, /* mayResolve */
     779             :   _finalize, /* finalize */
     780             :   nullptr, /* call */
     781             :   nullptr,               /* hasInstance */
     782             :   nullptr,               /* construct */
     783             :   nullptr, /* trace */
     784             : };
     785             : 
     786             : static const js::ClassExtension sClassExtension = {
     787             :   nullptr, /* weakmapKeyDelegateOp */
     788             :   _objectMoved /* objectMovedOp */
     789             : };
     790             : 
     791             : static const DOMJSClass sClass = {
     792             :   { "BoxObject",
     793             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     794             :     &sClassOps,
     795             :     JS_NULL_CLASS_SPEC,
     796             :     &sClassExtension,
     797             :     JS_NULL_OBJECT_OPS
     798             :   },
     799             :   { prototypes::id::BoxObject, 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 },
     800             :   IsBaseOf<nsISupports, mozilla::dom::BoxObject >::value,
     801             :   sNativePropertyHooks,
     802             :   FindAssociatedGlobalForNative<mozilla::dom::BoxObject>::Get,
     803             :   GetProtoObjectHandle,
     804             :   GetCCParticipant<mozilla::dom::BoxObject>::Get()
     805             : };
     806             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     807             :               "Must have the right minimal number of reserved slots.");
     808             : static_assert(1 >= 1,
     809             :               "Must have enough reserved slots.");
     810             : 
     811             : const JSClass*
     812           0 : GetJSClass()
     813             : {
     814           0 :   return sClass.ToJSClass();
     815             : }
     816             : 
     817             : bool
     818           4 : Wrap(JSContext* aCx, mozilla::dom::BoxObject* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     819             : {
     820             :   MOZ_ASSERT(static_cast<mozilla::dom::BoxObject*>(aObject) ==
     821             :              reinterpret_cast<mozilla::dom::BoxObject*>(aObject),
     822             :              "Multiple inheritance for mozilla::dom::BoxObject is broken.");
     823           4 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     824           4 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     825           4 :   MOZ_ASSERT(!aCache->GetWrapper(),
     826             :              "You should probably not be using Wrap() directly; use "
     827             :              "GetOrCreateDOMReflector instead");
     828             : 
     829           4 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     830             :              "nsISupports must be on our primary inheritance chain");
     831             : 
     832           8 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     833           4 :   if (!global) {
     834           0 :     return false;
     835             :   }
     836           4 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     837           4 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     838             : 
     839             :   // That might have ended up wrapping us already, due to the wonders
     840             :   // of XBL.  Check for that, and bail out as needed.
     841           4 :   aReflector.set(aCache->GetWrapper());
     842           4 :   if (aReflector) {
     843             : #ifdef DEBUG
     844           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     845             : #endif // DEBUG
     846           0 :     return true;
     847             :   }
     848             : 
     849           8 :   JSAutoCompartment ac(aCx, global);
     850           4 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     851           4 :   if (!canonicalProto) {
     852           0 :     return false;
     853             :   }
     854           8 :   JS::Rooted<JSObject*> proto(aCx);
     855           4 :   if (aGivenProto) {
     856           0 :     proto = aGivenProto;
     857             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     858             :     // coming in, we changed compartments to that of "parent" so may need
     859             :     // to wrap the proto here.
     860           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     861           0 :       if (!JS_WrapObject(aCx, &proto)) {
     862           0 :         return false;
     863             :       }
     864             :     }
     865             :   } else {
     866           4 :     proto = canonicalProto;
     867             :   }
     868             : 
     869           8 :   BindingJSObjectCreator<mozilla::dom::BoxObject> creator(aCx);
     870           4 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     871           4 :   if (!aReflector) {
     872           0 :     return false;
     873             :   }
     874             : 
     875           4 :   aCache->SetWrapper(aReflector);
     876           4 :   creator.InitializationSucceeded();
     877             : 
     878           4 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     879             :              aCache->GetWrapperPreserveColor() == aReflector);
     880             :   // If proto != canonicalProto, we have to preserve our wrapper;
     881             :   // otherwise we won't be able to properly recreate it later, since
     882             :   // we won't know what proto to use.  Note that we don't check
     883             :   // aGivenProto here, since it's entirely possible (and even
     884             :   // somewhat common) to have a non-null aGivenProto which is the
     885             :   // same as canonicalProto.
     886           4 :   if (proto != canonicalProto) {
     887           0 :     PreserveWrapper(aObject);
     888             :   }
     889             : 
     890           4 :   return true;
     891             : }
     892             : 
     893             : const NativePropertyHooks sNativePropertyHooks[] = { {
     894             :   nullptr,
     895             :   nullptr,
     896             :   nullptr,
     897             :   { sNativeProperties.Upcast(), nullptr },
     898             :   prototypes::id::BoxObject,
     899             :   constructors::id::BoxObject,
     900             :   nullptr,
     901             :   &DefaultXrayExpandoObjectClass
     902             : } };
     903             : 
     904             : void
     905           1 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     906             : {
     907           2 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     908           1 :   if (!parentProto) {
     909           0 :     return;
     910             :   }
     911             : 
     912           2 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     913           1 :   if (!constructorProto) {
     914           0 :     return;
     915             :   }
     916             : 
     917             :   static bool sIdsInited = false;
     918           1 :   if (!sIdsInited && NS_IsMainThread()) {
     919           1 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     920           0 :       return;
     921             :     }
     922           1 :     sIdsInited = true;
     923             :   }
     924             : 
     925           1 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::BoxObject);
     926           1 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::BoxObject);
     927           2 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     928             :                               &sPrototypeClass.mBase, protoCache,
     929             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     930             :                               interfaceCache,
     931             :                               sNativeProperties.Upcast(),
     932             :                               nullptr,
     933             :                               "BoxObject", aDefineOnGlobal,
     934             :                               nullptr,
     935           1 :                               false);
     936             : }
     937             : 
     938             : JS::Handle<JSObject*>
     939           6 : GetProtoObjectHandle(JSContext* aCx)
     940             : {
     941             :   /* Get the interface prototype object for this class.  This will create the
     942             :      object as needed. */
     943           6 :   bool aDefineOnGlobal = true;
     944             : 
     945             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     946           6 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     947           6 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     948           0 :     return nullptr;
     949             :   }
     950             : 
     951             :   /* Check to see whether the interface objects are already installed */
     952           6 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     953           6 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::BoxObject)) {
     954           2 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     955           1 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     956             :   }
     957             : 
     958             :   /*
     959             :    * The object might _still_ be null, but that's OK.
     960             :    *
     961             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     962             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     963             :    * changed after they have been set.
     964             :    *
     965             :    * Calling address() avoids the read read barrier that does gray
     966             :    * unmarking, but it's not possible for the object to be gray here.
     967             :    */
     968             : 
     969           6 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::BoxObject);
     970           6 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     971           6 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     972             : }
     973             : 
     974             : JSObject*
     975           0 : GetProtoObject(JSContext* aCx)
     976             : {
     977           0 :   return GetProtoObjectHandle(aCx);
     978             : }
     979             : 
     980             : JS::Handle<JSObject*>
     981           2 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     982             : {
     983             :   /* Get the interface object for this class.  This will create the object as
     984             :      needed. */
     985             : 
     986             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     987           2 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     988           2 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     989           0 :     return nullptr;
     990             :   }
     991             : 
     992             :   /* Check to see whether the interface objects are already installed */
     993           2 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     994           2 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::BoxObject)) {
     995           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     996           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     997             :   }
     998             : 
     999             :   /*
    1000             :    * The object might _still_ be null, but that's OK.
    1001             :    *
    1002             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1003             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1004             :    * changed after they have been set.
    1005             :    *
    1006             :    * Calling address() avoids the read read barrier that does gray
    1007             :    * unmarking, but it's not possible for the object to be gray here.
    1008             :    */
    1009             : 
    1010           2 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::BoxObject);
    1011           2 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1012           2 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1013             : }
    1014             : 
    1015             : JSObject*
    1016           0 : GetConstructorObject(JSContext* aCx)
    1017             : {
    1018           0 :   return GetConstructorObjectHandle(aCx);
    1019             : }
    1020             : 
    1021             : } // namespace BoxObjectBinding
    1022             : 
    1023             : 
    1024             : 
    1025             : } // namespace dom
    1026             : } // namespace mozilla

Generated by: LCOV version 1.13