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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM DOMQuad.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DOMPointBinding.h"
       4             : #include "DOMQuadBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/Preferences.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/DOMPoint.h"
      11             : #include "mozilla/dom/DOMQuad.h"
      12             : #include "mozilla/dom/DOMRect.h"
      13             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      14             : #include "mozilla/dom/XrayExpandoClass.h"
      15             : 
      16             : namespace mozilla {
      17             : namespace dom {
      18             : 
      19             : namespace DOMQuadBinding {
      20             : 
      21             : static bool
      22           0 : get_p1(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMQuad* self, JSJitGetterCallArgs args)
      23             : {
      24           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(self->P1()));
      25           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      26           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      27           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      28           0 :     return false;
      29             :   }
      30           0 :   return true;
      31             : }
      32             : 
      33             : static const JSJitInfo p1_getterinfo = {
      34             :   { (JSJitGetterOp)get_p1 },
      35             :   { prototypes::id::DOMQuad },
      36             :   { PrototypeTraits<prototypes::id::DOMQuad>::Depth },
      37             :   JSJitInfo::Getter,
      38             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      39             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      40             :   false,  /* isInfallible. False in setters. */
      41             :   true,  /* isMovable.  Not relevant for setters. */
      42             :   true, /* isEliminatable.  Not relevant for setters. */
      43             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      44             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      45             :   false,  /* isTypedMethod.  Only relevant for methods. */
      46             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      47             : };
      48             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      49             : static_assert(0 < 1, "There is no slot for us");
      50             : 
      51             : static bool
      52           0 : get_p2(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMQuad* self, JSJitGetterCallArgs args)
      53             : {
      54           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(self->P2()));
      55           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      56           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      57           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      58           0 :     return false;
      59             :   }
      60           0 :   return true;
      61             : }
      62             : 
      63             : static const JSJitInfo p2_getterinfo = {
      64             :   { (JSJitGetterOp)get_p2 },
      65             :   { prototypes::id::DOMQuad },
      66             :   { PrototypeTraits<prototypes::id::DOMQuad>::Depth },
      67             :   JSJitInfo::Getter,
      68             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      69             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
      70             :   false,  /* isInfallible. False in setters. */
      71             :   true,  /* isMovable.  Not relevant for setters. */
      72             :   true, /* isEliminatable.  Not relevant for setters. */
      73             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      74             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      75             :   false,  /* isTypedMethod.  Only relevant for methods. */
      76             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      77             : };
      78             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      79             : static_assert(0 < 1, "There is no slot for us");
      80             : 
      81             : static bool
      82           0 : get_p3(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMQuad* self, JSJitGetterCallArgs args)
      83             : {
      84           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(self->P3()));
      85           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      86           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      87           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      88           0 :     return false;
      89             :   }
      90           0 :   return true;
      91             : }
      92             : 
      93             : static const JSJitInfo p3_getterinfo = {
      94             :   { (JSJitGetterOp)get_p3 },
      95             :   { prototypes::id::DOMQuad },
      96             :   { PrototypeTraits<prototypes::id::DOMQuad>::Depth },
      97             :   JSJitInfo::Getter,
      98             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      99             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     100             :   false,  /* isInfallible. False in setters. */
     101             :   true,  /* isMovable.  Not relevant for setters. */
     102             :   true, /* isEliminatable.  Not relevant for setters. */
     103             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     104             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     105             :   false,  /* isTypedMethod.  Only relevant for methods. */
     106             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     107             : };
     108             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     109             : static_assert(0 < 1, "There is no slot for us");
     110             : 
     111             : static bool
     112           0 : get_p4(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMQuad* self, JSJitGetterCallArgs args)
     113             : {
     114           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMPoint>(self->P4()));
     115           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     116           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     117           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     118           0 :     return false;
     119             :   }
     120           0 :   return true;
     121             : }
     122             : 
     123             : static const JSJitInfo p4_getterinfo = {
     124             :   { (JSJitGetterOp)get_p4 },
     125             :   { prototypes::id::DOMQuad },
     126             :   { PrototypeTraits<prototypes::id::DOMQuad>::Depth },
     127             :   JSJitInfo::Getter,
     128             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     129             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     130             :   false,  /* isInfallible. False in setters. */
     131             :   true,  /* isMovable.  Not relevant for setters. */
     132             :   true, /* 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_bounds(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::DOMQuad* self, JSJitGetterCallArgs args)
     143             : {
     144           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMRectReadOnly>(self->Bounds()));
     145           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     146           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     147           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     148           0 :     return false;
     149             :   }
     150           0 :   return true;
     151             : }
     152             : 
     153             : static const JSJitInfo bounds_getterinfo = {
     154             :   { (JSJitGetterOp)get_bounds },
     155             :   { prototypes::id::DOMQuad },
     156             :   { PrototypeTraits<prototypes::id::DOMQuad>::Depth },
     157             :   JSJitInfo::Getter,
     158             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
     159             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     160             :   false,  /* isInfallible. False in setters. */
     161             :   true,  /* isMovable.  Not relevant for setters. */
     162             :   true, /* isEliminatable.  Not relevant for setters. */
     163             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     164             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     165             :   false,  /* isTypedMethod.  Only relevant for methods. */
     166             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     167             : };
     168             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     169             : static_assert(0 < 1, "There is no slot for us");
     170             : 
     171             : static bool
     172           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     173             : {
     174           0 :   mozilla::dom::DOMQuad* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMQuad>(obj);
     175             :   // We don't want to preserve if we don't have a wrapper, and we
     176             :   // obviously can't preserve if we're not initialized.
     177           0 :   if (self && self->GetWrapperPreserveColor()) {
     178           0 :     PreserveWrapper(self);
     179             :   }
     180           0 :   return true;
     181             : }
     182             : 
     183             : static void
     184           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     185             : {
     186           0 :   mozilla::dom::DOMQuad* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMQuad>(obj);
     187           0 :   if (self) {
     188           0 :     ClearWrapper(self, self, obj);
     189           0 :     AddForDeferredFinalization<mozilla::dom::DOMQuad>(self);
     190             :   }
     191           0 : }
     192             : 
     193             : static void
     194           0 : _objectMoved(JSObject* obj, const JSObject* old)
     195             : {
     196           0 :   mozilla::dom::DOMQuad* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::DOMQuad>(obj);
     197           0 :   if (self) {
     198           0 :     UpdateWrapper(self, self, obj, old);
     199             :   }
     200           0 : }
     201             : 
     202             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     203             : #if defined(__clang__)
     204             : #pragma clang diagnostic push
     205             : #pragma clang diagnostic ignored "-Wmissing-braces"
     206             : #endif
     207             : static const JSPropertySpec sAttributes_specs[] = {
     208             :   { "p1", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &p1_getterinfo, nullptr, nullptr },
     209             :   { "p2", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &p2_getterinfo, nullptr, nullptr },
     210             :   { "p3", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &p3_getterinfo, nullptr, nullptr },
     211             :   { "p4", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &p4_getterinfo, nullptr, nullptr },
     212             :   { "bounds", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &bounds_getterinfo, nullptr, nullptr },
     213             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     214             : };
     215             : #if defined(__clang__)
     216             : #pragma clang diagnostic pop
     217             : #endif
     218             : 
     219             : 
     220             : // Can't be const because the pref-enabled boolean needs to be writable
     221             : static Prefable<const JSPropertySpec> sAttributes[] = {
     222             :   { nullptr, &sAttributes_specs[0] },
     223             :   { nullptr, nullptr }
     224             : };
     225             : 
     226             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     227             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     228             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     229             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     230             : 
     231             : 
     232             : static uint16_t sNativeProperties_sortedPropertyIndices[5];
     233             : static PropertyInfo sNativeProperties_propertyInfos[5];
     234             : 
     235             : static const NativePropertiesN<1> sNativeProperties = {
     236             :   false, 0,
     237             :   false, 0,
     238             :   false, 0,
     239             :   true,  0 /* sAttributes */,
     240             :   false, 0,
     241             :   false, 0,
     242             :   false, 0,
     243             :   -1,
     244             :   5,
     245             :   sNativeProperties_sortedPropertyIndices,
     246             :   {
     247             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     248             :   }
     249             : };
     250             : static_assert(5 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     251             :     "We have a property info count that is oversized");
     252             : 
     253             : static bool
     254           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     255             : {
     256           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     257           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     258           0 :   if (!args.isConstructing()) {
     259             :     // XXXbz wish I could get the name from the callee instead of
     260             :     // Adding more relocations
     261           0 :     return ThrowConstructorWithoutNew(cx, "DOMQuad");
     262             :   }
     263             : 
     264           0 :   GlobalObject global(cx, obj);
     265           0 :   if (global.Failed()) {
     266           0 :     return false;
     267             :   }
     268             : 
     269           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     270           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     271           0 :     return false;
     272             :   }
     273             : 
     274           0 :   unsigned argcount = std::min(args.length(), 4u);
     275           0 :   switch (argcount) {
     276             :     case 0: {
     277           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     278           0 :       binding_detail::FastDOMPointInit arg0;
     279           0 :       if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of DOMQuad.constructor", false)) {
     280           0 :         return false;
     281             :       }
     282           0 :       binding_detail::FastDOMPointInit arg1;
     283           0 :       if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of DOMQuad.constructor", false)) {
     284           0 :         return false;
     285             :       }
     286           0 :       binding_detail::FastDOMPointInit arg2;
     287           0 :       if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of DOMQuad.constructor", false)) {
     288           0 :         return false;
     289             :       }
     290           0 :       binding_detail::FastDOMPointInit arg3;
     291           0 :       if (!arg3.Init(cx, (args.hasDefined(3)) ? args[3] : JS::NullHandleValue,  "Argument 4 of DOMQuad.constructor", false)) {
     292           0 :         return false;
     293             :       }
     294           0 :       Maybe<JSAutoCompartment> ac;
     295           0 :       if (objIsXray) {
     296           0 :         obj = js::CheckedUnwrap(obj);
     297           0 :         if (!obj) {
     298           0 :           return false;
     299             :         }
     300           0 :         ac.emplace(cx, obj);
     301           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
     302           0 :           return false;
     303             :         }
     304             :       }
     305           0 :       binding_detail::FastErrorResult rv;
     306           0 :       auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(mozilla::dom::DOMQuad::Constructor(global, Constify(arg0), Constify(arg1), Constify(arg2), Constify(arg3), rv)));
     307           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     308           0 :         return false;
     309             :       }
     310           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     311             :       static_assert(!IsPointer<decltype(result)>::value,
     312             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
     313           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     314           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     315           0 :         return false;
     316             :       }
     317           0 :       return true;
     318             :       break;
     319             :     }
     320             :     case 1: {
     321           0 :       if (args[0].isNullOrUndefined()) {
     322           0 :         binding_detail::FastDOMPointInit arg0;
     323           0 :         if (!arg0.Init(cx, args[0],  "Argument 1 of DOMQuad", false)) {
     324           0 :           return false;
     325             :         }
     326           0 :         bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     327           0 :         binding_detail::FastDOMPointInit arg1;
     328           0 :         if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of DOMQuad.constructor", false)) {
     329           0 :           return false;
     330             :         }
     331           0 :         binding_detail::FastDOMPointInit arg2;
     332           0 :         if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of DOMQuad.constructor", false)) {
     333           0 :           return false;
     334             :         }
     335           0 :         binding_detail::FastDOMPointInit arg3;
     336           0 :         if (!arg3.Init(cx, (args.hasDefined(3)) ? args[3] : JS::NullHandleValue,  "Argument 4 of DOMQuad.constructor", false)) {
     337           0 :           return false;
     338             :         }
     339           0 :         Maybe<JSAutoCompartment> ac;
     340           0 :         if (objIsXray) {
     341           0 :           obj = js::CheckedUnwrap(obj);
     342           0 :           if (!obj) {
     343           0 :             return false;
     344             :           }
     345           0 :           ac.emplace(cx, obj);
     346           0 :           if (!JS_WrapObject(cx, &desiredProto)) {
     347           0 :             return false;
     348             :           }
     349             :         }
     350           0 :         binding_detail::FastErrorResult rv;
     351           0 :         auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(mozilla::dom::DOMQuad::Constructor(global, Constify(arg0), Constify(arg1), Constify(arg2), Constify(arg3), rv)));
     352           0 :         if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     353           0 :           return false;
     354             :         }
     355           0 :         MOZ_ASSERT(!JS_IsExceptionPending(cx));
     356             :         static_assert(!IsPointer<decltype(result)>::value,
     357             :                       "NewObject implies that we need to keep the object alive with a strong reference.");
     358           0 :         if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     359           0 :           MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     360           0 :           return false;
     361             :         }
     362           0 :         return true;
     363             :       }
     364           0 :       if (args[0].isObject()) {
     365             :         do {
     366           0 :           NonNull<mozilla::dom::DOMRectReadOnly> arg0;
     367             :           {
     368           0 :             nsresult rv = UnwrapObject<prototypes::id::DOMRectReadOnly, mozilla::dom::DOMRectReadOnly>(args[0], arg0);
     369           0 :             if (NS_FAILED(rv)) {
     370           0 :               break;
     371             :             }
     372             :           }
     373           0 :           bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     374           0 :           Maybe<JSAutoCompartment> ac;
     375           0 :           if (objIsXray) {
     376           0 :             obj = js::CheckedUnwrap(obj);
     377           0 :             if (!obj) {
     378           0 :               return false;
     379             :             }
     380           0 :             ac.emplace(cx, obj);
     381           0 :             if (!JS_WrapObject(cx, &desiredProto)) {
     382           0 :               return false;
     383             :             }
     384             :           }
     385           0 :           binding_detail::FastErrorResult rv;
     386           0 :           auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(mozilla::dom::DOMQuad::Constructor(global, NonNullHelper(arg0), rv)));
     387           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     388           0 :             return false;
     389             :           }
     390           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     391             :           static_assert(!IsPointer<decltype(result)>::value,
     392             :                         "NewObject implies that we need to keep the object alive with a strong reference.");
     393           0 :           if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     394           0 :             MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     395           0 :             return false;
     396             :           }
     397           0 :           return true;
     398             :         } while (0);
     399             :         do {
     400           0 :           binding_detail::FastDOMPointInit arg0;
     401           0 :           if (!arg0.Init(cx, args[0],  "Argument 1 of DOMQuad", false)) {
     402           0 :             return false;
     403             :           }
     404           0 :           bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     405           0 :           binding_detail::FastDOMPointInit arg1;
     406           0 :           if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of DOMQuad.constructor", false)) {
     407           0 :             return false;
     408             :           }
     409           0 :           binding_detail::FastDOMPointInit arg2;
     410           0 :           if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of DOMQuad.constructor", false)) {
     411           0 :             return false;
     412             :           }
     413           0 :           binding_detail::FastDOMPointInit arg3;
     414           0 :           if (!arg3.Init(cx, (args.hasDefined(3)) ? args[3] : JS::NullHandleValue,  "Argument 4 of DOMQuad.constructor", false)) {
     415           0 :             return false;
     416             :           }
     417           0 :           Maybe<JSAutoCompartment> ac;
     418           0 :           if (objIsXray) {
     419           0 :             obj = js::CheckedUnwrap(obj);
     420           0 :             if (!obj) {
     421           0 :               return false;
     422             :             }
     423           0 :             ac.emplace(cx, obj);
     424           0 :             if (!JS_WrapObject(cx, &desiredProto)) {
     425           0 :               return false;
     426             :             }
     427             :           }
     428           0 :           binding_detail::FastErrorResult rv;
     429           0 :           auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(mozilla::dom::DOMQuad::Constructor(global, Constify(arg0), Constify(arg1), Constify(arg2), Constify(arg3), rv)));
     430           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     431           0 :             return false;
     432             :           }
     433           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     434             :           static_assert(!IsPointer<decltype(result)>::value,
     435             :                         "NewObject implies that we need to keep the object alive with a strong reference.");
     436           0 :           if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     437           0 :             MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     438           0 :             return false;
     439             :           }
     440           0 :           return true;
     441             :         } while (0);
     442             :       }
     443           0 :       return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "1", "DOMQuad");
     444             :       break;
     445             :     }
     446             :     case 2: {
     447             :       MOZ_FALLTHROUGH;
     448             :     }
     449             :     case 3: {
     450             :       MOZ_FALLTHROUGH;
     451             :     }
     452             :     case 4: {
     453           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     454           0 :       binding_detail::FastDOMPointInit arg0;
     455           0 :       if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue,  "Argument 1 of DOMQuad.constructor", false)) {
     456           0 :         return false;
     457             :       }
     458           0 :       binding_detail::FastDOMPointInit arg1;
     459           0 :       if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of DOMQuad.constructor", false)) {
     460           0 :         return false;
     461             :       }
     462           0 :       binding_detail::FastDOMPointInit arg2;
     463           0 :       if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue,  "Argument 3 of DOMQuad.constructor", false)) {
     464           0 :         return false;
     465             :       }
     466           0 :       binding_detail::FastDOMPointInit arg3;
     467           0 :       if (!arg3.Init(cx, (args.hasDefined(3)) ? args[3] : JS::NullHandleValue,  "Argument 4 of DOMQuad.constructor", false)) {
     468           0 :         return false;
     469             :       }
     470           0 :       Maybe<JSAutoCompartment> ac;
     471           0 :       if (objIsXray) {
     472           0 :         obj = js::CheckedUnwrap(obj);
     473           0 :         if (!obj) {
     474           0 :           return false;
     475             :         }
     476           0 :         ac.emplace(cx, obj);
     477           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
     478           0 :           return false;
     479             :         }
     480             :       }
     481           0 :       binding_detail::FastErrorResult rv;
     482           0 :       auto result(StrongOrRawPtr<mozilla::dom::DOMQuad>(mozilla::dom::DOMQuad::Constructor(global, Constify(arg0), Constify(arg1), Constify(arg2), Constify(arg3), rv)));
     483           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     484           0 :         return false;
     485             :       }
     486           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     487             :       static_assert(!IsPointer<decltype(result)>::value,
     488             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
     489           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     490           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     491           0 :         return false;
     492             :       }
     493           0 :       return true;
     494             :       break;
     495             :     }
     496             :     default: {
     497           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "DOMQuad");
     498             :       break;
     499             :     }
     500             :   }
     501             :   MOZ_CRASH("We have an always-returning default case");
     502             :   return false;
     503             : }
     504             : 
     505             : static const js::ClassOps sInterfaceObjectClassOps = {
     506             :     nullptr,               /* addProperty */
     507             :     nullptr,               /* delProperty */
     508             :     nullptr,               /* getProperty */
     509             :     nullptr,               /* setProperty */
     510             :     nullptr,               /* enumerate */
     511             :     nullptr,               /* newEnumerate */
     512             :     nullptr,               /* resolve */
     513             :     nullptr,               /* mayResolve */
     514             :     nullptr,               /* finalize */
     515             :     _constructor, /* call */
     516             :     nullptr,               /* hasInstance */
     517             :     _constructor, /* construct */
     518             :     nullptr,               /* trace */
     519             : };
     520             : 
     521             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     522             :   {
     523             :     "Function",
     524             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     525             :     &sInterfaceObjectClassOps,
     526             :     JS_NULL_CLASS_SPEC,
     527             :     JS_NULL_CLASS_EXT,
     528             :     &sInterfaceObjectClassObjectOps
     529             :   },
     530             :   eInterface,
     531             :   true,
     532             :   prototypes::id::DOMQuad,
     533             :   PrototypeTraits<prototypes::id::DOMQuad>::Depth,
     534             :   sNativePropertyHooks,
     535             :   "function DOMQuad() {\n    [native code]\n}",
     536             :   JS::GetRealmFunctionPrototype
     537             : };
     538             : 
     539             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     540             :   {
     541             :     "DOMQuadPrototype",
     542             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     543             :     JS_NULL_CLASS_OPS,
     544             :     JS_NULL_CLASS_SPEC,
     545             :     JS_NULL_CLASS_EXT,
     546             :     JS_NULL_OBJECT_OPS
     547             :   },
     548             :   eInterfacePrototype,
     549             :   false,
     550             :   prototypes::id::DOMQuad,
     551             :   PrototypeTraits<prototypes::id::DOMQuad>::Depth,
     552             :   sNativePropertyHooks,
     553             :   "[object DOMQuadPrototype]",
     554             :   JS::GetRealmObjectPrototype
     555             : };
     556             : 
     557             : bool
     558           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     559             : {
     560             :   static bool sPrefValue;
     561             :   static bool sPrefCacheSetUp = false;
     562           0 :   if (!sPrefCacheSetUp) {
     563           0 :     sPrefCacheSetUp = true;
     564           0 :     Preferences::AddBoolVarCache(&sPrefValue, "layout.css.DOMQuad.enabled");
     565             :   }
     566             : 
     567           0 :   return sPrefValue;
     568             : }
     569             : 
     570             : JSObject*
     571           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     572             : {
     573           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     574             : }
     575             : 
     576             : static const js::ClassOps sClassOps = {
     577             :   _addProperty, /* addProperty */
     578             :   nullptr,               /* delProperty */
     579             :   nullptr,               /* getProperty */
     580             :   nullptr,               /* setProperty */
     581             :   nullptr,               /* enumerate */
     582             :   nullptr, /* newEnumerate */
     583             :   nullptr, /* resolve */
     584             :   nullptr, /* mayResolve */
     585             :   _finalize, /* finalize */
     586             :   nullptr, /* call */
     587             :   nullptr,               /* hasInstance */
     588             :   nullptr,               /* construct */
     589             :   nullptr, /* trace */
     590             : };
     591             : 
     592             : static const js::ClassExtension sClassExtension = {
     593             :   nullptr, /* weakmapKeyDelegateOp */
     594             :   _objectMoved /* objectMovedOp */
     595             : };
     596             : 
     597             : static const DOMJSClass sClass = {
     598             :   { "DOMQuad",
     599             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     600             :     &sClassOps,
     601             :     JS_NULL_CLASS_SPEC,
     602             :     &sClassExtension,
     603             :     JS_NULL_OBJECT_OPS
     604             :   },
     605             :   { prototypes::id::DOMQuad, 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 },
     606             :   IsBaseOf<nsISupports, mozilla::dom::DOMQuad >::value,
     607             :   sNativePropertyHooks,
     608             :   FindAssociatedGlobalForNative<mozilla::dom::DOMQuad>::Get,
     609             :   GetProtoObjectHandle,
     610             :   GetCCParticipant<mozilla::dom::DOMQuad>::Get()
     611             : };
     612             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     613             :               "Must have the right minimal number of reserved slots.");
     614             : static_assert(1 >= 1,
     615             :               "Must have enough reserved slots.");
     616             : 
     617             : const JSClass*
     618           0 : GetJSClass()
     619             : {
     620           0 :   return sClass.ToJSClass();
     621             : }
     622             : 
     623             : bool
     624           0 : Wrap(JSContext* aCx, mozilla::dom::DOMQuad* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     625             : {
     626             :   MOZ_ASSERT(static_cast<mozilla::dom::DOMQuad*>(aObject) ==
     627             :              reinterpret_cast<mozilla::dom::DOMQuad*>(aObject),
     628             :              "Multiple inheritance for mozilla::dom::DOMQuad is broken.");
     629           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     630           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     631           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     632             :              "You should probably not be using Wrap() directly; use "
     633             :              "GetOrCreateDOMReflector instead");
     634             : 
     635           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     636             :              "nsISupports must be on our primary inheritance chain");
     637             : 
     638           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     639           0 :   if (!global) {
     640           0 :     return false;
     641             :   }
     642           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     643           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     644             : 
     645             :   // That might have ended up wrapping us already, due to the wonders
     646             :   // of XBL.  Check for that, and bail out as needed.
     647           0 :   aReflector.set(aCache->GetWrapper());
     648           0 :   if (aReflector) {
     649             : #ifdef DEBUG
     650           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     651             : #endif // DEBUG
     652           0 :     return true;
     653             :   }
     654             : 
     655           0 :   JSAutoCompartment ac(aCx, global);
     656           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     657           0 :   if (!canonicalProto) {
     658           0 :     return false;
     659             :   }
     660           0 :   JS::Rooted<JSObject*> proto(aCx);
     661           0 :   if (aGivenProto) {
     662           0 :     proto = aGivenProto;
     663             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     664             :     // coming in, we changed compartments to that of "parent" so may need
     665             :     // to wrap the proto here.
     666           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     667           0 :       if (!JS_WrapObject(aCx, &proto)) {
     668           0 :         return false;
     669             :       }
     670             :     }
     671             :   } else {
     672           0 :     proto = canonicalProto;
     673             :   }
     674             : 
     675           0 :   BindingJSObjectCreator<mozilla::dom::DOMQuad> creator(aCx);
     676           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     677           0 :   if (!aReflector) {
     678           0 :     return false;
     679             :   }
     680             : 
     681           0 :   aCache->SetWrapper(aReflector);
     682           0 :   creator.InitializationSucceeded();
     683             : 
     684           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     685             :              aCache->GetWrapperPreserveColor() == aReflector);
     686             :   // If proto != canonicalProto, we have to preserve our wrapper;
     687             :   // otherwise we won't be able to properly recreate it later, since
     688             :   // we won't know what proto to use.  Note that we don't check
     689             :   // aGivenProto here, since it's entirely possible (and even
     690             :   // somewhat common) to have a non-null aGivenProto which is the
     691             :   // same as canonicalProto.
     692           0 :   if (proto != canonicalProto) {
     693           0 :     PreserveWrapper(aObject);
     694             :   }
     695             : 
     696           0 :   return true;
     697             : }
     698             : 
     699             : const NativePropertyHooks sNativePropertyHooks[] = { {
     700             :   nullptr,
     701             :   nullptr,
     702             :   nullptr,
     703             :   { sNativeProperties.Upcast(), nullptr },
     704             :   prototypes::id::DOMQuad,
     705             :   constructors::id::DOMQuad,
     706             :   nullptr,
     707             :   &DefaultXrayExpandoObjectClass
     708             : } };
     709             : 
     710             : void
     711           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     712             : {
     713           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     714           0 :   if (!parentProto) {
     715           0 :     return;
     716             :   }
     717             : 
     718           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     719           0 :   if (!constructorProto) {
     720           0 :     return;
     721             :   }
     722             : 
     723             :   static bool sIdsInited = false;
     724           0 :   if (!sIdsInited && NS_IsMainThread()) {
     725           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     726           0 :       return;
     727             :     }
     728           0 :     sIdsInited = true;
     729             :   }
     730             : 
     731           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::DOMQuad);
     732           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::DOMQuad);
     733           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     734             :                               &sPrototypeClass.mBase, protoCache,
     735             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     736             :                               interfaceCache,
     737             :                               sNativeProperties.Upcast(),
     738             :                               nullptr,
     739             :                               "DOMQuad", aDefineOnGlobal,
     740             :                               nullptr,
     741           0 :                               false);
     742             : }
     743             : 
     744             : JS::Handle<JSObject*>
     745           0 : GetProtoObjectHandle(JSContext* aCx)
     746             : {
     747             :   /* Get the interface prototype object for this class.  This will create the
     748             :      object as needed. */
     749           0 :   bool aDefineOnGlobal = true;
     750             : 
     751             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     752           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     753           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     754           0 :     return nullptr;
     755             :   }
     756             : 
     757             :   /* Check to see whether the interface objects are already installed */
     758           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     759           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::DOMQuad)) {
     760           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     761           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     762             :   }
     763             : 
     764             :   /*
     765             :    * The object might _still_ be null, but that's OK.
     766             :    *
     767             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     768             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     769             :    * changed after they have been set.
     770             :    *
     771             :    * Calling address() avoids the read read barrier that does gray
     772             :    * unmarking, but it's not possible for the object to be gray here.
     773             :    */
     774             : 
     775           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::DOMQuad);
     776           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     777           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     778             : }
     779             : 
     780             : JS::Handle<JSObject*>
     781           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     782             : {
     783             :   /* Get the interface object for this class.  This will create the object as
     784             :      needed. */
     785             : 
     786             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     787           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     788           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     789           0 :     return nullptr;
     790             :   }
     791             : 
     792             :   /* Check to see whether the interface objects are already installed */
     793           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     794           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::DOMQuad)) {
     795           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     796           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     797             :   }
     798             : 
     799             :   /*
     800             :    * The object might _still_ be null, but that's OK.
     801             :    *
     802             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     803             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     804             :    * changed after they have been set.
     805             :    *
     806             :    * Calling address() avoids the read read barrier that does gray
     807             :    * unmarking, but it's not possible for the object to be gray here.
     808             :    */
     809             : 
     810           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::DOMQuad);
     811           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     812           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     813             : }
     814             : 
     815             : JSObject*
     816           0 : GetConstructorObject(JSContext* aCx)
     817             : {
     818           0 :   return GetConstructorObjectHandle(aCx);
     819             : }
     820             : 
     821             : } // namespace DOMQuadBinding
     822             : 
     823             : 
     824             : 
     825             : } // namespace dom
     826             : } // namespace mozilla

Generated by: LCOV version 1.13