Generated file

Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM AnimationEffect.webidl BY Codegen.py - DO NOT EDIT */
#include <type_traits>
#include "AnimationEffectBinding.h"
#include "AtomList.h"
#include "MainThreadUtils.h"
#include "WrapperFactory.h"
#include "js/CallAndConstruct.h"
#include "js/Exception.h"
#include "js/MapAndSet.h"
#include "js/Object.h"
#include "js/PropertyAndElement.h"
#include "js/PropertyDescriptor.h"
#include "js/experimental/JitInfo.h"
#include "jsapi.h"
#include "mozilla/Atomics.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/OwningNonNull.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/AnimationEffect.h"
#include "mozilla/dom/BindingCallContext.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/CSSNumericValue.h"
#include "mozilla/dom/DOMJSClass.h"
#include "mozilla/dom/NonRefcountedDOMObject.h"
#include "mozilla/dom/PrimitiveConversions.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/XrayExpandoClass.h"
namespace mozilla {
namespace dom {
namespace binding_detail {}; // Just to make sure it's known as a namespace
using namespace mozilla::dom::binding_detail;
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<FillMode>::Values[5];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, FillMode aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<FillMode>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<FillMode>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<FillMode>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
namespace binding_detail {
constexpr nsLiteralCString EnumStrings<PlaybackDirection>::Values[4];
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, PlaybackDirection aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < std::size(binding_detail::EnumStrings<PlaybackDirection>::Values));
JSString* resultStr =
JS_NewStringCopyN(aCx, binding_detail::EnumStrings<PlaybackDirection>::Values[uint32_t(aArgument)].BeginReading(),
binding_detail::EnumStrings<PlaybackDirection>::Values[uint32_t(aArgument)].Length());
if (!resultStr) {
return false;
}
aValue.setString(resultStr);
return true;
}
void
ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, OwningUnrestrictedDoubleOrCSSNumericValueOrString& aUnion, const char* aName, uint32_t aFlags)
{
if (aUnion.IsCSSNumericValue()) {
ImplCycleCollectionTraverse(aCallback, aUnion.GetAsCSSNumericValue(), "mCSSNumericValue", aFlags);
}
}
void
ImplCycleCollectionUnlink(OwningUnrestrictedDoubleOrCSSNumericValueOrString& aUnion)
{
aUnion.Uninit();
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::TrySetToUnrestrictedDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
double& memberSlot = RawSetAsUnrestrictedDouble();
if (!ValueToPrimitive<double, eDefault>(cx, value, "Unrestricted double branch of (unrestricted double or CSSNumericValue or DOMString)", &memberSlot)) {
return false;
}
}
return true;
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::TrySetToCSSNumericValue(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
NonNull<mozilla::dom::CSSNumericValue>& memberSlot = RawSetAsCSSNumericValue();
{
// Our JSContext should be in the right global to do unwrapping in.
nsresult rv = UnwrapObject<prototypes::id::CSSNumericValue, mozilla::dom::CSSNumericValue>(value, memberSlot, cx);
if (NS_FAILED(rv)) {
DestroyCSSNumericValue();
tryNext = true;
return true;
}
}
}
return true;
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::TrySetToCSSNumericValue(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return TrySetToCSSNumericValue(cx, value, tryNext, passedToJSImpl);
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
nsAutoString& memberSlot = RawSetAsString();
if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
return false;
}
}
return true;
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
MOZ_ASSERT(mType == eUninitialized);
bool done = false, failed = false, tryNext;
if (value.isObject()) {
done = (failed = !TrySetToCSSNumericValue(cx, value, tryNext, passedToJSImpl)) || !tryNext;
}
if (!done) {
do {
if (value.isNumber()) {
done = (failed = !TrySetToUnrestrictedDouble(cx, value, tryNext)) || !tryNext;
break;
}
done = (failed = !TrySetToString(cx, value, tryNext)) || !tryNext;
break;
} while (false);
}
if (failed) {
return false;
}
if (!done) {
cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "CSSNumericValue");
return false;
}
return true;
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return Init(cx, value, sourceDescription, passedToJSImpl);
}
bool
UnrestrictedDoubleOrCSSNumericValueOrString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
{
switch (mType) {
case eUninitialized: {
return false;
}
case eUnrestrictedDouble: {
rval.set(JS::NumberValue(double(mValue.mUnrestrictedDouble.Value())));
return true;
}
case eCSSNumericValue: {
if (!GetOrCreateDOMReflector(cx, mValue.mCSSNumericValue.Value(), rval)) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
return true;
}
case eString: {
if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
return false;
}
return true;
}
default: {
return false;
}
}
}
OwningUnrestrictedDoubleOrCSSNumericValueOrString::OwningUnrestrictedDoubleOrCSSNumericValueOrString(OwningUnrestrictedDoubleOrCSSNumericValueOrString&& aOther)
: mType(eUninitialized)
{
switch (aOther.mType) {
case eUninitialized: {
MOZ_ASSERT(mType == eUninitialized,
"We need to destroy ourselves?");
break;
}
case eUnrestrictedDouble: {
mType = eUnrestrictedDouble;
mValue.mUnrestrictedDouble.SetValue(std::move(aOther.mValue.mUnrestrictedDouble.Value()));
break;
}
case eCSSNumericValue: {
mType = eCSSNumericValue;
mValue.mCSSNumericValue.SetValue(std::move(aOther.mValue.mCSSNumericValue.Value()));
break;
}
case eString: {
mType = eString;
mValue.mString.SetValue(std::move(aOther.mValue.mString.Value()));
break;
}
}
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::TrySetToUnrestrictedDouble(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
double& memberSlot = RawSetAsUnrestrictedDouble();
if (!ValueToPrimitive<double, eDefault>(cx, value, "Unrestricted double branch of (unrestricted double or CSSNumericValue or DOMString)", &memberSlot)) {
return false;
}
}
return true;
}
[[nodiscard]] double&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::RawSetAsUnrestrictedDouble()
{
if (mType == eUnrestrictedDouble) {
return mValue.mUnrestrictedDouble.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eUnrestrictedDouble;
return mValue.mUnrestrictedDouble.SetValue();
}
[[nodiscard]] double&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::SetAsUnrestrictedDouble()
{
if (mType == eUnrestrictedDouble) {
return mValue.mUnrestrictedDouble.Value();
}
Uninit();
mType = eUnrestrictedDouble;
return mValue.mUnrestrictedDouble.SetValue();
}
void
OwningUnrestrictedDoubleOrCSSNumericValueOrString::DestroyUnrestrictedDouble()
{
MOZ_RELEASE_ASSERT(IsUnrestrictedDouble(), "Wrong type!");
mValue.mUnrestrictedDouble.Destroy();
mType = eUninitialized;
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::TrySetToCSSNumericValue(BindingCallContext& cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
OwningNonNull<mozilla::dom::CSSNumericValue>& memberSlot = RawSetAsCSSNumericValue();
static_assert(IsRefcounted<mozilla::dom::CSSNumericValue>::value, "We can only store refcounted classes.");
{
// Our JSContext should be in the right global to do unwrapping in.
nsresult rv = UnwrapObject<prototypes::id::CSSNumericValue, mozilla::dom::CSSNumericValue>(value, memberSlot, cx);
if (NS_FAILED(rv)) {
DestroyCSSNumericValue();
tryNext = true;
return true;
}
}
}
return true;
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::TrySetToCSSNumericValue(JSContext* cx_, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return TrySetToCSSNumericValue(cx, value, tryNext, passedToJSImpl);
}
[[nodiscard]] OwningNonNull<mozilla::dom::CSSNumericValue>&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::RawSetAsCSSNumericValue()
{
if (mType == eCSSNumericValue) {
return mValue.mCSSNumericValue.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eCSSNumericValue;
return mValue.mCSSNumericValue.SetValue();
}
[[nodiscard]] OwningNonNull<mozilla::dom::CSSNumericValue>&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::SetAsCSSNumericValue()
{
if (mType == eCSSNumericValue) {
return mValue.mCSSNumericValue.Value();
}
Uninit();
mType = eCSSNumericValue;
return mValue.mCSSNumericValue.SetValue();
}
void
OwningUnrestrictedDoubleOrCSSNumericValueOrString::DestroyCSSNumericValue()
{
MOZ_RELEASE_ASSERT(IsCSSNumericValue(), "Wrong type!");
mValue.mCSSNumericValue.Destroy();
mType = eUninitialized;
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::TrySetToString(JSContext* cx, JS::Handle<JS::Value> value, bool& tryNext, bool passedToJSImpl)
{
tryNext = false;
{ // scope for memberSlot
nsString& memberSlot = RawSetAsString();
if (!ConvertJSValueToString(cx, value, eStringify, eStringify, memberSlot)) {
return false;
}
}
return true;
}
[[nodiscard]] nsString&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::RawSetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
MOZ_ASSERT(mType == eUninitialized);
mType = eString;
return mValue.mString.SetValue();
}
[[nodiscard]] nsString&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::SetAsString()
{
if (mType == eString) {
return mValue.mString.Value();
}
Uninit();
mType = eString;
return mValue.mString.SetValue();
}
void
OwningUnrestrictedDoubleOrCSSNumericValueOrString::DestroyString()
{
MOZ_RELEASE_ASSERT(IsString(), "Wrong type!");
mValue.mString.Destroy();
mType = eUninitialized;
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::Init(BindingCallContext& cx, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
MOZ_ASSERT(mType == eUninitialized);
bool done = false, failed = false, tryNext;
if (value.isObject()) {
done = (failed = !TrySetToCSSNumericValue(cx, value, tryNext, passedToJSImpl)) || !tryNext;
}
if (!done) {
do {
if (value.isNumber()) {
done = (failed = !TrySetToUnrestrictedDouble(cx, value, tryNext)) || !tryNext;
break;
}
done = (failed = !TrySetToString(cx, value, tryNext)) || !tryNext;
break;
} while (false);
}
if (failed) {
return false;
}
if (!done) {
cx.ThrowErrorMessage<MSG_NOT_IN_UNION>(sourceDescription, "CSSNumericValue");
return false;
}
return true;
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::Init(JSContext* cx_, JS::Handle<JS::Value> value, const char* sourceDescription, bool passedToJSImpl)
{
BindingCallContext cx(cx_, nullptr);
return Init(cx, value, sourceDescription, passedToJSImpl);
}
void
OwningUnrestrictedDoubleOrCSSNumericValueOrString::Uninit()
{
switch (mType) {
case eUninitialized: {
break;
}
case eUnrestrictedDouble: {
DestroyUnrestrictedDouble();
break;
}
case eCSSNumericValue: {
DestroyCSSNumericValue();
break;
}
case eString: {
DestroyString();
break;
}
}
}
bool
OwningUnrestrictedDoubleOrCSSNumericValueOrString::ToJSVal(JSContext* cx, JS::Handle<JSObject*> scopeObj, JS::MutableHandle<JS::Value> rval) const
{
switch (mType) {
case eUninitialized: {
return false;
}
case eUnrestrictedDouble: {
rval.set(JS::NumberValue(double(mValue.mUnrestrictedDouble.Value())));
return true;
}
case eCSSNumericValue: {
if (!GetOrCreateDOMReflector(cx, mValue.mCSSNumericValue.Value(), rval)) {
MOZ_ASSERT(JS_IsExceptionPending(cx));
return false;
}
return true;
}
case eString: {
if (!xpc::NonVoidStringToJsval(cx, mValue.mString.Value(), rval)) {
return false;
}
return true;
}
default: {
return false;
}
}
}
OwningUnrestrictedDoubleOrCSSNumericValueOrString&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::operator=(OwningUnrestrictedDoubleOrCSSNumericValueOrString&& aOther)
{
this->~OwningUnrestrictedDoubleOrCSSNumericValueOrString();
new (this) OwningUnrestrictedDoubleOrCSSNumericValueOrString (std::move(aOther));
return *this;
}
OwningUnrestrictedDoubleOrCSSNumericValueOrString&
OwningUnrestrictedDoubleOrCSSNumericValueOrString::operator=(const OwningUnrestrictedDoubleOrCSSNumericValueOrString& aOther)
{
switch (aOther.mType) {
case eUninitialized: {
MOZ_ASSERT(mType == eUninitialized,
"We need to destroy ourselves?");
break;
}
case eUnrestrictedDouble: {
SetAsUnrestrictedDouble() = aOther.GetAsUnrestrictedDouble();
break;
}
case eCSSNumericValue: {
SetAsCSSNumericValue() = aOther.GetAsCSSNumericValue();
break;
}
case eString: {
SetAsString() = aOther.GetAsString();
break;
}
}
return *this;
}
EffectTiming::EffectTiming()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
EffectTiming::InitIds(JSContext* cx, EffectTimingAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->iterations_id.init(cx, "iterations") ||
!atomsCache->iterationStart_id.init(cx, "iterationStart") ||
!atomsCache->fill_id.init(cx, "fill") ||
!atomsCache->endDelay_id.init(cx, "endDelay") ||
!atomsCache->easing_id.init(cx, "easing") ||
!atomsCache->duration_id.init(cx, "duration") ||
!atomsCache->direction_id.init(cx, "direction") ||
!atomsCache->delay_id.init(cx, "delay")) {
return false;
}
return true;
}
bool
EffectTiming::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
EffectTimingAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<EffectTimingAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->delay_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'delay' member of EffectTiming", &mDelay)) {
return false;
} else if (!std::isfinite(mDelay)) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'delay' member of EffectTiming");
return false;
}
} else {
mDelay = 0.0;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->direction_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, temp.ref(),
binding_detail::EnumStrings<PlaybackDirection>::Values,
"PlaybackDirection", "'direction' member of EffectTiming",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
mDirection = static_cast<PlaybackDirection>(index);
}
} else {
mDirection = PlaybackDirection::Normal;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->duration_id, temp.ptr())) {
return false;
}
}
mDuration.Uninit();
if (!(!isNull && !temp->isUndefined())) {
mDuration.SetStringLiteral(u"auto");
} else {
if (!mDuration.Init(cx, temp.ref(), "'duration' member of EffectTiming", passedToJSImpl)) {
return false;
}
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->easing_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mEasing)) {
return false;
}
} else {
mEasing.AssignLiteral("linear");
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->endDelay_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'endDelay' member of EffectTiming", &mEndDelay)) {
return false;
} else if (!std::isfinite(mEndDelay)) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'endDelay' member of EffectTiming");
return false;
}
} else {
mEndDelay = 0.0;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->fill_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, temp.ref(),
binding_detail::EnumStrings<FillMode>::Values,
"FillMode", "'fill' member of EffectTiming",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
mFill = static_cast<FillMode>(index);
}
} else {
mFill = FillMode::Auto;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->iterationStart_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'iterationStart' member of EffectTiming", &mIterationStart)) {
return false;
} else if (!std::isfinite(mIterationStart)) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'iterationStart' member of EffectTiming");
return false;
}
} else {
mIterationStart = 0.0;
}
mIsAnyMemberPresent = true;
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->iterations_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'iterations' member of EffectTiming", &mIterations)) {
return false;
}
} else {
mIterations = 1.0;
}
mIsAnyMemberPresent = true;
return true;
}
bool
EffectTiming::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
bool
EffectTiming::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
EffectTimingAtoms* atomsCache = GetAtomCache<EffectTimingAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
if (!obj) {
return false;
}
rval.setObject(*obj);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mDelay;
temp.set(JS::NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->delay_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
PlaybackDirection const & currentValue = mDirection;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->direction_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
OwningUnrestrictedDoubleOrCSSNumericValueOrString const & currentValue = mDuration;
if (!currentValue.ToJSVal(cx, obj, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->duration_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
nsCString const & currentValue = mEasing;
if (!NonVoidUTF8StringToJsval(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->easing_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mEndDelay;
temp.set(JS::NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->endDelay_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
FillMode const & currentValue = mFill;
if (!ToJSValue(cx, currentValue, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->fill_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mIterationStart;
temp.set(JS::NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->iterationStart_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mIterations;
temp.set(JS::NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->iterations_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
return true;
}
void
EffectTiming::TraceDictionary(JSTracer* trc)
{
}
EffectTiming&
EffectTiming::operator=(const EffectTiming& aOther)
{
MaybeEmptyDictionaryBase::operator=(aOther);
mDelay = aOther.mDelay;
mDirection = aOther.mDirection;
mDuration = aOther.mDuration;
mEasing = aOther.mEasing;
mEndDelay = aOther.mEndDelay;
mFill = aOther.mFill;
mIterationStart = aOther.mIterationStart;
mIterations = aOther.mIterations;
return *this;
}
OptionalEffectTiming::OptionalEffectTiming()
{
// Safe to pass a null context if we pass a null value
Init(nullptr, JS::NullHandleValue);
}
bool
OptionalEffectTiming::InitIds(JSContext* cx, OptionalEffectTimingAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->iterations_id.init(cx, "iterations") ||
!atomsCache->iterationStart_id.init(cx, "iterationStart") ||
!atomsCache->fill_id.init(cx, "fill") ||
!atomsCache->endDelay_id.init(cx, "endDelay") ||
!atomsCache->easing_id.init(cx, "easing") ||
!atomsCache->duration_id.init(cx, "duration") ||
!atomsCache->direction_id.init(cx, "direction") ||
!atomsCache->delay_id.init(cx, "delay")) {
return false;
}
return true;
}
bool
OptionalEffectTiming::Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// Passing a null JSContext is OK only if we're initing from null,
// Since in that case we will not have to do any property gets
// Also evaluate isNullOrUndefined in order to avoid false-positive
// checkers by static analysis tools
MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
OptionalEffectTimingAtoms* atomsCache = nullptr;
if (cx) {
atomsCache = GetAtomCache<OptionalEffectTimingAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
}
if (!IsConvertibleToDictionary(val)) {
return cx.ThrowErrorMessage<MSG_CONVERSION_ERROR>(sourceDescription, "dictionary");
}
bool isNull = val.isNullOrUndefined();
// We only need these if !isNull, in which case we have |cx|.
Maybe<JS::Rooted<JSObject *> > object;
Maybe<JS::Rooted<JS::Value> > temp;
if (!isNull) {
MOZ_ASSERT(cx);
object.emplace(cx, &val.toObject());
temp.emplace(cx);
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->delay_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mDelay.Construct();
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'delay' member of OptionalEffectTiming", &(mDelay.Value()))) {
return false;
} else if (!std::isfinite((mDelay.Value()))) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'delay' member of OptionalEffectTiming");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->direction_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mDirection.Construct();
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, temp.ref(),
binding_detail::EnumStrings<PlaybackDirection>::Values,
"PlaybackDirection", "'direction' member of OptionalEffectTiming",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
(mDirection.Value()) = static_cast<PlaybackDirection>(index);
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->duration_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mDuration.Construct();
if (!(mDuration.Value()).Init(cx, temp.ref(), "'duration' member of OptionalEffectTiming", passedToJSImpl)) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->easing_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mEasing.Construct();
if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mEasing.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->endDelay_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mEndDelay.Construct();
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'endDelay' member of OptionalEffectTiming", &(mEndDelay.Value()))) {
return false;
} else if (!std::isfinite((mEndDelay.Value()))) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'endDelay' member of OptionalEffectTiming");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->fill_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mFill.Construct();
{
int index;
if (!binding_detail::FindEnumStringIndex<true>(cx, temp.ref(),
binding_detail::EnumStrings<FillMode>::Values,
"FillMode", "'fill' member of OptionalEffectTiming",
&index)) {
return false;
}
MOZ_ASSERT(index >= 0);
(mFill.Value()) = static_cast<FillMode>(index);
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->iterationStart_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mIterationStart.Construct();
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'iterationStart' member of OptionalEffectTiming", &(mIterationStart.Value()))) {
return false;
} else if (!std::isfinite((mIterationStart.Value()))) {
cx.ThrowErrorMessage<MSG_NOT_FINITE>("'iterationStart' member of OptionalEffectTiming");
return false;
}
mIsAnyMemberPresent = true;
}
if (!isNull) {
if (!JS_GetPropertyById(cx, *object, atomsCache->iterations_id, temp.ptr())) {
return false;
}
}
if (!isNull && !temp->isUndefined()) {
mIterations.Construct();
if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), "'iterations' member of OptionalEffectTiming", &(mIterations.Value()))) {
return false;
}
mIsAnyMemberPresent = true;
}
return true;
}
bool
OptionalEffectTiming::Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
{
// We don't want to use sourceDescription for our context here;
// that's not really what it's formatted for.
BindingCallContext cx(cx_, nullptr);
return Init(cx, val, sourceDescription, passedToJSImpl);
}
void
OptionalEffectTiming::TraceDictionary(JSTracer* trc)
{
}
OptionalEffectTiming&
OptionalEffectTiming::operator=(const OptionalEffectTiming& aOther)
{
MaybeEmptyDictionaryBase::operator=(aOther);
mDelay.Reset();
if (aOther.mDelay.WasPassed()) {
mDelay.Construct(aOther.mDelay.Value());
}
mDirection.Reset();
if (aOther.mDirection.WasPassed()) {
mDirection.Construct(aOther.mDirection.Value());
}
mDuration.Reset();
if (aOther.mDuration.WasPassed()) {
mDuration.Construct(aOther.mDuration.Value());
}
mEasing.Reset();
if (aOther.mEasing.WasPassed()) {
mEasing.Construct(aOther.mEasing.Value());
}
mEndDelay.Reset();
if (aOther.mEndDelay.WasPassed()) {
mEndDelay.Construct(aOther.mEndDelay.Value());
}
mFill.Reset();
if (aOther.mFill.WasPassed()) {
mFill.Construct(aOther.mFill.Value());
}
mIterationStart.Reset();
if (aOther.mIterationStart.WasPassed()) {
mIterationStart.Construct(aOther.mIterationStart.Value());
}
mIterations.Reset();
if (aOther.mIterations.WasPassed()) {
mIterations.Construct(aOther.mIterations.Value());
}
return *this;
}
ComputedEffectTiming::ComputedEffectTiming()
: EffectTiming(FastDictionaryInitializer())
{
// Safe to pass a null context if we pass a null value
Init();
}
bool
ComputedEffectTiming::InitIds(JSContext* cx, ComputedEffectTimingAtoms* atomsCache)
{
MOZ_ASSERT(reinterpret_cast<jsid*>(atomsCache)->isVoid());
// Initialize these in reverse order so that any failure leaves the first one
// uninitialized.
if (!atomsCache->startTime_id.init(cx, "startTime") ||
!atomsCache->progress_id.init(cx, "progress") ||
!atomsCache->localTime_id.init(cx, "localTime") ||
!atomsCache->endTime_id.init(cx, "endTime") ||
!atomsCache->currentIteration_id.init(cx, "currentIteration") ||
!atomsCache->activeDuration_id.init(cx, "activeDuration")) {
return false;
}
return true;
}
bool
ComputedEffectTiming::Init(const char* sourceDescription, bool passedToJSImpl)
{
// We init the parent's members first
if (!EffectTiming::Init(nullptr, JS::NullHandleValue)) {
return false;
}
mCurrentIteration.SetNull();
mProgress.SetNull();
return true;
}
bool
ComputedEffectTiming::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
{
ComputedEffectTimingAtoms* atomsCache = GetAtomCache<ComputedEffectTimingAtoms>(cx);
if (reinterpret_cast<jsid*>(atomsCache)->isVoid() &&
!InitIds(cx, atomsCache)) {
return false;
}
// Per spec, we define the parent's members first
if (!EffectTiming::ToObjectInternal(cx, rval)) {
return false;
}
JS::Rooted<JSObject*> obj(cx, &rval.toObject());
if (mActiveDuration.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
OwningDoubleOrCSSNumericValue const & currentValue = mActiveDuration.InternalValue();
if (!currentValue.ToJSVal(cx, obj, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->activeDuration_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Nullable<double> const & currentValue = mCurrentIteration;
if (currentValue.IsNull()) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->currentIteration_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
temp.set(JS::NumberValue(double(currentValue.Value())));
if (!JS_DefinePropertyById(cx, obj, atomsCache->currentIteration_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mEndTime.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
OwningDoubleOrCSSNumericValue const & currentValue = mEndTime.InternalValue();
if (!currentValue.ToJSVal(cx, obj, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->endTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
if (mLocalTime.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Nullable<OwningDoubleOrCSSNumericValue > const & currentValue = mLocalTime.InternalValue();
if (currentValue.IsNull()) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->localTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
if (!currentValue.Value().ToJSVal(cx, obj, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->localTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
Nullable<double> const & currentValue = mProgress;
if (currentValue.IsNull()) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->progress_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
temp.set(JS::NumberValue(double(currentValue.Value())));
if (!JS_DefinePropertyById(cx, obj, atomsCache->progress_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
if (mStartTime.WasPassed()) {
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
OwningDoubleOrCSSNumericValue const & currentValue = mStartTime.InternalValue();
if (!currentValue.ToJSVal(cx, obj, &temp)) {
return false;
}
if (!JS_DefinePropertyById(cx, obj, atomsCache->startTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
} while(false);
}
return true;
}
void
ComputedEffectTiming::TraceDictionary(JSTracer* trc)
{
EffectTiming::TraceDictionary(trc);
}
ComputedEffectTiming&
ComputedEffectTiming::operator=(const ComputedEffectTiming& aOther)
{
EffectTiming::operator=(aOther);
mActiveDuration.Reset();
if (aOther.mActiveDuration.WasPassed()) {
mActiveDuration.Construct(aOther.mActiveDuration.Value());
}
mCurrentIteration = aOther.mCurrentIteration;
mEndTime.Reset();
if (aOther.mEndTime.WasPassed()) {
mEndTime.Construct(aOther.mEndTime.Value());
}
mLocalTime.Reset();
if (aOther.mLocalTime.WasPassed()) {
mLocalTime.Construct(aOther.mLocalTime.Value());
}
mProgress = aOther.mProgress;
mStartTime.Reset();
if (aOther.mStartTime.WasPassed()) {
mStartTime.Construct(aOther.mStartTime.Value());
}
return *this;
}
namespace AnimationEffect_Binding {
MOZ_CAN_RUN_SCRIPT static bool
getTiming(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"AnimationEffect", "getTiming", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::AnimationEffect*>(void_self);
EffectTiming result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetTiming(result))>, "Should be returning void here");
MOZ_KnownLive(self)->GetTiming(result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result.ToObjectInternal(cx, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo getTiming_methodinfo = {
{ (JSJitGetterOp)getTiming },
{ prototypes::id::AnimationEffect },
{ PrototypeTraits<prototypes::id::AnimationEffect>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
getComputedTiming(JSContext* cx, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"AnimationEffect", "getComputedTiming", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::AnimationEffect*>(void_self);
ComputedEffectTiming result;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->GetComputedTimingAsDict(result))>, "Should be returning void here");
MOZ_KnownLive(self)->GetComputedTimingAsDict(result);
MOZ_ASSERT(!JS_IsExceptionPending(cx));
if (!result.ToObjectInternal(cx, args.rval())) {
return false;
}
return true;
}
static const JSJitInfo getComputedTiming_methodinfo = {
{ (JSJitGetterOp)getComputedTiming },
{ prototypes::id::AnimationEffect },
{ PrototypeTraits<prototypes::id::AnimationEffect>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_CAN_RUN_SCRIPT static bool
updateTiming(JSContext* cx_, JS::Handle<JSObject*> obj, void* void_self, const JSJitMethodCallArgs& args)
{
BindingCallContext cx(cx_, "AnimationEffect.updateTiming");
AUTO_PROFILER_LABEL_DYNAMIC_FAST(
"AnimationEffect", "updateTiming", DOM, cx,
uint32_t(js::ProfilingStackFrame::Flags::STRING_TEMPLATE_METHOD) |
uint32_t(js::ProfilingStackFrame::Flags::RELEVANT_FOR_JS));
auto* self = static_cast<mozilla::dom::AnimationEffect*>(void_self);
binding_detail::FastOptionalEffectTiming arg0;
if (!arg0.Init(cx, (args.hasDefined(0)) ? args[0] : JS::NullHandleValue, "Argument 1", false)) {
return false;
}
FastErrorResult rv;
// NOTE: This assert does NOT call the function.
static_assert(std::is_void_v<decltype(MOZ_KnownLive(self)->UpdateTiming(Constify(arg0), rv))>, "Should be returning void here");
MOZ_KnownLive(self)->UpdateTiming(Constify(arg0), rv);
if (rv.MaybeSetPendingException(cx, "AnimationEffect.updateTiming")) [[unlikely]] {
return false;
}
MOZ_ASSERT(!JS_IsExceptionPending(cx));
args.rval().setUndefined();
return true;
}
static const JSJitInfo updateTiming_methodinfo = {
{ (JSJitGetterOp)updateTiming },
{ prototypes::id::AnimationEffect },
{ PrototypeTraits<prototypes::id::AnimationEffect>::Depth },
JSJitInfo::Method,
JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
false, /* isInfallible. False in setters. */
false, /* isMovable. Not relevant for setters. */
false, /* isEliminatable. Not relevant for setters. */
false, /* isAlwaysInSlot. Only relevant for getters. */
false, /* isLazilyCachedInSlot. Only relevant for getters. */
false, /* isTypedMethod. Only relevant for methods. */
0 /* Reserved slot index, if we're stored in a slot, else 0. */
};
MOZ_GLOBINIT static const JSFunctionSpec sMethods_specs[] = {
JS_FNSPEC("getTiming", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getTiming_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("getComputedTiming", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&getComputedTiming_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
JS_FNSPEC("updateTiming", (GenericMethod<NormalThisPolicy, ThrowExceptions>), reinterpret_cast<const JSJitInfo*>(&updateTiming_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
JS_FS_END
};
static const Prefable<const JSFunctionSpec> sMethods[] = {
{ nullptr, &sMethods_specs[0] },
{ nullptr, nullptr }
};
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
"We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
"We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
static uint16_t sNativeProperties_sortedPropertyIndices[3];
static PropertyInfo sNativeProperties_propertyInfos[3];
static const NativePropertiesN<1> sNativeProperties = {
false, 0,
false, 0,
true, 0 /* sMethods */,
false, 0,
false, 0,
false, 0,
false, 0,
-1,
3,
sNativeProperties_sortedPropertyIndices,
{
{ sMethods, &sNativeProperties_propertyInfos[0] }
}
};
static_assert(3 < 1ull << (CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount)),
"We have a property info count that is oversized");
bool sNativePropertiesInited = false;
const NativePropertyHooks sNativePropertyHooks = {
nullptr,
{ sNativeProperties.Upcast(), nullptr, &sNativePropertiesInited },
prototypes::id::AnimationEffect,
constructors::id::AnimationEffect,
&DefaultXrayExpandoObjectClass
};
static const DOMInterfaceInfo sInterfaceObjectInfo = {
{ ThrowingConstructor, &sNativePropertyHooks },
JS::GetRealmFunctionPrototypeHandle,
PrototypeTraits<prototypes::id::AnimationEffect>::Depth,
prototypes::id::AnimationEffect,
true,
0,
"AnimationEffect",
};
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
{
"AnimationEffectPrototype",
JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
JS_NULL_CLASS_OPS,
JS_NULL_CLASS_SPEC,
JS_NULL_CLASS_EXT,
JS_NULL_OBJECT_OPS
},
eInterfacePrototype,
prototypes::id::AnimationEffect,
PrototypeTraits<prototypes::id::AnimationEffect>::Depth,
&sNativePropertyHooks,
JS::GetRealmObjectPrototype
};
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnimationEffect);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnimationEffect);
JS::Handle<JSObject*> parentProto(JS::GetRealmObjectPrototypeHandle(aCx));
if (!parentProto) {
return;
}
JS::Handle<JSObject*> constructorProto(JS::GetRealmFunctionPrototypeHandle(aCx));
if (!constructorProto) {
return;
}
dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
&sPrototypeClass, protoCache,
constructorProto, &sInterfaceObjectInfo, 0, false, Span<const LegacyFactoryFunction, 0>{},
interfaceCache,
sNativeProperties.Upcast(),
nullptr,
"AnimationEffect",
aDefineOnGlobal != DefineInterfaceProperty::No,
nullptr,
false,
nullptr);
}
JS::Handle<JSObject*>
GetProtoObjectHandle(JSContext* aCx)
{
/* Get the interface prototype object for this class. This will create the
object as needed. */
return GetPerInterfaceObjectHandle(aCx, prototypes::id::AnimationEffect,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
JSObject*
GetProtoObject(JSContext* aCx)
{
return GetProtoObjectHandle(aCx);
}
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx)
{
/* Get the interface object for this class. This will create the object as
needed. */
return GetPerInterfaceObjectHandle(aCx, constructors::id::AnimationEffect,
&CreateInterfaceObjects,
DefineInterfaceProperty::CheckExposure);
}
} // namespace AnimationEffect_Binding
} // namespace dom
} // namespace mozilla