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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM KeyframeEffect.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AnimationEffectReadOnlyBinding.h"
       4             : #include "AtomList.h"
       5             : #include "KeyframeEffectBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "XrayWrapper.h"
       8             : #include "jsapi.h"
       9             : #include "mozilla/FloatingPoint.h"
      10             : #include "mozilla/OwningNonNull.h"
      11             : #include "mozilla/dom/BindingUtils.h"
      12             : #include "mozilla/dom/CSSPseudoElement.h"
      13             : #include "mozilla/dom/DOMJSClass.h"
      14             : #include "mozilla/dom/Element.h"
      15             : #include "mozilla/dom/KeyframeEffect.h"
      16             : #include "mozilla/dom/KeyframeEffectReadOnly.h"
      17             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      18             : #include "mozilla/dom/Nullable.h"
      19             : #include "mozilla/dom/PrimitiveConversions.h"
      20             : #include "mozilla/dom/ScriptSettings.h"
      21             : #include "mozilla/dom/SimpleGlobalObject.h"
      22             : #include "mozilla/dom/UnionConversions.h"
      23             : #include "mozilla/dom/XrayExpandoClass.h"
      24             : #include "nsContentUtils.h"
      25             : #include "nsDocument.h"
      26             : 
      27             : namespace mozilla {
      28             : namespace dom {
      29             : 
      30             : namespace IterationCompositeOperationValues {
      31             : extern const EnumEntry strings[3] = {
      32             :   {"replace", 7},
      33             :   {"accumulate", 10},
      34             :   { nullptr, 0 }
      35             : };
      36             : } // namespace IterationCompositeOperationValues
      37             : 
      38             : bool
      39           0 : ToJSValue(JSContext* aCx, IterationCompositeOperation aArgument, JS::MutableHandle<JS::Value> aValue)
      40             : {
      41           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(IterationCompositeOperationValues::strings));
      42             :   JSString* resultStr =
      43           0 :     JS_NewStringCopyN(aCx, IterationCompositeOperationValues::strings[uint32_t(aArgument)].value,
      44           0 :                       IterationCompositeOperationValues::strings[uint32_t(aArgument)].length);
      45           0 :   if (!resultStr) {
      46           0 :     return false;
      47             :   }
      48           0 :   aValue.setString(resultStr);
      49           0 :   return true;
      50             : }
      51             : 
      52             : 
      53             : void
      54           0 : ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningElementOrCSSPseudoElement& aUnion, const char* aName, uint32_t aFlags)
      55             : {
      56           0 :   if (aUnion.IsElement()) {
      57           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsElement(), "mElement", aFlags);
      58           0 :   } else if (aUnion.IsCSSPseudoElement()) {
      59           0 :     ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCSSPseudoElement(), "mCSSPseudoElement", aFlags);
      60             :   }
      61           0 : }
      62             : 
      63             : 
      64             : void
      65           0 : ImplCycleCollectionUnlink(OwningElementOrCSSPseudoElement& aUnion)
      66             : {
      67           0 :   aUnion.Uninit();
      68           0 : }
      69             : 
      70             : 
      71             : 
      72           0 : AnimationPropertyValueDetails::AnimationPropertyValueDetails()
      73             : {
      74             :   // Safe to pass a null context if we pass a null value
      75           0 :   Init(nullptr, JS::NullHandleValue);
      76           0 : }
      77             : 
      78             : 
      79             : 
      80             : bool
      81           0 : AnimationPropertyValueDetails::InitIds(JSContext* cx, AnimationPropertyValueDetailsAtoms* atomsCache)
      82             : {
      83           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      84             : 
      85             :   // Initialize these in reverse order so that any failure leaves the first one
      86             :   // uninitialized.
      87           0 :   if (!atomsCache->value_id.init(cx, "value") ||
      88           0 :       !atomsCache->offset_id.init(cx, "offset") ||
      89           0 :       !atomsCache->easing_id.init(cx, "easing") ||
      90           0 :       !atomsCache->composite_id.init(cx, "composite")) {
      91           0 :     return false;
      92             :   }
      93           0 :   return true;
      94             : }
      95             : 
      96             : bool
      97           0 : AnimationPropertyValueDetails::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      98             : {
      99             :   // Passing a null JSContext is OK only if we're initing from null,
     100             :   // Since in that case we will not have to do any property gets
     101             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     102             :   // checkers by static analysis tools
     103           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     104           0 :   AnimationPropertyValueDetailsAtoms* atomsCache = nullptr;
     105           0 :   if (cx) {
     106           0 :     atomsCache = GetAtomCache<AnimationPropertyValueDetailsAtoms>(cx);
     107           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     108           0 :       return false;
     109             :     }
     110             :   }
     111             : 
     112           0 :   if (!IsConvertibleToDictionary(val)) {
     113           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     114             :   }
     115             : 
     116           0 :   bool isNull = val.isNullOrUndefined();
     117             :   // We only need these if !isNull, in which case we have |cx|.
     118           0 :   Maybe<JS::Rooted<JSObject *> > object;
     119           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     120           0 :   if (!isNull) {
     121           0 :     MOZ_ASSERT(cx);
     122           0 :     object.emplace(cx, &val.toObject());
     123           0 :     temp.emplace(cx);
     124             :   }
     125           0 :   if (!isNull) {
     126           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->composite_id, temp.ptr())) {
     127           0 :       return false;
     128             :     }
     129             :   }
     130           0 :   if (!isNull && !temp->isUndefined()) {
     131             :     {
     132             :       int index;
     133           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), CompositeOperationValues::strings, "CompositeOperation", "'composite' member of AnimationPropertyValueDetails", &index)) {
     134           0 :         return false;
     135             :       }
     136           0 :       MOZ_ASSERT(index >= 0);
     137           0 :       mComposite = static_cast<CompositeOperation>(index);
     138             :     }
     139           0 :     mIsAnyMemberPresent = true;
     140           0 :   } else if (cx) {
     141             :     // Don't error out if we have no cx.  In that
     142             :     // situation the caller is default-constructing us and we'll
     143             :     // just assume they know what they're doing.
     144           0 :     return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
     145           0 :                              "'composite' member of AnimationPropertyValueDetails");
     146             :   }
     147             : 
     148           0 :   if (!isNull) {
     149           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->easing_id, temp.ptr())) {
     150           0 :       return false;
     151             :     }
     152             :   }
     153           0 :   if (!isNull && !temp->isUndefined()) {
     154           0 :     mEasing.Construct();
     155           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mEasing.Value()))) {
     156           0 :       return false;
     157             :     }
     158           0 :     mIsAnyMemberPresent = true;
     159             :   }
     160             : 
     161           0 :   if (!isNull) {
     162           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->offset_id, temp.ptr())) {
     163           0 :       return false;
     164             :     }
     165             :   }
     166           0 :   if (!isNull && !temp->isUndefined()) {
     167           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mOffset)) {
     168           0 :       return false;
     169           0 :     } else if (!mozilla::IsFinite(mOffset)) {
     170           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "'offset' member of AnimationPropertyValueDetails");
     171           0 :       return false;
     172             :     }
     173           0 :     mIsAnyMemberPresent = true;
     174           0 :   } else if (cx) {
     175             :     // Don't error out if we have no cx.  In that
     176             :     // situation the caller is default-constructing us and we'll
     177             :     // just assume they know what they're doing.
     178           0 :     return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
     179           0 :                              "'offset' member of AnimationPropertyValueDetails");
     180             :   }
     181             : 
     182           0 :   if (!isNull) {
     183           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->value_id, temp.ptr())) {
     184           0 :       return false;
     185             :     }
     186             :   }
     187           0 :   if (!isNull && !temp->isUndefined()) {
     188           0 :     mValue.Construct();
     189           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mValue.Value()))) {
     190           0 :       return false;
     191             :     }
     192           0 :     mIsAnyMemberPresent = true;
     193             :   }
     194           0 :   return true;
     195             : }
     196             : 
     197             : bool
     198           0 : AnimationPropertyValueDetails::Init(const nsAString& aJSON)
     199             : {
     200           0 :   AutoJSAPI jsapi;
     201           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     202           0 :   if (!cleanGlobal) {
     203           0 :     return false;
     204             :   }
     205           0 :   if (!jsapi.Init(cleanGlobal)) {
     206           0 :     return false;
     207             :   }
     208           0 :   JSContext* cx = jsapi.cx();
     209           0 :   JS::Rooted<JS::Value> json(cx);
     210           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     211           0 :   NS_ENSURE_TRUE(ok, false);
     212           0 :   return Init(cx, json);
     213             : }
     214             : 
     215             : bool
     216           0 : AnimationPropertyValueDetails::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     217             : {
     218           0 :   AnimationPropertyValueDetailsAtoms* atomsCache = GetAtomCache<AnimationPropertyValueDetailsAtoms>(cx);
     219           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     220           0 :     return false;
     221             :   }
     222             : 
     223           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     224           0 :   if (!obj) {
     225           0 :     return false;
     226             :   }
     227           0 :   rval.set(JS::ObjectValue(*obj));
     228             : 
     229             :   do {
     230             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     231           0 :     JS::Rooted<JS::Value> temp(cx);
     232           0 :     CompositeOperation const & currentValue = mComposite;
     233           0 :     if (!ToJSValue(cx, currentValue, &temp)) {
     234           0 :       return false;
     235             :     }
     236           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->composite_id, temp, JSPROP_ENUMERATE)) {
     237           0 :       return false;
     238             :     }
     239           0 :     break;
     240             :   } while(0);
     241             : 
     242           0 :   if (mEasing.WasPassed()) {
     243             :     do {
     244             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     245           0 :       JS::Rooted<JS::Value> temp(cx);
     246           0 :       nsString const & currentValue = mEasing.InternalValue();
     247           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     248           0 :         return false;
     249             :       }
     250           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->easing_id, temp, JSPROP_ENUMERATE)) {
     251           0 :         return false;
     252             :       }
     253           0 :       break;
     254             :     } while(0);
     255             :   }
     256             : 
     257             :   do {
     258             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     259           0 :     JS::Rooted<JS::Value> temp(cx);
     260           0 :     double const & currentValue = mOffset;
     261           0 :     temp.set(JS_NumberValue(double(currentValue)));
     262           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->offset_id, temp, JSPROP_ENUMERATE)) {
     263           0 :       return false;
     264             :     }
     265           0 :     break;
     266             :   } while(0);
     267             : 
     268           0 :   if (mValue.WasPassed()) {
     269             :     do {
     270             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     271           0 :       JS::Rooted<JS::Value> temp(cx);
     272           0 :       nsString const & currentValue = mValue.InternalValue();
     273           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     274           0 :         return false;
     275             :       }
     276           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->value_id, temp, JSPROP_ENUMERATE)) {
     277           0 :         return false;
     278             :       }
     279           0 :       break;
     280             :     } while(0);
     281             :   }
     282             : 
     283           0 :   return true;
     284             : }
     285             : 
     286             : bool
     287           0 : AnimationPropertyValueDetails::ToJSON(nsAString& aJSON) const
     288             : {
     289           0 :   AutoJSAPI jsapi;
     290           0 :   jsapi.Init();
     291           0 :   JSContext *cx = jsapi.cx();
     292             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     293             :   // because we'll only be creating objects, in ways that have no
     294             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     295             :   // which likewise guarantees no side-effects for the sorts of
     296             :   // things we will pass it.
     297           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     298           0 :   JS::Rooted<JS::Value> val(cx);
     299           0 :   if (!ToObjectInternal(cx, &val)) {
     300           0 :     return false;
     301             :   }
     302           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     303           0 :   return StringifyToJSON(cx, obj, aJSON);
     304             : }
     305             : 
     306             : void
     307           0 : AnimationPropertyValueDetails::TraceDictionary(JSTracer* trc)
     308             : {
     309           0 : }
     310             : 
     311             : AnimationPropertyValueDetails&
     312           0 : AnimationPropertyValueDetails::operator=(const AnimationPropertyValueDetails& aOther)
     313             : {
     314           0 :   mComposite = aOther.mComposite;
     315           0 :   mEasing.Reset();
     316           0 :   if (aOther.mEasing.WasPassed()) {
     317           0 :     mEasing.Construct(aOther.mEasing.Value());
     318             :   }
     319           0 :   mOffset = aOther.mOffset;
     320           0 :   mValue.Reset();
     321           0 :   if (aOther.mValue.WasPassed()) {
     322           0 :     mValue.Construct(aOther.mValue.Value());
     323             :   }
     324           0 :   return *this;
     325             : }
     326             : 
     327             : namespace binding_detail {
     328             : } // namespace binding_detail
     329             : 
     330             : 
     331             : bool
     332           0 : ElementOrCSSPseudoElement::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     333             : {
     334           0 :   switch (mType) {
     335             :     case eUninitialized: {
     336           0 :       return false;
     337             :       break;
     338             :     }
     339             :     case eElement: {
     340           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mElement.Value(), rval)) {
     341           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     342           0 :         return false;
     343             :       }
     344           0 :       return true;
     345             :       break;
     346             :     }
     347             :     case eCSSPseudoElement: {
     348           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mCSSPseudoElement.Value(), rval)) {
     349           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     350           0 :         return false;
     351             :       }
     352           0 :       return true;
     353             :       break;
     354             :     }
     355             :     default: {
     356           0 :       return false;
     357             :       break;
     358             :     }
     359             :   }
     360             : 
     361             :   return false;
     362             : }
     363             : 
     364             : 
     365             : OwningNonNull<mozilla::dom::Element>&
     366           0 : OwningElementOrCSSPseudoElement::RawSetAsElement()
     367             : {
     368           0 :   if (mType == eElement) {
     369           0 :     return mValue.mElement.Value();
     370             :   }
     371           0 :   MOZ_ASSERT(mType == eUninitialized);
     372           0 :   mType = eElement;
     373           0 :   return mValue.mElement.SetValue();
     374             : }
     375             : 
     376             : OwningNonNull<mozilla::dom::Element>&
     377           0 : OwningElementOrCSSPseudoElement::SetAsElement()
     378             : {
     379           0 :   if (mType == eElement) {
     380           0 :     return mValue.mElement.Value();
     381             :   }
     382           0 :   Uninit();
     383           0 :   mType = eElement;
     384           0 :   return mValue.mElement.SetValue();
     385             : }
     386             : 
     387             : bool
     388           0 : OwningElementOrCSSPseudoElement::TrySetToElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     389             : {
     390           0 :   tryNext = false;
     391             :   { // scope for memberSlot
     392           0 :     OwningNonNull<mozilla::dom::Element>& memberSlot = RawSetAsElement();
     393             :     static_assert(IsRefcounted<mozilla::dom::Element>::value, "We can only store refcounted classes.");{
     394           0 :       nsresult rv = UnwrapObject<prototypes::id::Element, mozilla::dom::Element>(value, memberSlot);
     395           0 :       if (NS_FAILED(rv)) {
     396           0 :         DestroyElement();
     397           0 :         tryNext = true;
     398           0 :         return true;
     399             :       }
     400             :     }
     401             :   }
     402           0 :   return true;
     403             : }
     404             : 
     405             : void
     406           0 : OwningElementOrCSSPseudoElement::DestroyElement()
     407             : {
     408           0 :   MOZ_ASSERT(IsElement(), "Wrong type!");
     409           0 :   mValue.mElement.Destroy();
     410           0 :   mType = eUninitialized;
     411           0 : }
     412             : 
     413             : 
     414             : 
     415             : 
     416             : OwningNonNull<mozilla::dom::CSSPseudoElement>&
     417           0 : OwningElementOrCSSPseudoElement::RawSetAsCSSPseudoElement()
     418             : {
     419           0 :   if (mType == eCSSPseudoElement) {
     420           0 :     return mValue.mCSSPseudoElement.Value();
     421             :   }
     422           0 :   MOZ_ASSERT(mType == eUninitialized);
     423           0 :   mType = eCSSPseudoElement;
     424           0 :   return mValue.mCSSPseudoElement.SetValue();
     425             : }
     426             : 
     427             : OwningNonNull<mozilla::dom::CSSPseudoElement>&
     428           0 : OwningElementOrCSSPseudoElement::SetAsCSSPseudoElement()
     429             : {
     430           0 :   if (mType == eCSSPseudoElement) {
     431           0 :     return mValue.mCSSPseudoElement.Value();
     432             :   }
     433           0 :   Uninit();
     434           0 :   mType = eCSSPseudoElement;
     435           0 :   return mValue.mCSSPseudoElement.SetValue();
     436             : }
     437             : 
     438             : bool
     439           0 : OwningElementOrCSSPseudoElement::TrySetToCSSPseudoElement(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
     440             : {
     441           0 :   tryNext = false;
     442             :   { // scope for memberSlot
     443           0 :     OwningNonNull<mozilla::dom::CSSPseudoElement>& memberSlot = RawSetAsCSSPseudoElement();
     444             :     static_assert(IsRefcounted<mozilla::dom::CSSPseudoElement>::value, "We can only store refcounted classes.");{
     445           0 :       nsresult rv = UnwrapObject<prototypes::id::CSSPseudoElement, mozilla::dom::CSSPseudoElement>(value, memberSlot);
     446           0 :       if (NS_FAILED(rv)) {
     447           0 :         DestroyCSSPseudoElement();
     448           0 :         tryNext = true;
     449           0 :         return true;
     450             :       }
     451             :     }
     452             :   }
     453           0 :   return true;
     454             : }
     455             : 
     456             : void
     457           0 : OwningElementOrCSSPseudoElement::DestroyCSSPseudoElement()
     458             : {
     459           0 :   MOZ_ASSERT(IsCSSPseudoElement(), "Wrong type!");
     460           0 :   mValue.mCSSPseudoElement.Destroy();
     461           0 :   mType = eUninitialized;
     462           0 : }
     463             : 
     464             : 
     465             : 
     466             : 
     467             : void
     468           0 : OwningElementOrCSSPseudoElement::Uninit()
     469             : {
     470           0 :   switch (mType) {
     471             :     case eUninitialized: {
     472           0 :       break;
     473             :     }
     474             :     case eElement: {
     475           0 :       DestroyElement();
     476           0 :       break;
     477             :     }
     478             :     case eCSSPseudoElement: {
     479           0 :       DestroyCSSPseudoElement();
     480           0 :       break;
     481             :     }
     482             :   }
     483           0 : }
     484             : 
     485             : bool
     486           0 : OwningElementOrCSSPseudoElement::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
     487             : {
     488           0 :   switch (mType) {
     489             :     case eUninitialized: {
     490           0 :       return false;
     491             :       break;
     492             :     }
     493             :     case eElement: {
     494           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mElement.Value(), rval)) {
     495           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     496           0 :         return false;
     497             :       }
     498           0 :       return true;
     499             :       break;
     500             :     }
     501             :     case eCSSPseudoElement: {
     502           0 :       if (!GetOrCreateDOMReflector(cx, mValue.mCSSPseudoElement.Value(), rval)) {
     503           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     504           0 :         return false;
     505             :       }
     506           0 :       return true;
     507             :       break;
     508             :     }
     509             :     default: {
     510           0 :       return false;
     511             :       break;
     512             :     }
     513             :   }
     514             : 
     515             :   return false;
     516             : }
     517             : 
     518             : void
     519           0 : OwningElementOrCSSPseudoElement::TraceUnion(JSTracer* trc)
     520             : {
     521           0 : }
     522             : 
     523             : OwningElementOrCSSPseudoElement&
     524           0 : OwningElementOrCSSPseudoElement::operator=(const OwningElementOrCSSPseudoElement& aOther)
     525             : {
     526           0 :   switch (aOther.mType) {
     527             :     case eUninitialized: {
     528           0 :       MOZ_ASSERT(mType == eUninitialized,
     529             :                  "We need to destroy ourselves?");
     530           0 :       break;
     531             :     }
     532             :     case eElement: {
     533           0 :       SetAsElement() = aOther.GetAsElement();
     534           0 :       break;
     535             :     }
     536             :     case eCSSPseudoElement: {
     537           0 :       SetAsCSSPseudoElement() = aOther.GetAsCSSPseudoElement();
     538           0 :       break;
     539             :     }
     540             :   }
     541           0 :   return *this;
     542             : }
     543             : 
     544             : 
     545             : 
     546           0 : KeyframeEffectOptions::KeyframeEffectOptions()
     547           0 :   : AnimationEffectTimingProperties(FastDictionaryInitializer())
     548             : {
     549             :   // Safe to pass a null context if we pass a null value
     550           0 :   Init(nullptr, JS::NullHandleValue);
     551           0 : }
     552             : 
     553             : 
     554             : 
     555             : bool
     556           0 : KeyframeEffectOptions::InitIds(JSContext* cx, KeyframeEffectOptionsAtoms* atomsCache)
     557             : {
     558           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     559             : 
     560             :   // Initialize these in reverse order so that any failure leaves the first one
     561             :   // uninitialized.
     562           0 :   if (!atomsCache->iterationComposite_id.init(cx, "iterationComposite") ||
     563           0 :       !atomsCache->composite_id.init(cx, "composite")) {
     564           0 :     return false;
     565             :   }
     566           0 :   return true;
     567             : }
     568             : 
     569             : bool
     570           0 : KeyframeEffectOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     571             : {
     572             :   // Passing a null JSContext is OK only if we're initing from null,
     573             :   // Since in that case we will not have to do any property gets
     574             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     575             :   // checkers by static analysis tools
     576           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     577           0 :   KeyframeEffectOptionsAtoms* atomsCache = nullptr;
     578           0 :   if (cx) {
     579           0 :     atomsCache = GetAtomCache<KeyframeEffectOptionsAtoms>(cx);
     580           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     581           0 :       return false;
     582             :     }
     583             :   }
     584             : 
     585             :   // Per spec, we init the parent's members first
     586           0 :   if (!AnimationEffectTimingProperties::Init(cx, val)) {
     587           0 :     return false;
     588             :   }
     589             : 
     590           0 :   bool isNull = val.isNullOrUndefined();
     591             :   // We only need these if !isNull, in which case we have |cx|.
     592           0 :   Maybe<JS::Rooted<JSObject *> > object;
     593           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     594           0 :   if (!isNull) {
     595           0 :     MOZ_ASSERT(cx);
     596           0 :     object.emplace(cx, &val.toObject());
     597           0 :     temp.emplace(cx);
     598             :   }
     599           0 :   if (!isNull) {
     600           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->composite_id, temp.ptr())) {
     601           0 :       return false;
     602             :     }
     603             :   }
     604           0 :   if (!isNull && !temp->isUndefined()) {
     605             :     {
     606             :       int index;
     607           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), CompositeOperationValues::strings, "CompositeOperation", "'composite' member of KeyframeEffectOptions", &index)) {
     608           0 :         return false;
     609             :       }
     610           0 :       MOZ_ASSERT(index >= 0);
     611           0 :       mComposite = static_cast<CompositeOperation>(index);
     612             :     }
     613             :   } else {
     614           0 :     mComposite = CompositeOperation::Replace;
     615             :   }
     616           0 :   mIsAnyMemberPresent = true;
     617             : 
     618           0 :   if (!isNull) {
     619           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->iterationComposite_id, temp.ptr())) {
     620           0 :       return false;
     621             :     }
     622             :   }
     623           0 :   if (!isNull && !temp->isUndefined()) {
     624             :     {
     625             :       int index;
     626           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), IterationCompositeOperationValues::strings, "IterationCompositeOperation", "'iterationComposite' member of KeyframeEffectOptions", &index)) {
     627           0 :         return false;
     628             :       }
     629           0 :       MOZ_ASSERT(index >= 0);
     630           0 :       mIterationComposite = static_cast<IterationCompositeOperation>(index);
     631             :     }
     632             :   } else {
     633           0 :     mIterationComposite = IterationCompositeOperation::Replace;
     634             :   }
     635           0 :   mIsAnyMemberPresent = true;
     636           0 :   return true;
     637             : }
     638             : 
     639             : bool
     640           0 : KeyframeEffectOptions::Init(const nsAString& aJSON)
     641             : {
     642           0 :   AutoJSAPI jsapi;
     643           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     644           0 :   if (!cleanGlobal) {
     645           0 :     return false;
     646             :   }
     647           0 :   if (!jsapi.Init(cleanGlobal)) {
     648           0 :     return false;
     649             :   }
     650           0 :   JSContext* cx = jsapi.cx();
     651           0 :   JS::Rooted<JS::Value> json(cx);
     652           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     653           0 :   NS_ENSURE_TRUE(ok, false);
     654           0 :   return Init(cx, json);
     655             : }
     656             : 
     657             : bool
     658           0 : KeyframeEffectOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     659             : {
     660           0 :   KeyframeEffectOptionsAtoms* atomsCache = GetAtomCache<KeyframeEffectOptionsAtoms>(cx);
     661           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     662           0 :     return false;
     663             :   }
     664             : 
     665             :   // Per spec, we define the parent's members first
     666           0 :   if (!AnimationEffectTimingProperties::ToObjectInternal(cx, rval)) {
     667           0 :     return false;
     668             :   }
     669           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     670             : 
     671             :   do {
     672             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     673           0 :     JS::Rooted<JS::Value> temp(cx);
     674           0 :     CompositeOperation const & currentValue = mComposite;
     675           0 :     if (!ToJSValue(cx, currentValue, &temp)) {
     676           0 :       return false;
     677             :     }
     678           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->composite_id, temp, JSPROP_ENUMERATE)) {
     679           0 :       return false;
     680             :     }
     681           0 :     break;
     682             :   } while(0);
     683             : 
     684             :   do {
     685             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     686           0 :     JS::Rooted<JS::Value> temp(cx);
     687           0 :     IterationCompositeOperation const & currentValue = mIterationComposite;
     688           0 :     if (!ToJSValue(cx, currentValue, &temp)) {
     689           0 :       return false;
     690             :     }
     691           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->iterationComposite_id, temp, JSPROP_ENUMERATE)) {
     692           0 :       return false;
     693             :     }
     694           0 :     break;
     695             :   } while(0);
     696             : 
     697           0 :   return true;
     698             : }
     699             : 
     700             : bool
     701           0 : KeyframeEffectOptions::ToJSON(nsAString& aJSON) const
     702             : {
     703           0 :   AutoJSAPI jsapi;
     704           0 :   jsapi.Init();
     705           0 :   JSContext *cx = jsapi.cx();
     706             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     707             :   // because we'll only be creating objects, in ways that have no
     708             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     709             :   // which likewise guarantees no side-effects for the sorts of
     710             :   // things we will pass it.
     711           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     712           0 :   JS::Rooted<JS::Value> val(cx);
     713           0 :   if (!ToObjectInternal(cx, &val)) {
     714           0 :     return false;
     715             :   }
     716           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     717           0 :   return StringifyToJSON(cx, obj, aJSON);
     718             : }
     719             : 
     720             : void
     721           0 : KeyframeEffectOptions::TraceDictionary(JSTracer* trc)
     722             : {
     723           0 :   AnimationEffectTimingProperties::TraceDictionary(trc);
     724           0 : }
     725             : 
     726             : KeyframeEffectOptions&
     727           0 : KeyframeEffectOptions::operator=(const KeyframeEffectOptions& aOther)
     728             : {
     729           0 :   AnimationEffectTimingProperties::operator=(aOther);
     730           0 :   mComposite = aOther.mComposite;
     731           0 :   mIterationComposite = aOther.mIterationComposite;
     732           0 :   return *this;
     733             : }
     734             : 
     735             : namespace binding_detail {
     736             : } // namespace binding_detail
     737             : 
     738             : 
     739             : 
     740           0 : AnimationPropertyDetails::AnimationPropertyDetails()
     741             : {
     742             :   // Safe to pass a null context if we pass a null value
     743           0 :   Init(nullptr, JS::NullHandleValue);
     744           0 : }
     745             : 
     746             : 
     747             : 
     748             : bool
     749           0 : AnimationPropertyDetails::InitIds(JSContext* cx, AnimationPropertyDetailsAtoms* atomsCache)
     750             : {
     751           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     752             : 
     753             :   // Initialize these in reverse order so that any failure leaves the first one
     754             :   // uninitialized.
     755           0 :   if (!atomsCache->warning_id.init(cx, "warning") ||
     756           0 :       !atomsCache->values_id.init(cx, "values") ||
     757           0 :       !atomsCache->runningOnCompositor_id.init(cx, "runningOnCompositor") ||
     758           0 :       !atomsCache->property_id.init(cx, "property")) {
     759           0 :     return false;
     760             :   }
     761           0 :   return true;
     762             : }
     763             : 
     764             : bool
     765           0 : AnimationPropertyDetails::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     766             : {
     767             :   // Passing a null JSContext is OK only if we're initing from null,
     768             :   // Since in that case we will not have to do any property gets
     769             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     770             :   // checkers by static analysis tools
     771           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     772           0 :   AnimationPropertyDetailsAtoms* atomsCache = nullptr;
     773           0 :   if (cx) {
     774           0 :     atomsCache = GetAtomCache<AnimationPropertyDetailsAtoms>(cx);
     775           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     776           0 :       return false;
     777             :     }
     778             :   }
     779             : 
     780           0 :   if (!IsConvertibleToDictionary(val)) {
     781           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     782             :   }
     783             : 
     784           0 :   bool isNull = val.isNullOrUndefined();
     785             :   // We only need these if !isNull, in which case we have |cx|.
     786           0 :   Maybe<JS::Rooted<JSObject *> > object;
     787           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     788           0 :   if (!isNull) {
     789           0 :     MOZ_ASSERT(cx);
     790           0 :     object.emplace(cx, &val.toObject());
     791           0 :     temp.emplace(cx);
     792             :   }
     793           0 :   if (!isNull) {
     794           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->property_id, temp.ptr())) {
     795           0 :       return false;
     796             :     }
     797             :   }
     798           0 :   if (!isNull && !temp->isUndefined()) {
     799           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mProperty)) {
     800           0 :       return false;
     801             :     }
     802           0 :     mIsAnyMemberPresent = true;
     803           0 :   } else if (cx) {
     804             :     // Don't error out if we have no cx.  In that
     805             :     // situation the caller is default-constructing us and we'll
     806             :     // just assume they know what they're doing.
     807           0 :     return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
     808           0 :                              "'property' member of AnimationPropertyDetails");
     809             :   }
     810             : 
     811           0 :   if (!isNull) {
     812           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->runningOnCompositor_id, temp.ptr())) {
     813           0 :       return false;
     814             :     }
     815             :   }
     816           0 :   if (!isNull && !temp->isUndefined()) {
     817           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mRunningOnCompositor)) {
     818           0 :       return false;
     819             :     }
     820           0 :     mIsAnyMemberPresent = true;
     821           0 :   } else if (cx) {
     822             :     // Don't error out if we have no cx.  In that
     823             :     // situation the caller is default-constructing us and we'll
     824             :     // just assume they know what they're doing.
     825           0 :     return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
     826           0 :                              "'runningOnCompositor' member of AnimationPropertyDetails");
     827             :   }
     828             : 
     829           0 :   if (!isNull) {
     830           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->values_id, temp.ptr())) {
     831           0 :       return false;
     832             :     }
     833             :   }
     834           0 :   if (!isNull && !temp->isUndefined()) {
     835           0 :     if (temp.ref().isObject()) {
     836           0 :       JS::ForOfIterator iter(cx);
     837           0 :       if (!iter.init(temp.ref(), JS::ForOfIterator::AllowNonIterable)) {
     838           0 :         return false;
     839             :       }
     840           0 :       if (!iter.valueIsIterable()) {
     841           0 :         ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'values' member of AnimationPropertyDetails");
     842           0 :         return false;
     843             :       }
     844           0 :       Sequence<AnimationPropertyValueDetails> &arr = mValues;
     845           0 :       JS::Rooted<JS::Value> temp(cx);
     846             :       while (true) {
     847             :         bool done;
     848           0 :         if (!iter.next(&temp, &done)) {
     849           0 :           return false;
     850             :         }
     851           0 :         if (done) {
     852           0 :           break;
     853             :         }
     854           0 :         AnimationPropertyValueDetails* slotPtr = arr.AppendElement(mozilla::fallible);
     855           0 :         if (!slotPtr) {
     856           0 :           JS_ReportOutOfMemory(cx);
     857           0 :           return false;
     858             :         }
     859           0 :         AnimationPropertyValueDetails& slot = *slotPtr;
     860           0 :         if (!slot.Init(cx, temp,  "Element of 'values' member of AnimationPropertyDetails", passedToJSImpl)) {
     861           0 :           return false;
     862             :         }
     863           0 :       }
     864             :     } else {
     865           0 :       ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "'values' member of AnimationPropertyDetails");
     866           0 :       return false;
     867             :     }
     868           0 :     mIsAnyMemberPresent = true;
     869           0 :   } else if (cx) {
     870             :     // Don't error out if we have no cx.  In that
     871             :     // situation the caller is default-constructing us and we'll
     872             :     // just assume they know what they're doing.
     873           0 :     return ThrowErrorMessage(cx, MSG_MISSING_REQUIRED_DICTIONARY_MEMBER,
     874           0 :                              "'values' member of AnimationPropertyDetails");
     875             :   }
     876             : 
     877           0 :   if (!isNull) {
     878           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->warning_id, temp.ptr())) {
     879           0 :       return false;
     880             :     }
     881             :   }
     882           0 :   if (!isNull && !temp->isUndefined()) {
     883           0 :     mWarning.Construct();
     884           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mWarning.Value()))) {
     885           0 :       return false;
     886             :     }
     887           0 :     mIsAnyMemberPresent = true;
     888             :   }
     889           0 :   return true;
     890             : }
     891             : 
     892             : bool
     893           0 : AnimationPropertyDetails::Init(const nsAString& aJSON)
     894             : {
     895           0 :   AutoJSAPI jsapi;
     896           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     897           0 :   if (!cleanGlobal) {
     898           0 :     return false;
     899             :   }
     900           0 :   if (!jsapi.Init(cleanGlobal)) {
     901           0 :     return false;
     902             :   }
     903           0 :   JSContext* cx = jsapi.cx();
     904           0 :   JS::Rooted<JS::Value> json(cx);
     905           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     906           0 :   NS_ENSURE_TRUE(ok, false);
     907           0 :   return Init(cx, json);
     908             : }
     909             : 
     910             : bool
     911           0 : AnimationPropertyDetails::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     912             : {
     913           0 :   AnimationPropertyDetailsAtoms* atomsCache = GetAtomCache<AnimationPropertyDetailsAtoms>(cx);
     914           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     915           0 :     return false;
     916             :   }
     917             : 
     918           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     919           0 :   if (!obj) {
     920           0 :     return false;
     921             :   }
     922           0 :   rval.set(JS::ObjectValue(*obj));
     923             : 
     924             :   do {
     925             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     926           0 :     JS::Rooted<JS::Value> temp(cx);
     927           0 :     nsString const & currentValue = mProperty;
     928           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     929           0 :       return false;
     930             :     }
     931           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->property_id, temp, JSPROP_ENUMERATE)) {
     932           0 :       return false;
     933             :     }
     934           0 :     break;
     935             :   } while(0);
     936             : 
     937             :   do {
     938             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     939           0 :     JS::Rooted<JS::Value> temp(cx);
     940           0 :     bool const & currentValue = mRunningOnCompositor;
     941           0 :     temp.setBoolean(currentValue);
     942           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->runningOnCompositor_id, temp, JSPROP_ENUMERATE)) {
     943           0 :       return false;
     944             :     }
     945           0 :     break;
     946             :   } while(0);
     947             : 
     948             :   do {
     949             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     950           0 :     JS::Rooted<JS::Value> temp(cx);
     951           0 :     Sequence<AnimationPropertyValueDetails> const & currentValue = mValues;
     952             : 
     953           0 :     uint32_t length = currentValue.Length();
     954           0 :     JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     955           0 :     if (!returnArray) {
     956           0 :       return false;
     957             :     }
     958             :     // Scope for 'tmp'
     959             :     {
     960           0 :       JS::Rooted<JS::Value> tmp(cx);
     961           0 :       for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     962             :         // Control block to let us common up the JS_DefineElement calls when there
     963             :         // are different ways to succeed at wrapping the object.
     964             :         do {
     965           0 :           if (!currentValue[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
     966           0 :             return false;
     967             :           }
     968           0 :           break;
     969             :         } while (0);
     970           0 :         if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     971             :                               JSPROP_ENUMERATE)) {
     972           0 :           return false;
     973             :         }
     974             :       }
     975             :     }
     976           0 :     temp.setObject(*returnArray);
     977           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->values_id, temp, JSPROP_ENUMERATE)) {
     978           0 :       return false;
     979             :     }
     980           0 :     break;
     981             :   } while(0);
     982             : 
     983           0 :   if (mWarning.WasPassed()) {
     984             :     do {
     985             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     986           0 :       JS::Rooted<JS::Value> temp(cx);
     987           0 :       nsString const & currentValue = mWarning.InternalValue();
     988           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     989           0 :         return false;
     990             :       }
     991           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->warning_id, temp, JSPROP_ENUMERATE)) {
     992           0 :         return false;
     993             :       }
     994           0 :       break;
     995             :     } while(0);
     996             :   }
     997             : 
     998           0 :   return true;
     999             : }
    1000             : 
    1001             : bool
    1002           0 : AnimationPropertyDetails::ToJSON(nsAString& aJSON) const
    1003             : {
    1004           0 :   AutoJSAPI jsapi;
    1005           0 :   jsapi.Init();
    1006           0 :   JSContext *cx = jsapi.cx();
    1007             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
    1008             :   // because we'll only be creating objects, in ways that have no
    1009             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
    1010             :   // which likewise guarantees no side-effects for the sorts of
    1011             :   // things we will pass it.
    1012           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
    1013           0 :   JS::Rooted<JS::Value> val(cx);
    1014           0 :   if (!ToObjectInternal(cx, &val)) {
    1015           0 :     return false;
    1016             :   }
    1017           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
    1018           0 :   return StringifyToJSON(cx, obj, aJSON);
    1019             : }
    1020             : 
    1021             : void
    1022           0 : AnimationPropertyDetails::TraceDictionary(JSTracer* trc)
    1023             : {
    1024           0 : }
    1025             : 
    1026             : AnimationPropertyDetails&
    1027           0 : AnimationPropertyDetails::operator=(const AnimationPropertyDetails& aOther)
    1028             : {
    1029           0 :   mProperty = aOther.mProperty;
    1030           0 :   mRunningOnCompositor = aOther.mRunningOnCompositor;
    1031           0 :   mValues = aOther.mValues;
    1032           0 :   mWarning.Reset();
    1033           0 :   if (aOther.mWarning.WasPassed()) {
    1034           0 :     mWarning.Construct(aOther.mWarning.Value());
    1035             :   }
    1036           0 :   return *this;
    1037             : }
    1038             : 
    1039             : namespace binding_detail {
    1040             : } // namespace binding_detail
    1041             : 
    1042             : 
    1043             : bool
    1044           0 : UnrestrictedDoubleOrKeyframeEffectOptions::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
    1045             : {
    1046           0 :   switch (mType) {
    1047             :     case eUninitialized: {
    1048           0 :       return false;
    1049             :       break;
    1050             :     }
    1051             :     case eUnrestrictedDouble: {
    1052           0 :       rval.set(JS_NumberValue(double(mValue.mUnrestrictedDouble.Value())));
    1053           0 :       return true;
    1054             :       break;
    1055             :     }
    1056             :     case eKeyframeEffectOptions: {
    1057           0 :       if (!mValue.mKeyframeEffectOptions.Value().ToObjectInternal(cx, rval)) {
    1058           0 :         return false;
    1059             :       }
    1060           0 :       return true;
    1061             :       break;
    1062             :     }
    1063             :     default: {
    1064           0 :       return false;
    1065             :       break;
    1066             :     }
    1067             :   }
    1068             : 
    1069             :   return false;
    1070             : }
    1071             : 
    1072             : 
    1073             : double&
    1074           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::RawSetAsUnrestrictedDouble()
    1075             : {
    1076           0 :   if (mType == eUnrestrictedDouble) {
    1077           0 :     return mValue.mUnrestrictedDouble.Value();
    1078             :   }
    1079           0 :   MOZ_ASSERT(mType == eUninitialized);
    1080           0 :   mType = eUnrestrictedDouble;
    1081           0 :   return mValue.mUnrestrictedDouble.SetValue();
    1082             : }
    1083             : 
    1084             : double&
    1085           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::SetAsUnrestrictedDouble()
    1086             : {
    1087           0 :   if (mType == eUnrestrictedDouble) {
    1088           0 :     return mValue.mUnrestrictedDouble.Value();
    1089             :   }
    1090           0 :   Uninit();
    1091           0 :   mType = eUnrestrictedDouble;
    1092           0 :   return mValue.mUnrestrictedDouble.SetValue();
    1093             : }
    1094             : 
    1095             : bool
    1096           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::TrySetToUnrestrictedDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
    1097             : {
    1098           0 :   tryNext = false;
    1099             :   { // scope for memberSlot
    1100           0 :     double& memberSlot = RawSetAsUnrestrictedDouble();
    1101           0 :     if (!ValueToPrimitive<double, eDefault>(cx, value, &memberSlot)) {
    1102           0 :       return false;
    1103             :     }
    1104             :   }
    1105           0 :   return true;
    1106             : }
    1107             : 
    1108             : void
    1109           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::DestroyUnrestrictedDouble()
    1110             : {
    1111           0 :   MOZ_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
    1112           0 :   mValue.mUnrestrictedDouble.Destroy();
    1113           0 :   mType = eUninitialized;
    1114           0 : }
    1115             : 
    1116             : 
    1117             : 
    1118             : 
    1119             : KeyframeEffectOptions&
    1120           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::RawSetAsKeyframeEffectOptions()
    1121             : {
    1122           0 :   if (mType == eKeyframeEffectOptions) {
    1123           0 :     return mValue.mKeyframeEffectOptions.Value();
    1124             :   }
    1125           0 :   MOZ_ASSERT(mType == eUninitialized);
    1126           0 :   mType = eKeyframeEffectOptions;
    1127           0 :   return mValue.mKeyframeEffectOptions.SetValue();
    1128             : }
    1129             : 
    1130             : KeyframeEffectOptions&
    1131           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::SetAsKeyframeEffectOptions()
    1132             : {
    1133           0 :   if (mType == eKeyframeEffectOptions) {
    1134           0 :     return mValue.mKeyframeEffectOptions.Value();
    1135             :   }
    1136           0 :   Uninit();
    1137           0 :   mType = eKeyframeEffectOptions;
    1138           0 :   return mValue.mKeyframeEffectOptions.SetValue();
    1139             : }
    1140             : 
    1141             : bool
    1142           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::TrySetToKeyframeEffectOptions(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
    1143             : {
    1144           0 :   tryNext = false;
    1145             :   { // scope for memberSlot
    1146           0 :     KeyframeEffectOptions& memberSlot = RawSetAsKeyframeEffectOptions();
    1147           0 :     if (!IsConvertibleToDictionary(value)) {
    1148           0 :       DestroyKeyframeEffectOptions();
    1149           0 :       tryNext = true;
    1150           0 :       return true;
    1151             :     }
    1152           0 :     if (!memberSlot.Init(cx, value,  "Member of UnrestrictedDoubleOrKeyframeEffectOptions", passedToJSImpl)) {
    1153           0 :       return false;
    1154             :     }
    1155             :   }
    1156           0 :   return true;
    1157             : }
    1158             : 
    1159             : void
    1160           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::DestroyKeyframeEffectOptions()
    1161             : {
    1162           0 :   MOZ_ASSERT(IsKeyframeEffectOptions(), "Wrong type!");
    1163           0 :   mValue.mKeyframeEffectOptions.Destroy();
    1164           0 :   mType = eUninitialized;
    1165           0 : }
    1166             : 
    1167             : 
    1168             : 
    1169             : 
    1170             : void
    1171           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::Uninit()
    1172             : {
    1173           0 :   switch (mType) {
    1174             :     case eUninitialized: {
    1175           0 :       break;
    1176             :     }
    1177             :     case eUnrestrictedDouble: {
    1178           0 :       DestroyUnrestrictedDouble();
    1179           0 :       break;
    1180             :     }
    1181             :     case eKeyframeEffectOptions: {
    1182           0 :       DestroyKeyframeEffectOptions();
    1183           0 :       break;
    1184             :     }
    1185             :   }
    1186           0 : }
    1187             : 
    1188             : bool
    1189           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
    1190             : {
    1191           0 :   switch (mType) {
    1192             :     case eUninitialized: {
    1193           0 :       return false;
    1194             :       break;
    1195             :     }
    1196             :     case eUnrestrictedDouble: {
    1197           0 :       rval.set(JS_NumberValue(double(mValue.mUnrestrictedDouble.Value())));
    1198           0 :       return true;
    1199             :       break;
    1200             :     }
    1201             :     case eKeyframeEffectOptions: {
    1202           0 :       if (!mValue.mKeyframeEffectOptions.Value().ToObjectInternal(cx, rval)) {
    1203           0 :         return false;
    1204             :       }
    1205           0 :       return true;
    1206             :       break;
    1207             :     }
    1208             :     default: {
    1209           0 :       return false;
    1210             :       break;
    1211             :     }
    1212             :   }
    1213             : 
    1214             :   return false;
    1215             : }
    1216             : 
    1217             : void
    1218           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::TraceUnion(JSTracer* trc)
    1219             : {
    1220           0 : }
    1221             : 
    1222             : OwningUnrestrictedDoubleOrKeyframeEffectOptions&
    1223           0 : OwningUnrestrictedDoubleOrKeyframeEffectOptions::operator=(const OwningUnrestrictedDoubleOrKeyframeEffectOptions& aOther)
    1224             : {
    1225           0 :   switch (aOther.mType) {
    1226             :     case eUninitialized: {
    1227           0 :       MOZ_ASSERT(mType == eUninitialized,
    1228             :                  "We need to destroy ourselves?");
    1229           0 :       break;
    1230             :     }
    1231             :     case eUnrestrictedDouble: {
    1232           0 :       SetAsUnrestrictedDouble() = aOther.GetAsUnrestrictedDouble();
    1233           0 :       break;
    1234             :     }
    1235             :     case eKeyframeEffectOptions: {
    1236           0 :       SetAsKeyframeEffectOptions() = aOther.GetAsKeyframeEffectOptions();
    1237           0 :       break;
    1238             :     }
    1239             :   }
    1240           0 :   return *this;
    1241             : }
    1242             : 
    1243             : 
    1244             : namespace KeyframeEffectBinding {
    1245             : 
    1246             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<KeyframeEffectReadOnlyBinding::NativeType>::value,
    1247             :               "Can't inherit from an interface with a different ownership model.");
    1248             : 
    1249             : static bool
    1250           0 : get_target(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, JSJitGetterCallArgs args)
    1251             : {
    1252           0 :   Nullable<OwningElementOrCSSPseudoElement> result;
    1253           0 :   self->GetTarget(result);
    1254           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1255           0 :   if (result.IsNull()) {
    1256           0 :     args.rval().setNull();
    1257           0 :     return true;
    1258             :   }
    1259           0 :   if (!result.Value().ToJSVal(cx, obj, args.rval())) {
    1260           0 :     return false;
    1261             :   }
    1262           0 :   return true;
    1263             : }
    1264             : 
    1265             : static bool
    1266           0 : set_target(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, JSJitSetterCallArgs args)
    1267             : {
    1268           0 :   Nullable<ElementOrCSSPseudoElement > arg0;
    1269           0 :   Maybe<ElementOrCSSPseudoElementArgument> arg0_holder;
    1270           0 :   if (args[0].isNullOrUndefined()) {
    1271           0 :     arg0.SetNull();
    1272             :   } else {
    1273           0 :     arg0_holder.emplace(arg0.SetValue());
    1274             :     {
    1275           0 :       bool done = false, failed = false, tryNext;
    1276           0 :       if (args[0].isObject()) {
    1277           0 :         done = (failed = !arg0_holder.ref().TrySetToElement(cx, args[0], tryNext, false)) || !tryNext ||
    1278           0 :                (failed = !arg0_holder.ref().TrySetToCSSPseudoElement(cx, args[0], tryNext, false)) || !tryNext;
    1279             : 
    1280             :       }
    1281           0 :       if (failed) {
    1282           0 :         return false;
    1283             :       }
    1284           0 :       if (!done) {
    1285           0 :         ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Value being assigned to KeyframeEffect.target", "Element, CSSPseudoElement");
    1286           0 :         return false;
    1287             :       }
    1288             :     }
    1289             :   }
    1290           0 :   self->SetTarget(Constify(arg0));
    1291           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1292             : 
    1293           0 :   return true;
    1294             : }
    1295             : 
    1296             : static const JSJitInfo target_getterinfo = {
    1297             :   { (JSJitGetterOp)get_target },
    1298             :   { prototypes::id::KeyframeEffect },
    1299             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1300             :   JSJitInfo::Getter,
    1301             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1302             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    1303             :   false,  /* isInfallible. False in setters. */
    1304             :   false,  /* isMovable.  Not relevant for setters. */
    1305             :   false, /* isEliminatable.  Not relevant for setters. */
    1306             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1307             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1308             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1309             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1310             : };
    1311             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1312             : static_assert(0 < 2, "There is no slot for us");
    1313             : static const JSJitInfo target_setterinfo = {
    1314             :   { (JSJitGetterOp)set_target },
    1315             :   { prototypes::id::KeyframeEffect },
    1316             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1317             :   JSJitInfo::Setter,
    1318             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1319             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1320             :   false,  /* isInfallible. False in setters. */
    1321             :   false,  /* isMovable.  Not relevant for setters. */
    1322             :   false, /* isEliminatable.  Not relevant for setters. */
    1323             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1324             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1325             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1326             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1327             : };
    1328             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1329             : static_assert(0 < 2, "There is no slot for us");
    1330             : 
    1331             : static bool
    1332           0 : get_iterationComposite(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, JSJitGetterCallArgs args)
    1333             : {
    1334           0 :   IterationCompositeOperation result(self->IterationComposite(nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem));
    1335           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1336           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1337           0 :     return false;
    1338             :   }
    1339           0 :   return true;
    1340             : }
    1341             : 
    1342             : static bool
    1343           0 : set_iterationComposite(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, JSJitSetterCallArgs args)
    1344             : {
    1345             :   IterationCompositeOperation arg0;
    1346             :   {
    1347             :     int index;
    1348           0 :     if (!FindEnumStringIndex<false>(cx, args[0], IterationCompositeOperationValues::strings, "IterationCompositeOperation", "Value being assigned to KeyframeEffect.iterationComposite", &index)) {
    1349           0 :       return false;
    1350             :     }
    1351           0 :     if (index < 0) {
    1352           0 :       return true;
    1353             :     }
    1354           0 :     arg0 = static_cast<IterationCompositeOperation>(index);
    1355             :   }
    1356           0 :   self->SetIterationComposite(arg0, nsContentUtils::IsSystemCaller(cx) ? CallerType::System : CallerType::NonSystem);
    1357           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1358             : 
    1359           0 :   return true;
    1360             : }
    1361             : 
    1362             : static const JSJitInfo iterationComposite_getterinfo = {
    1363             :   { (JSJitGetterOp)get_iterationComposite },
    1364             :   { prototypes::id::KeyframeEffect },
    1365             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1366             :   JSJitInfo::Getter,
    1367             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1368             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1369             :   false,  /* isInfallible. False in setters. */
    1370             :   false,  /* isMovable.  Not relevant for setters. */
    1371             :   false, /* isEliminatable.  Not relevant for setters. */
    1372             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1373             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1374             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1375             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1376             : };
    1377             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1378             : static_assert(0 < 2, "There is no slot for us");
    1379             : static const JSJitInfo iterationComposite_setterinfo = {
    1380             :   { (JSJitGetterOp)set_iterationComposite },
    1381             :   { prototypes::id::KeyframeEffect },
    1382             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1383             :   JSJitInfo::Setter,
    1384             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1385             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1386             :   false,  /* isInfallible. False in setters. */
    1387             :   false,  /* isMovable.  Not relevant for setters. */
    1388             :   false, /* isEliminatable.  Not relevant for setters. */
    1389             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1390             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1391             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1392             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1393             : };
    1394             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1395             : static_assert(0 < 2, "There is no slot for us");
    1396             : 
    1397             : static bool
    1398           0 : get_composite(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, JSJitGetterCallArgs args)
    1399             : {
    1400           0 :   CompositeOperation result(self->Composite());
    1401           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1402           0 :   if (!ToJSValue(cx, result, args.rval())) {
    1403           0 :     return false;
    1404             :   }
    1405           0 :   return true;
    1406             : }
    1407             : 
    1408             : static bool
    1409           0 : set_composite(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, JSJitSetterCallArgs args)
    1410             : {
    1411             :   CompositeOperation arg0;
    1412             :   {
    1413             :     int index;
    1414           0 :     if (!FindEnumStringIndex<false>(cx, args[0], CompositeOperationValues::strings, "CompositeOperation", "Value being assigned to KeyframeEffect.composite", &index)) {
    1415           0 :       return false;
    1416             :     }
    1417           0 :     if (index < 0) {
    1418           0 :       return true;
    1419             :     }
    1420           0 :     arg0 = static_cast<CompositeOperation>(index);
    1421             :   }
    1422           0 :   self->SetComposite(arg0);
    1423           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1424             : 
    1425           0 :   return true;
    1426             : }
    1427             : 
    1428             : static const JSJitInfo composite_getterinfo = {
    1429             :   { (JSJitGetterOp)get_composite },
    1430             :   { prototypes::id::KeyframeEffect },
    1431             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1432             :   JSJitInfo::Getter,
    1433             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1434             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    1435             :   false,  /* isInfallible. False in setters. */
    1436             :   false,  /* isMovable.  Not relevant for setters. */
    1437             :   false, /* isEliminatable.  Not relevant for setters. */
    1438             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1439             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1440             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1441             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1442             : };
    1443             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1444             : static_assert(0 < 2, "There is no slot for us");
    1445             : static const JSJitInfo composite_setterinfo = {
    1446             :   { (JSJitGetterOp)set_composite },
    1447             :   { prototypes::id::KeyframeEffect },
    1448             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1449             :   JSJitInfo::Setter,
    1450             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1451             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1452             :   false,  /* isInfallible. False in setters. */
    1453             :   false,  /* isMovable.  Not relevant for setters. */
    1454             :   false, /* isEliminatable.  Not relevant for setters. */
    1455             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1456             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1457             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1458             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1459             : };
    1460             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1461             : static_assert(0 < 2, "There is no slot for us");
    1462             : 
    1463             : static bool
    1464           0 : setKeyframes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffect* self, const JSJitMethodCallArgs& args)
    1465             : {
    1466           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
    1467           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "KeyframeEffect.setKeyframes");
    1468             :   }
    1469           0 :   JS::Rooted<JSObject*> arg0(cx);
    1470           0 :   if (args[0].isObject()) {
    1471           0 :     arg0 = &args[0].toObject();
    1472           0 :   } else if (args[0].isNullOrUndefined()) {
    1473           0 :     arg0 = nullptr;
    1474             :   } else {
    1475           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of KeyframeEffect.setKeyframes");
    1476           0 :     return false;
    1477             :   }
    1478           0 :   binding_detail::FastErrorResult rv;
    1479           0 :   self->SetKeyframes(cx, arg0, rv);
    1480           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1481           0 :     return false;
    1482             :   }
    1483           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1484           0 :   args.rval().setUndefined();
    1485           0 :   return true;
    1486             : }
    1487             : 
    1488             : static const JSJitInfo setKeyframes_methodinfo = {
    1489             :   { (JSJitGetterOp)setKeyframes },
    1490             :   { prototypes::id::KeyframeEffect },
    1491             :   { PrototypeTraits<prototypes::id::KeyframeEffect>::Depth },
    1492             :   JSJitInfo::Method,
    1493             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    1494             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
    1495             :   false,  /* isInfallible. False in setters. */
    1496             :   false,  /* isMovable.  Not relevant for setters. */
    1497             :   false, /* isEliminatable.  Not relevant for setters. */
    1498             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    1499             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    1500             :   false,  /* isTypedMethod.  Only relevant for methods. */
    1501             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    1502             : };
    1503             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    1504             : static_assert(0 < 2, "There is no slot for us");
    1505             : 
    1506             : static bool
    1507           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    1508             : {
    1509           0 :   mozilla::dom::KeyframeEffect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyframeEffect>(obj);
    1510             :   // We don't want to preserve if we don't have a wrapper, and we
    1511             :   // obviously can't preserve if we're not initialized.
    1512           0 :   if (self && self->GetWrapperPreserveColor()) {
    1513           0 :     PreserveWrapper(self);
    1514             :   }
    1515           0 :   return true;
    1516             : }
    1517             : 
    1518             : static void
    1519           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    1520             : {
    1521           0 :   mozilla::dom::KeyframeEffect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyframeEffect>(obj);
    1522           0 :   if (self) {
    1523           0 :     ClearWrapper(self, self, obj);
    1524           0 :     AddForDeferredFinalization<mozilla::dom::KeyframeEffect>(self);
    1525             :   }
    1526           0 : }
    1527             : 
    1528             : static void
    1529           0 : _objectMoved(JSObject* obj, const JSObject* old)
    1530             : {
    1531           0 :   mozilla::dom::KeyframeEffect* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyframeEffect>(obj);
    1532           0 :   if (self) {
    1533           0 :     UpdateWrapper(self, self, obj, old);
    1534             :   }
    1535           0 : }
    1536             : 
    1537             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1538             : #if defined(__clang__)
    1539             : #pragma clang diagnostic push
    1540             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1541             : #endif
    1542             : static const JSFunctionSpec sMethods_specs[] = {
    1543             :   JS_FNSPEC("setKeyframes", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setKeyframes_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
    1544             :   JS_FS_END
    1545             : };
    1546             : #if defined(__clang__)
    1547             : #pragma clang diagnostic pop
    1548             : #endif
    1549             : 
    1550             : 
    1551             : // Can't be const because the pref-enabled boolean needs to be writable
    1552             : static Prefable<const JSFunctionSpec> sMethods[] = {
    1553             :   { nullptr, &sMethods_specs[0] },
    1554             :   { nullptr, nullptr }
    1555             : };
    1556             : 
    1557             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1558             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1559             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1560             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1561             : 
    1562             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    1563             : #if defined(__clang__)
    1564             : #pragma clang diagnostic push
    1565             : #pragma clang diagnostic ignored "-Wmissing-braces"
    1566             : #endif
    1567             : static const JSPropertySpec sAttributes_specs[] = {
    1568             :   { "target", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &target_getterinfo, GenericBindingSetter, &target_setterinfo },
    1569             :   { "iterationComposite", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &iterationComposite_getterinfo, GenericBindingSetter, &iterationComposite_setterinfo },
    1570             :   { "composite", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &composite_getterinfo, GenericBindingSetter, &composite_setterinfo },
    1571             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    1572             : };
    1573             : #if defined(__clang__)
    1574             : #pragma clang diagnostic pop
    1575             : #endif
    1576             : 
    1577             : 
    1578             : // Can't be const because the pref-enabled boolean needs to be writable
    1579             : static Prefable<const JSPropertySpec> sAttributes[] = {
    1580             :   { nullptr, &sAttributes_specs[0] },
    1581             :   { nullptr, nullptr }
    1582             : };
    1583             : 
    1584             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    1585             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    1586             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    1587             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    1588             : 
    1589             : 
    1590             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
    1591             : static PropertyInfo sNativeProperties_propertyInfos[4];
    1592             : 
    1593             : static const NativePropertiesN<2> sNativeProperties = {
    1594             :   false, 0,
    1595             :   false, 0,
    1596             :   true,  0 /* sMethods */,
    1597             :   true,  1 /* sAttributes */,
    1598             :   false, 0,
    1599             :   false, 0,
    1600             :   false, 0,
    1601             :   -1,
    1602             :   4,
    1603             :   sNativeProperties_sortedPropertyIndices,
    1604             :   {
    1605             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    1606             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
    1607             :   }
    1608             : };
    1609             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1610             :     "We have a property info count that is oversized");
    1611             : 
    1612             : static bool
    1613           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    1614             : {
    1615           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    1616           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    1617           0 :   if (!args.isConstructing()) {
    1618             :     // XXXbz wish I could get the name from the callee instead of
    1619             :     // Adding more relocations
    1620           0 :     return ThrowConstructorWithoutNew(cx, "KeyframeEffect");
    1621             :   }
    1622             : 
    1623           0 :   GlobalObject global(cx, obj);
    1624           0 :   if (global.Failed()) {
    1625           0 :     return false;
    1626             :   }
    1627             : 
    1628           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    1629           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    1630           0 :     return false;
    1631             :   }
    1632             : 
    1633           0 :   unsigned argcount = std::min(args.length(), 3u);
    1634           0 :   switch (argcount) {
    1635             :     case 1: {
    1636           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1637           0 :       NonNull<mozilla::dom::KeyframeEffectReadOnly> arg0;
    1638           0 :       if (args[0].isObject()) {
    1639             :         {
    1640           0 :           nsresult rv = UnwrapObject<prototypes::id::KeyframeEffectReadOnly, mozilla::dom::KeyframeEffectReadOnly>(args[0], arg0);
    1641           0 :           if (NS_FAILED(rv)) {
    1642           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of KeyframeEffect.constructor", "KeyframeEffectReadOnly");
    1643           0 :             return false;
    1644             :           }
    1645             :         }
    1646             :       } else {
    1647           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of KeyframeEffect.constructor");
    1648           0 :         return false;
    1649             :       }
    1650           0 :       Maybe<JSAutoCompartment> ac;
    1651           0 :       if (objIsXray) {
    1652           0 :         obj = js::CheckedUnwrap(obj);
    1653           0 :         if (!obj) {
    1654           0 :           return false;
    1655             :         }
    1656           0 :         ac.emplace(cx, obj);
    1657           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
    1658           0 :           return false;
    1659             :         }
    1660             :       }
    1661           0 :       binding_detail::FastErrorResult rv;
    1662           0 :       auto result(StrongOrRawPtr<mozilla::dom::KeyframeEffect>(mozilla::dom::KeyframeEffect::Constructor(global, NonNullHelper(arg0), rv)));
    1663           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1664           0 :         return false;
    1665             :       }
    1666           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1667             :       static_assert(!IsPointer<decltype(result)>::value,
    1668             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    1669           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1670           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1671           0 :         return false;
    1672             :       }
    1673           0 :       return true;
    1674             :       break;
    1675             :     }
    1676             :     case 2: {
    1677             :       MOZ_FALLTHROUGH;
    1678             :     }
    1679             :     case 3: {
    1680           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    1681           0 :       Nullable<ElementOrCSSPseudoElement > arg0;
    1682           0 :       Maybe<ElementOrCSSPseudoElementArgument> arg0_holder;
    1683           0 :       if (args[0].isNullOrUndefined()) {
    1684           0 :         arg0.SetNull();
    1685             :       } else {
    1686           0 :         arg0_holder.emplace(arg0.SetValue());
    1687             :         {
    1688           0 :           bool done = false, failed = false, tryNext;
    1689           0 :           if (args[0].isObject()) {
    1690           0 :             done = (failed = !arg0_holder.ref().TrySetToElement(cx, args[0], tryNext, false)) || !tryNext ||
    1691           0 :                    (failed = !arg0_holder.ref().TrySetToCSSPseudoElement(cx, args[0], tryNext, false)) || !tryNext;
    1692             : 
    1693             :           }
    1694           0 :           if (failed) {
    1695           0 :             return false;
    1696             :           }
    1697           0 :           if (!done) {
    1698           0 :             ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of KeyframeEffect.constructor", "Element, CSSPseudoElement");
    1699           0 :             return false;
    1700             :           }
    1701             :         }
    1702             :       }
    1703           0 :       JS::Rooted<JSObject*> arg1(cx);
    1704           0 :       if (args[1].isObject()) {
    1705           0 :         arg1 = &args[1].toObject();
    1706           0 :       } else if (args[1].isNullOrUndefined()) {
    1707           0 :         arg1 = nullptr;
    1708             :       } else {
    1709           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of KeyframeEffect.constructor");
    1710           0 :         return false;
    1711             :       }
    1712           0 :       UnrestrictedDoubleOrKeyframeEffectOptions arg2;
    1713           0 :       UnrestrictedDoubleOrKeyframeEffectOptionsArgument arg2_holder(arg2);
    1714           0 :       if (!(args.hasDefined(2))) {
    1715           0 :         if (!arg2.RawSetAsKeyframeEffectOptions().Init(cx, JS::NullHandleValue, "Member of UnrestrictedDoubleOrKeyframeEffectOptions")) {
    1716           0 :           return false;
    1717             :         }
    1718             :       } else {
    1719             :         {
    1720           0 :           bool done = false, failed = false, tryNext;
    1721           0 :           if (!done) {
    1722           0 :             done = (failed = !arg2_holder.TrySetToKeyframeEffectOptions(cx, args[2], tryNext, false)) || !tryNext;
    1723             :           }
    1724           0 :           if (!done) {
    1725             :             do {
    1726           0 :               done = (failed = !arg2_holder.TrySetToUnrestrictedDouble(cx, args[2], tryNext)) || !tryNext;
    1727           0 :               break;
    1728             :             } while (0);
    1729             :           }
    1730           0 :           if (failed) {
    1731           0 :             return false;
    1732             :           }
    1733           0 :           if (!done) {
    1734           0 :             ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of KeyframeEffect.constructor", "KeyframeEffectOptions");
    1735           0 :             return false;
    1736             :           }
    1737             :         }
    1738             :       }
    1739           0 :       Maybe<JSAutoCompartment> ac;
    1740           0 :       if (objIsXray) {
    1741           0 :         obj = js::CheckedUnwrap(obj);
    1742           0 :         if (!obj) {
    1743           0 :           return false;
    1744             :         }
    1745           0 :         ac.emplace(cx, obj);
    1746           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
    1747           0 :           return false;
    1748             :         }
    1749           0 :         if (!JS_WrapObject(cx, &arg1)) {
    1750           0 :           return false;
    1751             :         }
    1752             :       }
    1753           0 :       binding_detail::FastErrorResult rv;
    1754           0 :       auto result(StrongOrRawPtr<mozilla::dom::KeyframeEffect>(mozilla::dom::KeyframeEffect::Constructor(global, Constify(arg0), arg1, Constify(arg2), rv)));
    1755           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    1756           0 :         return false;
    1757             :       }
    1758           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    1759             :       static_assert(!IsPointer<decltype(result)>::value,
    1760             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    1761           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    1762           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    1763           0 :         return false;
    1764             :       }
    1765           0 :       return true;
    1766             :       break;
    1767             :     }
    1768             :     default: {
    1769           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "KeyframeEffect");
    1770             :       break;
    1771             :     }
    1772             :   }
    1773             :   MOZ_CRASH("We have an always-returning default case");
    1774             :   return false;
    1775             : }
    1776             : 
    1777             : static const js::ClassOps sInterfaceObjectClassOps = {
    1778             :     nullptr,               /* addProperty */
    1779             :     nullptr,               /* delProperty */
    1780             :     nullptr,               /* getProperty */
    1781             :     nullptr,               /* setProperty */
    1782             :     nullptr,               /* enumerate */
    1783             :     nullptr,               /* newEnumerate */
    1784             :     nullptr,               /* resolve */
    1785             :     nullptr,               /* mayResolve */
    1786             :     nullptr,               /* finalize */
    1787             :     _constructor, /* call */
    1788             :     nullptr,               /* hasInstance */
    1789             :     _constructor, /* construct */
    1790             :     nullptr,               /* trace */
    1791             : };
    1792             : 
    1793             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1794             :   {
    1795             :     "Function",
    1796             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1797             :     &sInterfaceObjectClassOps,
    1798             :     JS_NULL_CLASS_SPEC,
    1799             :     JS_NULL_CLASS_EXT,
    1800             :     &sInterfaceObjectClassObjectOps
    1801             :   },
    1802             :   eInterface,
    1803             :   true,
    1804             :   prototypes::id::KeyframeEffect,
    1805             :   PrototypeTraits<prototypes::id::KeyframeEffect>::Depth,
    1806             :   sNativePropertyHooks,
    1807             :   "function KeyframeEffect() {\n    [native code]\n}",
    1808             :   KeyframeEffectReadOnlyBinding::GetConstructorObject
    1809             : };
    1810             : 
    1811             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1812             :   {
    1813             :     "KeyframeEffectPrototype",
    1814             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1815             :     JS_NULL_CLASS_OPS,
    1816             :     JS_NULL_CLASS_SPEC,
    1817             :     JS_NULL_CLASS_EXT,
    1818             :     JS_NULL_OBJECT_OPS
    1819             :   },
    1820             :   eInterfacePrototype,
    1821             :   false,
    1822             :   prototypes::id::KeyframeEffect,
    1823             :   PrototypeTraits<prototypes::id::KeyframeEffect>::Depth,
    1824             :   sNativePropertyHooks,
    1825             :   "[object KeyframeEffectPrototype]",
    1826             :   KeyframeEffectReadOnlyBinding::GetProtoObject
    1827             : };
    1828             : 
    1829             : bool
    1830           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    1831             : {
    1832           0 :   return nsDocument::IsWebAnimationsEnabled(aCx, aObj);
    1833             : }
    1834             : 
    1835             : JSObject*
    1836           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1837             : {
    1838           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1839             : }
    1840             : 
    1841             : static const js::ClassOps sClassOps = {
    1842             :   _addProperty, /* addProperty */
    1843             :   nullptr,               /* delProperty */
    1844             :   nullptr,               /* getProperty */
    1845             :   nullptr,               /* setProperty */
    1846             :   nullptr,               /* enumerate */
    1847             :   nullptr, /* newEnumerate */
    1848             :   nullptr, /* resolve */
    1849             :   nullptr, /* mayResolve */
    1850             :   _finalize, /* finalize */
    1851             :   nullptr, /* call */
    1852             :   nullptr,               /* hasInstance */
    1853             :   nullptr,               /* construct */
    1854             :   nullptr, /* trace */
    1855             : };
    1856             : 
    1857             : static const js::ClassExtension sClassExtension = {
    1858             :   nullptr, /* weakmapKeyDelegateOp */
    1859             :   _objectMoved /* objectMovedOp */
    1860             : };
    1861             : 
    1862             : static const DOMJSClass sClass = {
    1863             :   { "KeyframeEffect",
    1864             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
    1865             :     &sClassOps,
    1866             :     JS_NULL_CLASS_SPEC,
    1867             :     &sClassExtension,
    1868             :     JS_NULL_OBJECT_OPS
    1869             :   },
    1870             :   { prototypes::id::AnimationEffectReadOnly, prototypes::id::KeyframeEffectReadOnly, prototypes::id::KeyframeEffect, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    1871             :   IsBaseOf<nsISupports, mozilla::dom::KeyframeEffect >::value,
    1872             :   sNativePropertyHooks,
    1873             :   FindAssociatedGlobalForNative<mozilla::dom::KeyframeEffect>::Get,
    1874             :   GetProtoObjectHandle,
    1875             :   GetCCParticipant<mozilla::dom::KeyframeEffect>::Get()
    1876             : };
    1877             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1878             :               "Must have the right minimal number of reserved slots.");
    1879             : static_assert(2 >= 2,
    1880             :               "Must have enough reserved slots.");
    1881             : 
    1882             : const JSClass*
    1883           0 : GetJSClass()
    1884             : {
    1885           0 :   return sClass.ToJSClass();
    1886             : }
    1887             : 
    1888             : bool
    1889           0 : Wrap(JSContext* aCx, mozilla::dom::KeyframeEffect* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1890             : {
    1891             :   MOZ_ASSERT(static_cast<mozilla::dom::KeyframeEffect*>(aObject) ==
    1892             :              reinterpret_cast<mozilla::dom::KeyframeEffect*>(aObject),
    1893             :              "Multiple inheritance for mozilla::dom::KeyframeEffect is broken.");
    1894             :   MOZ_ASSERT(static_cast<mozilla::dom::KeyframeEffectReadOnly*>(aObject) ==
    1895             :              reinterpret_cast<mozilla::dom::KeyframeEffectReadOnly*>(aObject),
    1896             :              "Multiple inheritance for mozilla::dom::KeyframeEffectReadOnly is broken.");
    1897             :   MOZ_ASSERT(static_cast<mozilla::dom::AnimationEffectReadOnly*>(aObject) ==
    1898             :              reinterpret_cast<mozilla::dom::AnimationEffectReadOnly*>(aObject),
    1899             :              "Multiple inheritance for mozilla::dom::AnimationEffectReadOnly is broken.");
    1900           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1901           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1902           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1903             :              "You should probably not be using Wrap() directly; use "
    1904             :              "GetOrCreateDOMReflector instead");
    1905             : 
    1906           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1907             :              "nsISupports must be on our primary inheritance chain");
    1908             : 
    1909           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1910           0 :   if (!global) {
    1911           0 :     return false;
    1912             :   }
    1913           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1914           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1915             : 
    1916             :   // That might have ended up wrapping us already, due to the wonders
    1917             :   // of XBL.  Check for that, and bail out as needed.
    1918           0 :   aReflector.set(aCache->GetWrapper());
    1919           0 :   if (aReflector) {
    1920             : #ifdef DEBUG
    1921           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1922             : #endif // DEBUG
    1923           0 :     return true;
    1924             :   }
    1925             : 
    1926           0 :   JSAutoCompartment ac(aCx, global);
    1927           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1928           0 :   if (!canonicalProto) {
    1929           0 :     return false;
    1930             :   }
    1931           0 :   JS::Rooted<JSObject*> proto(aCx);
    1932           0 :   if (aGivenProto) {
    1933           0 :     proto = aGivenProto;
    1934             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1935             :     // coming in, we changed compartments to that of "parent" so may need
    1936             :     // to wrap the proto here.
    1937           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1938           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1939           0 :         return false;
    1940             :       }
    1941             :     }
    1942             :   } else {
    1943           0 :     proto = canonicalProto;
    1944             :   }
    1945             : 
    1946           0 :   BindingJSObjectCreator<mozilla::dom::KeyframeEffect> creator(aCx);
    1947           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1948           0 :   if (!aReflector) {
    1949           0 :     return false;
    1950             :   }
    1951             : 
    1952           0 :   aCache->SetWrapper(aReflector);
    1953           0 :   creator.InitializationSucceeded();
    1954             : 
    1955           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1956             :              aCache->GetWrapperPreserveColor() == aReflector);
    1957             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1958             :   // otherwise we won't be able to properly recreate it later, since
    1959             :   // we won't know what proto to use.  Note that we don't check
    1960             :   // aGivenProto here, since it's entirely possible (and even
    1961             :   // somewhat common) to have a non-null aGivenProto which is the
    1962             :   // same as canonicalProto.
    1963           0 :   if (proto != canonicalProto) {
    1964           0 :     PreserveWrapper(aObject);
    1965             :   }
    1966             : 
    1967           0 :   return true;
    1968             : }
    1969             : 
    1970             : // This may allocate too many slots, because we only really need
    1971             : // slots for our non-interface-typed members that we cache.  But
    1972             : // allocating slots only for those would make the slot index
    1973             : // computations much more complicated, so let's do this the simple
    1974             : // way for now.
    1975             : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
    1976             : 
    1977             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1978             :   nullptr,
    1979             :   nullptr,
    1980             :   nullptr,
    1981             :   { sNativeProperties.Upcast(), nullptr },
    1982             :   prototypes::id::KeyframeEffect,
    1983             :   constructors::id::KeyframeEffect,
    1984             :   KeyframeEffectReadOnlyBinding::sNativePropertyHooks,
    1985             :   &sXrayExpandoObjectClass
    1986             : } };
    1987             : 
    1988             : void
    1989           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1990             : {
    1991           0 :   JS::Handle<JSObject*> parentProto(KeyframeEffectReadOnlyBinding::GetProtoObjectHandle(aCx));
    1992           0 :   if (!parentProto) {
    1993           0 :     return;
    1994             :   }
    1995             : 
    1996           0 :   JS::Handle<JSObject*> constructorProto(KeyframeEffectReadOnlyBinding::GetConstructorObjectHandle(aCx));
    1997           0 :   if (!constructorProto) {
    1998           0 :     return;
    1999             :   }
    2000             : 
    2001             :   static bool sIdsInited = false;
    2002           0 :   if (!sIdsInited && NS_IsMainThread()) {
    2003           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2004           0 :       return;
    2005             :     }
    2006           0 :     sIdsInited = true;
    2007             :   }
    2008             : 
    2009           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::KeyframeEffect);
    2010           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::KeyframeEffect);
    2011           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2012             :                               &sPrototypeClass.mBase, protoCache,
    2013             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
    2014             :                               interfaceCache,
    2015             :                               sNativeProperties.Upcast(),
    2016             :                               nullptr,
    2017             :                               "KeyframeEffect", aDefineOnGlobal,
    2018             :                               nullptr,
    2019           0 :                               false);
    2020             : }
    2021             : 
    2022             : JS::Handle<JSObject*>
    2023           0 : GetProtoObjectHandle(JSContext* aCx)
    2024             : {
    2025             :   /* Get the interface prototype object for this class.  This will create the
    2026             :      object as needed. */
    2027           0 :   bool aDefineOnGlobal = true;
    2028             : 
    2029             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2030           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2031           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2032           0 :     return nullptr;
    2033             :   }
    2034             : 
    2035             :   /* Check to see whether the interface objects are already installed */
    2036           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2037           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::KeyframeEffect)) {
    2038           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2039           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2040             :   }
    2041             : 
    2042             :   /*
    2043             :    * The object might _still_ be null, but that's OK.
    2044             :    *
    2045             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2046             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2047             :    * changed after they have been set.
    2048             :    *
    2049             :    * Calling address() avoids the read read barrier that does gray
    2050             :    * unmarking, but it's not possible for the object to be gray here.
    2051             :    */
    2052             : 
    2053           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::KeyframeEffect);
    2054           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2055           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2056             : }
    2057             : 
    2058             : JS::Handle<JSObject*>
    2059           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2060             : {
    2061             :   /* Get the interface object for this class.  This will create the object as
    2062             :      needed. */
    2063             : 
    2064             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2065           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2066           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2067           0 :     return nullptr;
    2068             :   }
    2069             : 
    2070             :   /* Check to see whether the interface objects are already installed */
    2071           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2072           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::KeyframeEffect)) {
    2073           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2074           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2075             :   }
    2076             : 
    2077             :   /*
    2078             :    * The object might _still_ be null, but that's OK.
    2079             :    *
    2080             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2081             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2082             :    * changed after they have been set.
    2083             :    *
    2084             :    * Calling address() avoids the read read barrier that does gray
    2085             :    * unmarking, but it's not possible for the object to be gray here.
    2086             :    */
    2087             : 
    2088           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::KeyframeEffect);
    2089           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2090           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2091             : }
    2092             : 
    2093             : JSObject*
    2094           0 : GetConstructorObject(JSContext* aCx)
    2095             : {
    2096           0 :   return GetConstructorObjectHandle(aCx);
    2097             : }
    2098             : 
    2099             : } // namespace KeyframeEffectBinding
    2100             : 
    2101             : 
    2102             : 
    2103             : namespace KeyframeEffectReadOnlyBinding {
    2104             : 
    2105             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AnimationEffectReadOnlyBinding::NativeType>::value,
    2106             :               "Can't inherit from an interface with a different ownership model.");
    2107             : 
    2108             : static bool
    2109           0 : get_target(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffectReadOnly* self, JSJitGetterCallArgs args)
    2110             : {
    2111           0 :   Nullable<OwningElementOrCSSPseudoElement> result;
    2112           0 :   self->GetTarget(result);
    2113           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2114           0 :   if (result.IsNull()) {
    2115           0 :     args.rval().setNull();
    2116           0 :     return true;
    2117             :   }
    2118           0 :   if (!result.Value().ToJSVal(cx, obj, args.rval())) {
    2119           0 :     return false;
    2120             :   }
    2121           0 :   return true;
    2122             : }
    2123             : 
    2124             : static const JSJitInfo target_getterinfo = {
    2125             :   { (JSJitGetterOp)get_target },
    2126             :   { prototypes::id::KeyframeEffectReadOnly },
    2127             :   { PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth },
    2128             :   JSJitInfo::Getter,
    2129             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2130             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
    2131             :   false,  /* isInfallible. False in setters. */
    2132             :   false,  /* isMovable.  Not relevant for setters. */
    2133             :   false, /* isEliminatable.  Not relevant for setters. */
    2134             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2135             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2136             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2137             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2138             : };
    2139             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2140             : static_assert(0 < 2, "There is no slot for us");
    2141             : 
    2142             : static bool
    2143           0 : get_iterationComposite(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffectReadOnly* self, JSJitGetterCallArgs args)
    2144             : {
    2145           0 :   IterationCompositeOperation result(self->IterationComposite());
    2146           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2147           0 :   if (!ToJSValue(cx, result, args.rval())) {
    2148           0 :     return false;
    2149             :   }
    2150           0 :   return true;
    2151             : }
    2152             : 
    2153             : static const JSJitInfo iterationComposite_getterinfo = {
    2154             :   { (JSJitGetterOp)get_iterationComposite },
    2155             :   { prototypes::id::KeyframeEffectReadOnly },
    2156             :   { PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth },
    2157             :   JSJitInfo::Getter,
    2158             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2159             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    2160             :   false,  /* isInfallible. False in setters. */
    2161             :   false,  /* isMovable.  Not relevant for setters. */
    2162             :   false, /* isEliminatable.  Not relevant for setters. */
    2163             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2164             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2165             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2166             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2167             : };
    2168             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2169             : static_assert(0 < 2, "There is no slot for us");
    2170             : 
    2171             : static bool
    2172           0 : get_composite(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffectReadOnly* self, JSJitGetterCallArgs args)
    2173             : {
    2174           0 :   CompositeOperation result(self->Composite());
    2175           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2176           0 :   if (!ToJSValue(cx, result, args.rval())) {
    2177           0 :     return false;
    2178             :   }
    2179           0 :   return true;
    2180             : }
    2181             : 
    2182             : static const JSJitInfo composite_getterinfo = {
    2183             :   { (JSJitGetterOp)get_composite },
    2184             :   { prototypes::id::KeyframeEffectReadOnly },
    2185             :   { PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth },
    2186             :   JSJitInfo::Getter,
    2187             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2188             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
    2189             :   false,  /* isInfallible. False in setters. */
    2190             :   false,  /* isMovable.  Not relevant for setters. */
    2191             :   false, /* isEliminatable.  Not relevant for setters. */
    2192             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2193             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2194             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2195             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2196             : };
    2197             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2198             : static_assert(0 < 2, "There is no slot for us");
    2199             : 
    2200             : static bool
    2201           0 : getKeyframes(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffectReadOnly* self, const JSJitMethodCallArgs& args)
    2202             : {
    2203           0 :   binding_detail::FastErrorResult rv;
    2204           0 :   nsTArray<JSObject*> result;
    2205           0 :   SequenceRooter<JSObject* > resultRooter(cx, &result);
    2206           0 :   self->GetKeyframes(cx, result, rv);
    2207           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2208           0 :     return false;
    2209             :   }
    2210           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2211             : 
    2212           0 :   uint32_t length = result.Length();
    2213           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
    2214           0 :   if (!returnArray) {
    2215           0 :     return false;
    2216             :   }
    2217             :   // Scope for 'tmp'
    2218             :   {
    2219           0 :     JS::Rooted<JS::Value> tmp(cx);
    2220           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
    2221             :       // Control block to let us common up the JS_DefineElement calls when there
    2222             :       // are different ways to succeed at wrapping the object.
    2223             :       do {
    2224           0 :         JS::ExposeObjectToActiveJS(result[sequenceIdx0]);
    2225           0 :         tmp.setObject(*result[sequenceIdx0]);
    2226           0 :         if (!MaybeWrapObjectValue(cx, &tmp)) {
    2227           0 :           return false;
    2228             :         }
    2229           0 :         break;
    2230             :       } while (0);
    2231           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
    2232             :                             JSPROP_ENUMERATE)) {
    2233           0 :         return false;
    2234             :       }
    2235             :     }
    2236             :   }
    2237           0 :   args.rval().setObject(*returnArray);
    2238           0 :   return true;
    2239             : }
    2240             : 
    2241             : static const JSJitInfo getKeyframes_methodinfo = {
    2242             :   { (JSJitGetterOp)getKeyframes },
    2243             :   { prototypes::id::KeyframeEffectReadOnly },
    2244             :   { PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth },
    2245             :   JSJitInfo::Method,
    2246             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2247             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    2248             :   false,  /* isInfallible. False in setters. */
    2249             :   false,  /* isMovable.  Not relevant for setters. */
    2250             :   false, /* isEliminatable.  Not relevant for setters. */
    2251             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2252             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2253             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2254             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2255             : };
    2256             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2257             : static_assert(0 < 2, "There is no slot for us");
    2258             : 
    2259             : static bool
    2260           0 : getProperties(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::KeyframeEffectReadOnly* self, const JSJitMethodCallArgs& args)
    2261             : {
    2262           0 :   binding_detail::FastErrorResult rv;
    2263           0 :   nsTArray<AnimationPropertyDetails> result;
    2264           0 :   self->GetProperties(result, rv);
    2265           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2266           0 :     return false;
    2267             :   }
    2268           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2269             : 
    2270           0 :   uint32_t length = result.Length();
    2271           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
    2272           0 :   if (!returnArray) {
    2273           0 :     return false;
    2274             :   }
    2275             :   // Scope for 'tmp'
    2276             :   {
    2277           0 :     JS::Rooted<JS::Value> tmp(cx);
    2278           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
    2279             :       // Control block to let us common up the JS_DefineElement calls when there
    2280             :       // are different ways to succeed at wrapping the object.
    2281             :       do {
    2282           0 :         if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
    2283           0 :           return false;
    2284             :         }
    2285           0 :         break;
    2286             :       } while (0);
    2287           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
    2288             :                             JSPROP_ENUMERATE)) {
    2289           0 :         return false;
    2290             :       }
    2291             :     }
    2292             :   }
    2293           0 :   args.rval().setObject(*returnArray);
    2294           0 :   return true;
    2295             : }
    2296             : 
    2297             : static const JSJitInfo getProperties_methodinfo = {
    2298             :   { (JSJitGetterOp)getProperties },
    2299             :   { prototypes::id::KeyframeEffectReadOnly },
    2300             :   { PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth },
    2301             :   JSJitInfo::Method,
    2302             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
    2303             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
    2304             :   false,  /* isInfallible. False in setters. */
    2305             :   false,  /* isMovable.  Not relevant for setters. */
    2306             :   false, /* isEliminatable.  Not relevant for setters. */
    2307             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
    2308             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
    2309             :   false,  /* isTypedMethod.  Only relevant for methods. */
    2310             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
    2311             : };
    2312             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
    2313             : static_assert(0 < 2, "There is no slot for us");
    2314             : 
    2315             : static bool
    2316           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
    2317             : {
    2318           0 :   mozilla::dom::KeyframeEffectReadOnly* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyframeEffectReadOnly>(obj);
    2319             :   // We don't want to preserve if we don't have a wrapper, and we
    2320             :   // obviously can't preserve if we're not initialized.
    2321           0 :   if (self && self->GetWrapperPreserveColor()) {
    2322           0 :     PreserveWrapper(self);
    2323             :   }
    2324           0 :   return true;
    2325             : }
    2326             : 
    2327             : static void
    2328           0 : _finalize(js::FreeOp* fop, JSObject* obj)
    2329             : {
    2330           0 :   mozilla::dom::KeyframeEffectReadOnly* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyframeEffectReadOnly>(obj);
    2331           0 :   if (self) {
    2332           0 :     ClearWrapper(self, self, obj);
    2333           0 :     AddForDeferredFinalization<mozilla::dom::KeyframeEffectReadOnly>(self);
    2334             :   }
    2335           0 : }
    2336             : 
    2337             : static void
    2338           0 : _objectMoved(JSObject* obj, const JSObject* old)
    2339             : {
    2340           0 :   mozilla::dom::KeyframeEffectReadOnly* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::KeyframeEffectReadOnly>(obj);
    2341           0 :   if (self) {
    2342           0 :     UpdateWrapper(self, self, obj, old);
    2343             :   }
    2344           0 : }
    2345             : 
    2346             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2347             : #if defined(__clang__)
    2348             : #pragma clang diagnostic push
    2349             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2350             : #endif
    2351             : static const JSFunctionSpec sMethods_specs[] = {
    2352             :   JS_FNSPEC("getKeyframes", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getKeyframes_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    2353             :   JS_FS_END
    2354             : };
    2355             : #if defined(__clang__)
    2356             : #pragma clang diagnostic pop
    2357             : #endif
    2358             : 
    2359             : 
    2360             : // Can't be const because the pref-enabled boolean needs to be writable
    2361             : static Prefable<const JSFunctionSpec> sMethods[] = {
    2362             :   { nullptr, &sMethods_specs[0] },
    2363             :   { nullptr, nullptr }
    2364             : };
    2365             : 
    2366             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2367             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2368             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2369             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2370             : 
    2371             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2372             : #if defined(__clang__)
    2373             : #pragma clang diagnostic push
    2374             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2375             : #endif
    2376             : static const JSFunctionSpec sChromeMethods_specs[] = {
    2377             :   JS_FNSPEC("getProperties", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getProperties_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
    2378             :   JS_FS_END
    2379             : };
    2380             : #if defined(__clang__)
    2381             : #pragma clang diagnostic pop
    2382             : #endif
    2383             : 
    2384             : 
    2385             : // Can't be const because the pref-enabled boolean needs to be writable
    2386             : static Prefable<const JSFunctionSpec> sChromeMethods[] = {
    2387             :   { nullptr, &sChromeMethods_specs[0] },
    2388             :   { nullptr, nullptr }
    2389             : };
    2390             : 
    2391             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2392             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2393             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2394             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2395             : 
    2396             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
    2397             : #if defined(__clang__)
    2398             : #pragma clang diagnostic push
    2399             : #pragma clang diagnostic ignored "-Wmissing-braces"
    2400             : #endif
    2401             : static const JSPropertySpec sAttributes_specs[] = {
    2402             :   { "target", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &target_getterinfo, nullptr, nullptr },
    2403             :   { "iterationComposite", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &iterationComposite_getterinfo, nullptr, nullptr },
    2404             :   { "composite", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &composite_getterinfo, nullptr, nullptr },
    2405             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
    2406             : };
    2407             : #if defined(__clang__)
    2408             : #pragma clang diagnostic pop
    2409             : #endif
    2410             : 
    2411             : 
    2412             : // Can't be const because the pref-enabled boolean needs to be writable
    2413             : static Prefable<const JSPropertySpec> sAttributes[] = {
    2414             :   { nullptr, &sAttributes_specs[0] },
    2415             :   { nullptr, nullptr }
    2416             : };
    2417             : 
    2418             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
    2419             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
    2420             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
    2421             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
    2422             : 
    2423             : 
    2424             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
    2425             : static PropertyInfo sNativeProperties_propertyInfos[4];
    2426             : 
    2427             : static const NativePropertiesN<2> sNativeProperties = {
    2428             :   false, 0,
    2429             :   false, 0,
    2430             :   true,  0 /* sMethods */,
    2431             :   true,  1 /* sAttributes */,
    2432             :   false, 0,
    2433             :   false, 0,
    2434             :   false, 0,
    2435             :   -1,
    2436             :   4,
    2437             :   sNativeProperties_sortedPropertyIndices,
    2438             :   {
    2439             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    2440             :     { sAttributes, &sNativeProperties_propertyInfos[1] }
    2441             :   }
    2442             : };
    2443             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    2444             :     "We have a property info count that is oversized");
    2445             : 
    2446             : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
    2447             : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
    2448             : 
    2449             : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
    2450             :   false, 0,
    2451             :   false, 0,
    2452             :   true,  0 /* sChromeMethods */,
    2453             :   false, 0,
    2454             :   false, 0,
    2455             :   false, 0,
    2456             :   false, 0,
    2457             :   -1,
    2458             :   1,
    2459             :   sChromeOnlyNativeProperties_sortedPropertyIndices,
    2460             :   {
    2461             :     { sChromeMethods, &sChromeOnlyNativeProperties_propertyInfos[0] }
    2462             :   }
    2463             : };
    2464             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
    2465             :     "We have a property info count that is oversized");
    2466             : 
    2467             : static bool
    2468           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
    2469             : {
    2470           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
    2471           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
    2472           0 :   if (!args.isConstructing()) {
    2473             :     // XXXbz wish I could get the name from the callee instead of
    2474             :     // Adding more relocations
    2475           0 :     return ThrowConstructorWithoutNew(cx, "KeyframeEffectReadOnly");
    2476             :   }
    2477             : 
    2478           0 :   GlobalObject global(cx, obj);
    2479           0 :   if (global.Failed()) {
    2480           0 :     return false;
    2481             :   }
    2482             : 
    2483           0 :   JS::Rooted<JSObject*> desiredProto(cx);
    2484           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
    2485           0 :     return false;
    2486             :   }
    2487             : 
    2488           0 :   unsigned argcount = std::min(args.length(), 3u);
    2489           0 :   switch (argcount) {
    2490             :     case 1: {
    2491           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    2492           0 :       NonNull<mozilla::dom::KeyframeEffectReadOnly> arg0;
    2493           0 :       if (args[0].isObject()) {
    2494             :         {
    2495           0 :           nsresult rv = UnwrapObject<prototypes::id::KeyframeEffectReadOnly, mozilla::dom::KeyframeEffectReadOnly>(args[0], arg0);
    2496           0 :           if (NS_FAILED(rv)) {
    2497           0 :             ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of KeyframeEffectReadOnly.constructor", "KeyframeEffectReadOnly");
    2498           0 :             return false;
    2499             :           }
    2500             :         }
    2501             :       } else {
    2502           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of KeyframeEffectReadOnly.constructor");
    2503           0 :         return false;
    2504             :       }
    2505           0 :       Maybe<JSAutoCompartment> ac;
    2506           0 :       if (objIsXray) {
    2507           0 :         obj = js::CheckedUnwrap(obj);
    2508           0 :         if (!obj) {
    2509           0 :           return false;
    2510             :         }
    2511           0 :         ac.emplace(cx, obj);
    2512           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
    2513           0 :           return false;
    2514             :         }
    2515             :       }
    2516           0 :       binding_detail::FastErrorResult rv;
    2517           0 :       auto result(StrongOrRawPtr<mozilla::dom::KeyframeEffectReadOnly>(mozilla::dom::KeyframeEffectReadOnly::Constructor(global, NonNullHelper(arg0), rv)));
    2518           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2519           0 :         return false;
    2520             :       }
    2521           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2522             :       static_assert(!IsPointer<decltype(result)>::value,
    2523             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    2524           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    2525           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2526           0 :         return false;
    2527             :       }
    2528           0 :       return true;
    2529             :       break;
    2530             :     }
    2531             :     case 2: {
    2532             :       MOZ_FALLTHROUGH;
    2533             :     }
    2534             :     case 3: {
    2535           0 :       bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
    2536           0 :       Nullable<ElementOrCSSPseudoElement > arg0;
    2537           0 :       Maybe<ElementOrCSSPseudoElementArgument> arg0_holder;
    2538           0 :       if (args[0].isNullOrUndefined()) {
    2539           0 :         arg0.SetNull();
    2540             :       } else {
    2541           0 :         arg0_holder.emplace(arg0.SetValue());
    2542             :         {
    2543           0 :           bool done = false, failed = false, tryNext;
    2544           0 :           if (args[0].isObject()) {
    2545           0 :             done = (failed = !arg0_holder.ref().TrySetToElement(cx, args[0], tryNext, false)) || !tryNext ||
    2546           0 :                    (failed = !arg0_holder.ref().TrySetToCSSPseudoElement(cx, args[0], tryNext, false)) || !tryNext;
    2547             : 
    2548             :           }
    2549           0 :           if (failed) {
    2550           0 :             return false;
    2551             :           }
    2552           0 :           if (!done) {
    2553           0 :             ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 1 of KeyframeEffectReadOnly.constructor", "Element, CSSPseudoElement");
    2554           0 :             return false;
    2555             :           }
    2556             :         }
    2557             :       }
    2558           0 :       JS::Rooted<JSObject*> arg1(cx);
    2559           0 :       if (args[1].isObject()) {
    2560           0 :         arg1 = &args[1].toObject();
    2561           0 :       } else if (args[1].isNullOrUndefined()) {
    2562           0 :         arg1 = nullptr;
    2563             :       } else {
    2564           0 :         ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of KeyframeEffectReadOnly.constructor");
    2565           0 :         return false;
    2566             :       }
    2567           0 :       UnrestrictedDoubleOrKeyframeEffectOptions arg2;
    2568           0 :       UnrestrictedDoubleOrKeyframeEffectOptionsArgument arg2_holder(arg2);
    2569           0 :       if (!(args.hasDefined(2))) {
    2570           0 :         if (!arg2.RawSetAsKeyframeEffectOptions().Init(cx, JS::NullHandleValue, "Member of UnrestrictedDoubleOrKeyframeEffectOptions")) {
    2571           0 :           return false;
    2572             :         }
    2573             :       } else {
    2574             :         {
    2575           0 :           bool done = false, failed = false, tryNext;
    2576           0 :           if (!done) {
    2577           0 :             done = (failed = !arg2_holder.TrySetToKeyframeEffectOptions(cx, args[2], tryNext, false)) || !tryNext;
    2578             :           }
    2579           0 :           if (!done) {
    2580             :             do {
    2581           0 :               done = (failed = !arg2_holder.TrySetToUnrestrictedDouble(cx, args[2], tryNext)) || !tryNext;
    2582           0 :               break;
    2583             :             } while (0);
    2584             :           }
    2585           0 :           if (failed) {
    2586           0 :             return false;
    2587             :           }
    2588           0 :           if (!done) {
    2589           0 :             ThrowErrorMessage(cx, MSG_NOT_IN_UNION, "Argument 3 of KeyframeEffectReadOnly.constructor", "KeyframeEffectOptions");
    2590           0 :             return false;
    2591             :           }
    2592             :         }
    2593             :       }
    2594           0 :       Maybe<JSAutoCompartment> ac;
    2595           0 :       if (objIsXray) {
    2596           0 :         obj = js::CheckedUnwrap(obj);
    2597           0 :         if (!obj) {
    2598           0 :           return false;
    2599             :         }
    2600           0 :         ac.emplace(cx, obj);
    2601           0 :         if (!JS_WrapObject(cx, &desiredProto)) {
    2602           0 :           return false;
    2603             :         }
    2604           0 :         if (!JS_WrapObject(cx, &arg1)) {
    2605           0 :           return false;
    2606             :         }
    2607             :       }
    2608           0 :       binding_detail::FastErrorResult rv;
    2609           0 :       auto result(StrongOrRawPtr<mozilla::dom::KeyframeEffectReadOnly>(mozilla::dom::KeyframeEffectReadOnly::Constructor(global, Constify(arg0), arg1, Constify(arg2), rv)));
    2610           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
    2611           0 :         return false;
    2612             :       }
    2613           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
    2614             :       static_assert(!IsPointer<decltype(result)>::value,
    2615             :                     "NewObject implies that we need to keep the object alive with a strong reference.");
    2616           0 :       if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
    2617           0 :         MOZ_ASSERT(true || JS_IsExceptionPending(cx));
    2618           0 :         return false;
    2619             :       }
    2620           0 :       return true;
    2621             :       break;
    2622             :     }
    2623             :     default: {
    2624           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "KeyframeEffectReadOnly");
    2625             :       break;
    2626             :     }
    2627             :   }
    2628             :   MOZ_CRASH("We have an always-returning default case");
    2629             :   return false;
    2630             : }
    2631             : 
    2632             : static const js::ClassOps sInterfaceObjectClassOps = {
    2633             :     nullptr,               /* addProperty */
    2634             :     nullptr,               /* delProperty */
    2635             :     nullptr,               /* getProperty */
    2636             :     nullptr,               /* setProperty */
    2637             :     nullptr,               /* enumerate */
    2638             :     nullptr,               /* newEnumerate */
    2639             :     nullptr,               /* resolve */
    2640             :     nullptr,               /* mayResolve */
    2641             :     nullptr,               /* finalize */
    2642             :     _constructor, /* call */
    2643             :     nullptr,               /* hasInstance */
    2644             :     _constructor, /* construct */
    2645             :     nullptr,               /* trace */
    2646             : };
    2647             : 
    2648             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    2649             :   {
    2650             :     "Function",
    2651             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    2652             :     &sInterfaceObjectClassOps,
    2653             :     JS_NULL_CLASS_SPEC,
    2654             :     JS_NULL_CLASS_EXT,
    2655             :     &sInterfaceObjectClassObjectOps
    2656             :   },
    2657             :   eInterface,
    2658             :   true,
    2659             :   prototypes::id::KeyframeEffectReadOnly,
    2660             :   PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth,
    2661             :   sNativePropertyHooks,
    2662             :   "function KeyframeEffectReadOnly() {\n    [native code]\n}",
    2663             :   AnimationEffectReadOnlyBinding::GetConstructorObject
    2664             : };
    2665             : 
    2666             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    2667             :   {
    2668             :     "KeyframeEffectReadOnlyPrototype",
    2669             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    2670             :     JS_NULL_CLASS_OPS,
    2671             :     JS_NULL_CLASS_SPEC,
    2672             :     JS_NULL_CLASS_EXT,
    2673             :     JS_NULL_OBJECT_OPS
    2674             :   },
    2675             :   eInterfacePrototype,
    2676             :   false,
    2677             :   prototypes::id::KeyframeEffectReadOnly,
    2678             :   PrototypeTraits<prototypes::id::KeyframeEffectReadOnly>::Depth,
    2679             :   sNativePropertyHooks,
    2680             :   "[object KeyframeEffectReadOnlyPrototype]",
    2681             :   AnimationEffectReadOnlyBinding::GetProtoObject
    2682             : };
    2683             : 
    2684             : bool
    2685           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
    2686             : {
    2687           0 :   return nsDocument::IsWebAnimationsEnabled(aCx, aObj);
    2688             : }
    2689             : 
    2690             : JSObject*
    2691           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    2692             : {
    2693           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    2694             : }
    2695             : 
    2696             : static const js::ClassOps sClassOps = {
    2697             :   _addProperty, /* addProperty */
    2698             :   nullptr,               /* delProperty */
    2699             :   nullptr,               /* getProperty */
    2700             :   nullptr,               /* setProperty */
    2701             :   nullptr,               /* enumerate */
    2702             :   nullptr, /* newEnumerate */
    2703             :   nullptr, /* resolve */
    2704             :   nullptr, /* mayResolve */
    2705             :   _finalize, /* finalize */
    2706             :   nullptr, /* call */
    2707             :   nullptr,               /* hasInstance */
    2708             :   nullptr,               /* construct */
    2709             :   nullptr, /* trace */
    2710             : };
    2711             : 
    2712             : static const js::ClassExtension sClassExtension = {
    2713             :   nullptr, /* weakmapKeyDelegateOp */
    2714             :   _objectMoved /* objectMovedOp */
    2715             : };
    2716             : 
    2717             : static const DOMJSClass sClass = {
    2718             :   { "KeyframeEffectReadOnly",
    2719             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(2),
    2720             :     &sClassOps,
    2721             :     JS_NULL_CLASS_SPEC,
    2722             :     &sClassExtension,
    2723             :     JS_NULL_OBJECT_OPS
    2724             :   },
    2725             :   { prototypes::id::AnimationEffectReadOnly, prototypes::id::KeyframeEffectReadOnly, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
    2726             :   IsBaseOf<nsISupports, mozilla::dom::KeyframeEffectReadOnly >::value,
    2727             :   sNativePropertyHooks,
    2728             :   FindAssociatedGlobalForNative<mozilla::dom::KeyframeEffectReadOnly>::Get,
    2729             :   GetProtoObjectHandle,
    2730             :   GetCCParticipant<mozilla::dom::KeyframeEffectReadOnly>::Get()
    2731             : };
    2732             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    2733             :               "Must have the right minimal number of reserved slots.");
    2734             : static_assert(2 >= 2,
    2735             :               "Must have enough reserved slots.");
    2736             : 
    2737             : const JSClass*
    2738           0 : GetJSClass()
    2739             : {
    2740           0 :   return sClass.ToJSClass();
    2741             : }
    2742             : 
    2743             : bool
    2744           0 : Wrap(JSContext* aCx, mozilla::dom::KeyframeEffectReadOnly* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    2745             : {
    2746             :   MOZ_ASSERT(static_cast<mozilla::dom::KeyframeEffectReadOnly*>(aObject) ==
    2747             :              reinterpret_cast<mozilla::dom::KeyframeEffectReadOnly*>(aObject),
    2748             :              "Multiple inheritance for mozilla::dom::KeyframeEffectReadOnly is broken.");
    2749             :   MOZ_ASSERT(static_cast<mozilla::dom::AnimationEffectReadOnly*>(aObject) ==
    2750             :              reinterpret_cast<mozilla::dom::AnimationEffectReadOnly*>(aObject),
    2751             :              "Multiple inheritance for mozilla::dom::AnimationEffectReadOnly is broken.");
    2752           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    2753           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    2754           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    2755             :              "You should probably not be using Wrap() directly; use "
    2756             :              "GetOrCreateDOMReflector instead");
    2757             : 
    2758           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    2759             :              "nsISupports must be on our primary inheritance chain");
    2760             : 
    2761           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    2762           0 :   if (!global) {
    2763           0 :     return false;
    2764             :   }
    2765           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    2766           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    2767             : 
    2768             :   // That might have ended up wrapping us already, due to the wonders
    2769             :   // of XBL.  Check for that, and bail out as needed.
    2770           0 :   aReflector.set(aCache->GetWrapper());
    2771           0 :   if (aReflector) {
    2772             : #ifdef DEBUG
    2773           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    2774             : #endif // DEBUG
    2775           0 :     return true;
    2776             :   }
    2777             : 
    2778           0 :   JSAutoCompartment ac(aCx, global);
    2779           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    2780           0 :   if (!canonicalProto) {
    2781           0 :     return false;
    2782             :   }
    2783           0 :   JS::Rooted<JSObject*> proto(aCx);
    2784           0 :   if (aGivenProto) {
    2785           0 :     proto = aGivenProto;
    2786             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    2787             :     // coming in, we changed compartments to that of "parent" so may need
    2788             :     // to wrap the proto here.
    2789           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    2790           0 :       if (!JS_WrapObject(aCx, &proto)) {
    2791           0 :         return false;
    2792             :       }
    2793             :     }
    2794             :   } else {
    2795           0 :     proto = canonicalProto;
    2796             :   }
    2797             : 
    2798           0 :   BindingJSObjectCreator<mozilla::dom::KeyframeEffectReadOnly> creator(aCx);
    2799           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    2800           0 :   if (!aReflector) {
    2801           0 :     return false;
    2802             :   }
    2803             : 
    2804           0 :   aCache->SetWrapper(aReflector);
    2805           0 :   creator.InitializationSucceeded();
    2806             : 
    2807           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    2808             :              aCache->GetWrapperPreserveColor() == aReflector);
    2809             :   // If proto != canonicalProto, we have to preserve our wrapper;
    2810             :   // otherwise we won't be able to properly recreate it later, since
    2811             :   // we won't know what proto to use.  Note that we don't check
    2812             :   // aGivenProto here, since it's entirely possible (and even
    2813             :   // somewhat common) to have a non-null aGivenProto which is the
    2814             :   // same as canonicalProto.
    2815           0 :   if (proto != canonicalProto) {
    2816           0 :     PreserveWrapper(aObject);
    2817             :   }
    2818             : 
    2819           0 :   return true;
    2820             : }
    2821             : 
    2822             : // This may allocate too many slots, because we only really need
    2823             : // slots for our non-interface-typed members that we cache.  But
    2824             : // allocating slots only for those would make the slot index
    2825             : // computations much more complicated, so let's do this the simple
    2826             : // way for now.
    2827             : DEFINE_XRAY_EXPANDO_CLASS(static, sXrayExpandoObjectClass, 1);
    2828             : 
    2829             : const NativePropertyHooks sNativePropertyHooks[] = { {
    2830             :   nullptr,
    2831             :   nullptr,
    2832             :   nullptr,
    2833             :   { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
    2834             :   prototypes::id::KeyframeEffectReadOnly,
    2835             :   constructors::id::KeyframeEffectReadOnly,
    2836             :   AnimationEffectReadOnlyBinding::sNativePropertyHooks,
    2837             :   &sXrayExpandoObjectClass
    2838             : } };
    2839             : 
    2840             : void
    2841           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    2842             : {
    2843           0 :   JS::Handle<JSObject*> parentProto(AnimationEffectReadOnlyBinding::GetProtoObjectHandle(aCx));
    2844           0 :   if (!parentProto) {
    2845           0 :     return;
    2846             :   }
    2847             : 
    2848           0 :   JS::Handle<JSObject*> constructorProto(AnimationEffectReadOnlyBinding::GetConstructorObjectHandle(aCx));
    2849           0 :   if (!constructorProto) {
    2850           0 :     return;
    2851             :   }
    2852             : 
    2853             :   static bool sIdsInited = false;
    2854           0 :   if (!sIdsInited && NS_IsMainThread()) {
    2855           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    2856           0 :       return;
    2857             :     }
    2858           0 :     if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
    2859           0 :       return;
    2860             :     }
    2861           0 :     sIdsInited = true;
    2862             :   }
    2863             : 
    2864           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::KeyframeEffectReadOnly);
    2865           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::KeyframeEffectReadOnly);
    2866           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    2867             :                               &sPrototypeClass.mBase, protoCache,
    2868             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
    2869             :                               interfaceCache,
    2870             :                               sNativeProperties.Upcast(),
    2871           0 :                               nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
    2872             :                               "KeyframeEffectReadOnly", aDefineOnGlobal,
    2873             :                               nullptr,
    2874           0 :                               false);
    2875             : }
    2876             : 
    2877             : JS::Handle<JSObject*>
    2878           0 : GetProtoObjectHandle(JSContext* aCx)
    2879             : {
    2880             :   /* Get the interface prototype object for this class.  This will create the
    2881             :      object as needed. */
    2882           0 :   bool aDefineOnGlobal = true;
    2883             : 
    2884             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2885           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2886           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2887           0 :     return nullptr;
    2888             :   }
    2889             : 
    2890             :   /* Check to see whether the interface objects are already installed */
    2891           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2892           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::KeyframeEffectReadOnly)) {
    2893           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2894           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2895             :   }
    2896             : 
    2897             :   /*
    2898             :    * The object might _still_ be null, but that's OK.
    2899             :    *
    2900             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2901             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2902             :    * changed after they have been set.
    2903             :    *
    2904             :    * Calling address() avoids the read read barrier that does gray
    2905             :    * unmarking, but it's not possible for the object to be gray here.
    2906             :    */
    2907             : 
    2908           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::KeyframeEffectReadOnly);
    2909           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2910           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2911             : }
    2912             : 
    2913             : JSObject*
    2914           0 : GetProtoObject(JSContext* aCx)
    2915             : {
    2916           0 :   return GetProtoObjectHandle(aCx);
    2917             : }
    2918             : 
    2919             : JS::Handle<JSObject*>
    2920           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    2921             : {
    2922             :   /* Get the interface object for this class.  This will create the object as
    2923             :      needed. */
    2924             : 
    2925             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    2926           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    2927           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    2928           0 :     return nullptr;
    2929             :   }
    2930             : 
    2931             :   /* Check to see whether the interface objects are already installed */
    2932           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    2933           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::KeyframeEffectReadOnly)) {
    2934           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    2935           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    2936             :   }
    2937             : 
    2938             :   /*
    2939             :    * The object might _still_ be null, but that's OK.
    2940             :    *
    2941             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    2942             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    2943             :    * changed after they have been set.
    2944             :    *
    2945             :    * Calling address() avoids the read read barrier that does gray
    2946             :    * unmarking, but it's not possible for the object to be gray here.
    2947             :    */
    2948             : 
    2949           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::KeyframeEffectReadOnly);
    2950           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    2951           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    2952             : }
    2953             : 
    2954             : JSObject*
    2955           0 : GetConstructorObject(JSContext* aCx)
    2956             : {
    2957           0 :   return GetConstructorObjectHandle(aCx);
    2958             : }
    2959             : 
    2960             : } // namespace KeyframeEffectReadOnlyBinding
    2961             : 
    2962             : 
    2963             : 
    2964             : } // namespace dom
    2965             : } // namespace mozilla

Generated by: LCOV version 1.13