LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - AnimationPlaybackEventBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 22 285 7.7 %
Date: 2017-07-14 16:53:18 Functions: 2 23 8.7 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13