зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1215406 - Part 5: Implement KeyframeEffectOptions in KeyframeEffectReadOnly constructor. r=birtles
Implement KeyframeEffectOptions in KeyframeEffectReadOnly constructor and other related APIs.
This commit is contained in:
Родитель
79e0ffc100
Коммит
af6590f3dd
|
@ -105,6 +105,18 @@ KeyframeEffectReadOnly::WrapObject(JSContext* aCx,
|
|||
return KeyframeEffectReadOnlyBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
IterationCompositeOperation
|
||||
KeyframeEffectReadOnly::IterationComposite() const
|
||||
{
|
||||
return IterationCompositeOperation::Replace;
|
||||
}
|
||||
|
||||
CompositeOperation
|
||||
KeyframeEffectReadOnly::Composite() const
|
||||
{
|
||||
return CompositeOperation::Replace;
|
||||
}
|
||||
|
||||
void
|
||||
KeyframeEffectReadOnly::SetTiming(const AnimationTiming& aTiming)
|
||||
{
|
||||
|
@ -535,25 +547,52 @@ DumpAnimationProperties(nsTArray<AnimationProperty>& aAnimationProperties)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Extract an iteration duration from an UnrestrictedDoubleOrXXX object.
|
||||
template <typename T>
|
||||
static TimeDuration
|
||||
GetIterationDuration(const T& aDuration) {
|
||||
// Always return the same object to benefit from return-value optimization.
|
||||
TimeDuration result;
|
||||
if (aDuration.IsUnrestrictedDouble()) {
|
||||
double durationMs = aDuration.GetAsUnrestrictedDouble();
|
||||
if (!IsNaN(durationMs) && durationMs >= 0.0f) {
|
||||
result = TimeDuration::FromMilliseconds(durationMs);
|
||||
}
|
||||
}
|
||||
// else, aDuration should be zero
|
||||
return result;
|
||||
}
|
||||
|
||||
/* static */ AnimationTiming
|
||||
KeyframeEffectReadOnly::ConvertKeyframeEffectOptions(
|
||||
const Optional<double>& aOptions)
|
||||
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions)
|
||||
{
|
||||
AnimationTiming animationTiming;
|
||||
|
||||
// The spec says to treat auto durations as 0 until a later version of
|
||||
// the spec says otherwise. Bug 1215406 is for handling a
|
||||
// KeyframeEffectOptions object and not just an offset.
|
||||
if (aOptions.WasPassed()) {
|
||||
animationTiming.mIterationDuration =
|
||||
TimeDuration::FromMilliseconds(aOptions.Value());
|
||||
} else {
|
||||
animationTiming.mIterationDuration = TimeDuration(0);
|
||||
}
|
||||
animationTiming.mIterationCount = 1.0f;
|
||||
animationTiming.mDirection = PlaybackDirection::Normal;
|
||||
animationTiming.mFillMode = FillMode::None;
|
||||
if (aOptions.IsKeyframeEffectOptions()) {
|
||||
const KeyframeEffectOptions& opt = aOptions.GetAsKeyframeEffectOptions();
|
||||
|
||||
animationTiming.mIterationDuration = GetIterationDuration(opt.mDuration);
|
||||
animationTiming.mDelay = TimeDuration::FromMilliseconds(opt.mDelay);
|
||||
// FIXME: Covert mIterationCount to a valid value.
|
||||
// Bug 1214536 should revise this and keep the original value, so
|
||||
// AnimationTimingEffectReadOnly can get the original iterations.
|
||||
animationTiming.mIterationCount = (IsNaN(opt.mIterations) ||
|
||||
opt.mIterations < 0.0f) ?
|
||||
1.0f :
|
||||
opt.mIterations;
|
||||
animationTiming.mDirection = opt.mDirection;
|
||||
// FIXME: We should store original value.
|
||||
animationTiming.mFillMode = (opt.mFill == FillMode::Auto) ?
|
||||
FillMode::None :
|
||||
opt.mFill;
|
||||
} else {
|
||||
animationTiming.mIterationDuration = GetIterationDuration(aOptions);
|
||||
animationTiming.mDelay = TimeDuration(0);
|
||||
animationTiming.mIterationCount = 1.0f;
|
||||
animationTiming.mDirection = PlaybackDirection::Normal;
|
||||
animationTiming.mFillMode = FillMode::None;
|
||||
}
|
||||
return animationTiming;
|
||||
}
|
||||
|
||||
|
@ -1581,7 +1620,7 @@ KeyframeEffectReadOnly::Constructor(
|
|||
const GlobalObject& aGlobal,
|
||||
Element* aTarget,
|
||||
const Optional<JS::Handle<JSObject*>>& aFrames,
|
||||
const Optional<double>& aOptions,
|
||||
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!aTarget) {
|
||||
|
|
|
@ -37,6 +37,9 @@ class AnimValuesStyleRule;
|
|||
|
||||
namespace dom {
|
||||
struct ComputedTimingProperties;
|
||||
class UnrestrictedDoubleOrKeyframeEffectOptions;
|
||||
enum class IterationCompositeOperation : uint32_t;
|
||||
enum class CompositeOperation : uint32_t;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,7 +187,7 @@ public:
|
|||
Constructor(const GlobalObject& aGlobal,
|
||||
Element* aTarget,
|
||||
const Optional<JS::Handle<JSObject*>>& aFrames,
|
||||
const Optional<double>& aOptions,
|
||||
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
Element* GetTarget() const {
|
||||
// Currently we never return animations from the API whose effect
|
||||
|
@ -207,12 +210,14 @@ public:
|
|||
aPseudoType = mPseudoType;
|
||||
}
|
||||
|
||||
const AnimationTiming& Timing() const {
|
||||
return mTiming;
|
||||
}
|
||||
AnimationTiming& Timing() {
|
||||
return mTiming;
|
||||
IterationCompositeOperation IterationComposite() const;
|
||||
CompositeOperation Composite() const;
|
||||
void GetSpacing(nsString& aRetVal) const {
|
||||
aRetVal.AssignLiteral("distribute");
|
||||
}
|
||||
|
||||
const AnimationTiming& Timing() const { return mTiming; }
|
||||
AnimationTiming& Timing() { return mTiming; }
|
||||
void SetTiming(const AnimationTiming& aTiming);
|
||||
|
||||
Nullable<TimeDuration> GetLocalTime() const;
|
||||
|
@ -293,13 +298,14 @@ protected:
|
|||
void ResetIsRunningOnCompositor();
|
||||
|
||||
static AnimationTiming ConvertKeyframeEffectOptions(
|
||||
const Optional<double>& aOptions);
|
||||
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions);
|
||||
|
||||
static void BuildAnimationPropertyList(
|
||||
JSContext* aCx,
|
||||
Element* aTarget,
|
||||
const Optional<JS::Handle<JSObject*>>& aFrames,
|
||||
InfallibleTArray<AnimationProperty>& aResult,
|
||||
ErrorResult& aRv);
|
||||
JSContext* aCx,
|
||||
Element* aTarget,
|
||||
const Optional<JS::Handle<JSObject*>>& aFrames,
|
||||
InfallibleTArray<AnimationProperty>& aResult,
|
||||
ErrorResult& aRv);
|
||||
|
||||
nsCOMPtr<Element> mTarget;
|
||||
RefPtr<Animation> mAnimation;
|
||||
|
|
Загрузка…
Ссылка в новой задаче