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/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 {
const nsLiteralCString EnumStrings<FillMode>::Values[5] = {
"none"_ns,
"forwards"_ns,
"backwards"_ns,
"both"_ns,
"auto"_ns,
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, FillMode aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(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 {
const nsLiteralCString EnumStrings<PlaybackDirection>::Values[4] = {
"normal"_ns,
"reverse"_ns,
"alternate"_ns,
"alternate-reverse"_ns,
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, PlaybackDirection aArgument, JS::MutableHandle<JS::Value> aValue)
{
MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(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;
}
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.set(JS::ObjectValue(*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);
OwningUnrestrictedDoubleOrString 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)
{
DictionaryBase::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)
{
DictionaryBase::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->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;
}
{
// scope for any temporaries our default value setting needs.
mActiveDuration = 0.0;
}
mIsAnyMemberPresent = true;
mCurrentIteration.SetNull();
mIsAnyMemberPresent = true;
{
// scope for any temporaries our default value setting needs.
mEndTime = 0.0;
}
mIsAnyMemberPresent = true;
mLocalTime.SetNull();
mIsAnyMemberPresent = true;
mProgress.SetNull();
mIsAnyMemberPresent = true;
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());
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mActiveDuration;
temp.set(JS_NumberValue(double(currentValue)));
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);
do {
// block for our 'break' successCode and scope for 'temp' and 'currentValue'
JS::Rooted<JS::Value> temp(cx);
double const & currentValue = mEndTime;
temp.set(JS_NumberValue(double(currentValue)));
if (!JS_DefinePropertyById(cx, obj, atomsCache->endTime_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 = mLocalTime;
if (currentValue.IsNull()) {
temp.setNull();
if (!JS_DefinePropertyById(cx, obj, atomsCache->localTime_id, temp, JSPROP_ENUMERATE)) {
return false;
}
break;
}
temp.set(JS_NumberValue(double(currentValue.Value())));
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);
return true;
}
void
ComputedEffectTiming::TraceDictionary(JSTracer* trc)
{
EffectTiming::TraceDictionary(trc);
}
ComputedEffectTiming&
ComputedEffectTiming::operator=(const ComputedEffectTiming& aOther)
{
EffectTiming::operator=(aOther);
mActiveDuration = aOther.mActiveDuration;
mCurrentIteration = aOther.mCurrentIteration;
mEndTime = aOther.mEndTime;
mLocalTime = aOther.mLocalTime;
mProgress = aOther.mProgress;
return *this;
}
bool
ComputedEffectTiming::operator==(const ComputedEffectTiming& aOther) const
{
if (mActiveDuration != aOther.mActiveDuration) {
return false;
}
if (mCurrentIteration != aOther.mCurrentIteration) {
return false;
}
if (mEndTime != aOther.mEndTime) {
return false;
}
if (mLocalTime != aOther.mLocalTime) {
return false;
}
if (mProgress != aOther.mProgress) {
return false;
}
return true;
}
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 (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx, "AnimationEffect.updateTiming"))) {
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. */
};
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::GetRealmFunctionPrototype,
prototypes::id::AnimationEffect,
PrototypeTraits<prototypes::id::AnimationEffect>::Depth,
true,
};
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, bool aDefineOnGlobal)
{
JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AnimationEffect);
JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AnimationEffect);
JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
if (!parentProto) {
return;
}
JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(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,
nullptr,
false,
nullptr);
}
JSObject*
GetProtoObject(JSContext* aCx)
{
return GetProtoObjectHandle(aCx);
}
JSObject*
GetConstructorObject(JSContext* aCx)
{
return GetConstructorObjectHandle(aCx);
}
} // namespace AnimationEffect_Binding
} // namespace dom
} // namespace mozilla