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

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

Generated by: LCOV version 1.13