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

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

Generated by: LCOV version 1.13