Bug 1214536 - Part 7: Rename AnimationTiming as TimingParams. r=birtles, r=smaug

1. struct AnimationTiming -> struct TimingParams
2. AnimationEffectReadOnly::TimingAsObject() -> AnimationEffectReadOnly::Timing()
3. KeyframeEffectReadOnly::Timing() -> KeyframeEffectReadOnly::SpecifiedTiming()
This commit is contained in:
Boris Chiou 2016-01-13 18:41:00 +01:00
parent 980a25bcbf
commit ccddbe32ab
13 changed files with 56 additions and 49 deletions

View File

@ -1187,7 +1187,7 @@ Animation::EffectEnd() const
return StickyTimeDuration(0); return StickyTimeDuration(0);
} }
return mEffect->Timing().mDelay return mEffect->SpecifiedTiming().mDelay
+ mEffect->GetComputedTiming().mActiveDuration; + mEffect->GetComputedTiming().mActiveDuration;
} }

View File

@ -31,11 +31,9 @@ public:
nsISupports* GetParentObject() const { return mParent; } nsISupports* GetParentObject() const { return mParent; }
virtual already_AddRefed<AnimationEffectTimingReadOnly> TimingAsObject() const = 0; virtual already_AddRefed<AnimationEffectTimingReadOnly> Timing() const = 0;
virtual void GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const virtual void GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const = 0;
{
}
protected: protected:
virtual ~AnimationEffectReadOnly() = default; virtual ~AnimationEffectReadOnly() = default;

View File

@ -10,7 +10,7 @@
namespace mozilla { namespace mozilla {
bool bool
AnimationTiming::operator==(const AnimationTiming& aOther) const TimingParams::operator==(const TimingParams& aOther) const
{ {
bool durationEqual; bool durationEqual;
if (mDuration.IsUnrestrictedDouble()) { if (mDuration.IsUnrestrictedDouble()) {

View File

@ -24,7 +24,7 @@
namespace mozilla { namespace mozilla {
struct AnimationTiming struct TimingParams
{ {
// The unitialized state of mDuration represents "auto". // The unitialized state of mDuration represents "auto".
// Bug 1237173: We will replace this with Maybe<TimeDuration>. // Bug 1237173: We will replace this with Maybe<TimeDuration>.
@ -34,8 +34,8 @@ struct AnimationTiming
dom::PlaybackDirection mDirection = dom::PlaybackDirection::Normal; dom::PlaybackDirection mDirection = dom::PlaybackDirection::Normal;
dom::FillMode mFill = dom::FillMode::Auto; dom::FillMode mFill = dom::FillMode::Auto;
bool operator==(const AnimationTiming& aOther) const; bool operator==(const TimingParams& aOther) const;
bool operator!=(const AnimationTiming& aOther) const bool operator!=(const TimingParams& aOther) const
{ {
return !(*this == aOther); return !(*this == aOther);
} }
@ -48,7 +48,7 @@ class AnimationEffectTimingReadOnly : public nsWrapperCache
{ {
public: public:
AnimationEffectTimingReadOnly() = default; AnimationEffectTimingReadOnly() = default;
explicit AnimationEffectTimingReadOnly(const AnimationTiming& aTiming) explicit AnimationEffectTimingReadOnly(const TimingParams& aTiming)
: mTiming(aTiming) { } : mTiming(aTiming) { }
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationEffectTimingReadOnly) NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationEffectTimingReadOnly)
@ -73,12 +73,12 @@ public:
PlaybackDirection Direction() const { return mTiming.mDirection; } PlaybackDirection Direction() const { return mTiming.mDirection; }
void GetEasing(nsString& aRetVal) const { aRetVal.AssignLiteral("linear"); } void GetEasing(nsString& aRetVal) const { aRetVal.AssignLiteral("linear"); }
const AnimationTiming& Timing() const { return mTiming; } const TimingParams& AsTimingParams() const { return mTiming; }
void SetTiming(const AnimationTiming& aTiming) { mTiming = aTiming; } void SetTimingParams(const TimingParams& aTiming) { mTiming = aTiming; }
protected: protected:
nsCOMPtr<nsISupports> mParent; nsCOMPtr<nsISupports> mParent;
AnimationTiming mTiming; TimingParams mTiming;
}; };
} // namespace dom } // namespace dom

View File

@ -27,7 +27,7 @@ namespace mozilla {
static void static void
GetComputedTimingDictionary(const ComputedTiming& aComputedTiming, GetComputedTimingDictionary(const ComputedTiming& aComputedTiming,
const Nullable<TimeDuration>& aLocalTime, const Nullable<TimeDuration>& aLocalTime,
const AnimationTiming& aTiming, const TimingParams& aTiming,
dom::ComputedTimingProperties& aRetVal) dom::ComputedTimingProperties& aRetVal)
{ {
// AnimationEffectTimingProperties // AnimationEffectTimingProperties
@ -75,7 +75,7 @@ KeyframeEffectReadOnly::KeyframeEffectReadOnly(
nsIDocument* aDocument, nsIDocument* aDocument,
Element* aTarget, Element* aTarget,
nsCSSPseudoElements::Type aPseudoType, nsCSSPseudoElements::Type aPseudoType,
const AnimationTiming& aTiming) const TimingParams& aTiming)
: AnimationEffectReadOnly(aDocument) : AnimationEffectReadOnly(aDocument)
, mTarget(aTarget) , mTarget(aTarget)
, mPseudoType(aPseudoType) , mPseudoType(aPseudoType)
@ -106,19 +106,19 @@ KeyframeEffectReadOnly::Composite() const
} }
already_AddRefed<AnimationEffectTimingReadOnly> already_AddRefed<AnimationEffectTimingReadOnly>
KeyframeEffectReadOnly::TimingAsObject() const KeyframeEffectReadOnly::Timing() const
{ {
RefPtr<AnimationEffectTimingReadOnly> temp(mTiming); RefPtr<AnimationEffectTimingReadOnly> temp(mTiming);
return temp.forget(); return temp.forget();
} }
void void
KeyframeEffectReadOnly::SetTiming(const AnimationTiming& aTiming) KeyframeEffectReadOnly::SetSpecifiedTiming(const TimingParams& aTiming)
{ {
if (mTiming->Timing() == aTiming) { if (mTiming->AsTimingParams() == aTiming) {
return; return;
} }
mTiming->SetTiming(aTiming); mTiming->SetTimingParams(aTiming);
if (mAnimation) { if (mAnimation) {
mAnimation->NotifyEffectTimingUpdated(); mAnimation->NotifyEffectTimingUpdated();
} }
@ -199,16 +199,17 @@ void
KeyframeEffectReadOnly::GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const KeyframeEffectReadOnly::GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const
{ {
const Nullable<TimeDuration> currentTime = GetLocalTime(); const Nullable<TimeDuration> currentTime = GetLocalTime();
GetComputedTimingDictionary(GetComputedTimingAt(currentTime, Timing()), GetComputedTimingDictionary(GetComputedTimingAt(currentTime,
SpecifiedTiming()),
currentTime, currentTime,
Timing(), SpecifiedTiming(),
aRetVal); aRetVal);
} }
ComputedTiming ComputedTiming
KeyframeEffectReadOnly::GetComputedTimingAt( KeyframeEffectReadOnly::GetComputedTimingAt(
const Nullable<TimeDuration>& aLocalTime, const Nullable<TimeDuration>& aLocalTime,
const AnimationTiming& aTiming) const TimingParams& aTiming)
{ {
const StickyTimeDuration zeroDuration; const StickyTimeDuration zeroDuration;
@ -638,11 +639,11 @@ DumpAnimationProperties(nsTArray<AnimationProperty>& aAnimationProperties)
} }
#endif #endif
/* static */ AnimationTiming /* static */ TimingParams
KeyframeEffectReadOnly::ConvertKeyframeEffectOptions( KeyframeEffectReadOnly::ConvertKeyframeEffectOptions(
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions) const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions)
{ {
AnimationTiming animationTiming; TimingParams animationTiming;
if (aOptions.IsKeyframeEffectOptions()) { if (aOptions.IsKeyframeEffectOptions()) {
const KeyframeEffectOptions& opt = aOptions.GetAsKeyframeEffectOptions(); const KeyframeEffectOptions& opt = aOptions.GetAsKeyframeEffectOptions();
@ -1698,7 +1699,7 @@ KeyframeEffectReadOnly::Constructor(
return nullptr; return nullptr;
} }
AnimationTiming timing = ConvertKeyframeEffectOptions(aOptions); TimingParams timing = ConvertKeyframeEffectOptions(aOptions);
InfallibleTArray<AnimationProperty> animationProperties; InfallibleTArray<AnimationProperty> animationProperties;
BuildAnimationPropertyList(aGlobal.Context(), aTarget, aFrames, BuildAnimationPropertyList(aGlobal.Context(), aTarget, aFrames,

View File

@ -20,7 +20,7 @@
#include "mozilla/StyleAnimationValue.h" #include "mozilla/StyleAnimationValue.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
#include "mozilla/dom/AnimationEffectReadOnly.h" #include "mozilla/dom/AnimationEffectReadOnly.h"
#include "mozilla/dom/AnimationEffectTimingReadOnly.h" // AnimationTiming #include "mozilla/dom/AnimationEffectTimingReadOnly.h" // TimingParams
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/KeyframeBinding.h" #include "mozilla/dom/KeyframeBinding.h"
#include "mozilla/dom/Nullable.h" #include "mozilla/dom/Nullable.h"
@ -61,8 +61,8 @@ struct ComputedTiming
Nullable<double> mProgress; Nullable<double> mProgress;
// Zero-based iteration index (meaningless if mProgress is null). // Zero-based iteration index (meaningless if mProgress is null).
uint64_t mCurrentIteration = 0; uint64_t mCurrentIteration = 0;
// Unlike AnimationTiming::mIterations, this value is guaranteed to be in the // Unlike TimingParams::mIterations, this value is
// range [0, Infinity]. // guaranteed to be in the range [0, Infinity].
double mIterations = 1.0; double mIterations = 1.0;
StickyTimeDuration mDuration; StickyTimeDuration mDuration;
@ -170,7 +170,7 @@ public:
KeyframeEffectReadOnly(nsIDocument* aDocument, KeyframeEffectReadOnly(nsIDocument* aDocument,
Element* aTarget, Element* aTarget,
nsCSSPseudoElements::Type aPseudoType, nsCSSPseudoElements::Type aPseudoType,
const AnimationTiming& aTiming); const TimingParams& aTiming);
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffectReadOnly, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(KeyframeEffectReadOnly,
@ -219,9 +219,13 @@ public:
aRetVal.AssignLiteral("distribute"); aRetVal.AssignLiteral("distribute");
} }
const AnimationTiming& Timing() const { return mTiming->Timing(); } already_AddRefed<AnimationEffectTimingReadOnly> Timing() const override;
void SetTiming(const AnimationTiming& aTiming);
already_AddRefed<AnimationEffectTimingReadOnly> TimingAsObject() const override; const TimingParams& SpecifiedTiming() const
{
return mTiming->AsTimingParams();
}
void SetSpecifiedTiming(const TimingParams& aTiming);
void NotifyAnimationTimingUpdated(); void NotifyAnimationTimingUpdated();
Nullable<TimeDuration> GetLocalTime() const; Nullable<TimeDuration> GetLocalTime() const;
@ -238,14 +242,15 @@ public:
// (because it is not currently active and is not filling at this time). // (because it is not currently active and is not filling at this time).
static ComputedTiming static ComputedTiming
GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime, GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime,
const AnimationTiming& aTiming); const TimingParams& aTiming);
// Shortcut for that gets the computed timing using the current local time as // Shortcut for that gets the computed timing using the current local time as
// calculated from the timeline time. // calculated from the timeline time.
ComputedTiming ComputedTiming
GetComputedTiming(const AnimationTiming* aTiming = nullptr) const GetComputedTiming(const TimingParams* aTiming = nullptr) const
{ {
return GetComputedTimingAt(GetLocalTime(), aTiming ? *aTiming : Timing()); return GetComputedTimingAt(GetLocalTime(),
aTiming ? *aTiming : SpecifiedTiming());
} }
void void
@ -328,7 +333,7 @@ protected:
// owning Animation's timing. // owning Animation's timing.
void UpdateTargetRegistration(); void UpdateTargetRegistration();
static AnimationTiming ConvertKeyframeEffectOptions( static TimingParams ConvertKeyframeEffectOptions(
const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions); const UnrestrictedDoubleOrKeyframeEffectOptions& aOptions);
static void BuildAnimationPropertyList( static void BuildAnimationPropertyList(

View File

@ -46,7 +46,7 @@ dictionary ComputedTimingProperties : AnimationEffectTimingProperties {
[Func="nsDocument::IsWebAnimationsEnabled"] [Func="nsDocument::IsWebAnimationsEnabled"]
interface AnimationEffectReadOnly { interface AnimationEffectReadOnly {
[Cached, Constant, BinaryName="timingAsObject"] [Cached, Constant]
readonly attribute AnimationEffectTimingReadOnly timing; readonly attribute AnimationEffectTimingReadOnly timing;
[BinaryName="getComputedTimingAsDict"] [BinaryName="getComputedTimingAsDict"]
ComputedTimingProperties getComputedTiming(); ComputedTimingProperties getComputedTiming();

View File

@ -581,13 +581,15 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
continue; continue;
} }
AnimationTiming timing; TimingParams timing;
timing.mDuration.SetAsUnrestrictedDouble() = animation.duration().ToMilliseconds(); timing.mDuration.SetAsUnrestrictedDouble() =
animation.duration().ToMilliseconds();
// Currently animations run on the compositor have their delay factored // Currently animations run on the compositor have their delay factored
// into their start time, hence the delay is effectively zero. // into their start time, hence the delay is effectively zero.
timing.mDelay = TimeDuration(0); timing.mDelay = TimeDuration(0);
timing.mIterations = animation.iterations(); timing.mIterations = animation.iterations();
timing.mDirection = static_cast<dom::PlaybackDirection>(animation.direction()); timing.mDirection =
static_cast<dom::PlaybackDirection>(animation.direction());
// Animations typically only run on the compositor during their active // Animations typically only run on the compositor during their active
// interval but if we end up sampling them outside that range (for // interval but if we end up sampling them outside that range (for
// example, while they are waiting to be removed) we currently just // example, while they are waiting to be removed) we currently just

View File

@ -381,7 +381,7 @@ AddAnimationForProperty(nsIFrame* aFrame, const AnimationProperty& aProperty,
aLayer->AddAnimationForNextTransaction() : aLayer->AddAnimationForNextTransaction() :
aLayer->AddAnimation(); aLayer->AddAnimation();
const AnimationTiming& timing = aAnimation->GetEffect()->Timing(); const TimingParams& timing = aAnimation->GetEffect()->SpecifiedTiming();
const ComputedTiming computedTiming = const ComputedTiming computedTiming =
aAnimation->GetEffect()->GetComputedTiming(); aAnimation->GetEffect()->GetComputedTiming();
Nullable<TimeDuration> startTime = aAnimation->GetCurrentOrPendingStartTime(); Nullable<TimeDuration> startTime = aAnimation->GetCurrentOrPendingStartTime();

View File

@ -289,7 +289,8 @@ CSSAnimation::ElapsedTimeToTimeStamp(const StickyTimeDuration&
return result; return result;
} }
result = AnimationTimeToTimeStamp(aElapsedTime + mEffect->Timing().mDelay); result = AnimationTimeToTimeStamp(aElapsedTime +
mEffect->SpecifiedTiming().mDelay);
return result; return result;
} }
@ -422,9 +423,9 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
KeyframeEffectReadOnly* oldEffect = oldAnim->GetEffect(); KeyframeEffectReadOnly* oldEffect = oldAnim->GetEffect();
KeyframeEffectReadOnly* newEffect = newAnim->GetEffect(); KeyframeEffectReadOnly* newEffect = newAnim->GetEffect();
animationChanged = animationChanged =
oldEffect->Timing() != newEffect->Timing() || oldEffect->SpecifiedTiming() != newEffect->SpecifiedTiming() ||
oldEffect->Properties() != newEffect->Properties(); oldEffect->Properties() != newEffect->Properties();
oldEffect->SetTiming(newEffect->Timing()); oldEffect->SetSpecifiedTiming(newEffect->SpecifiedTiming());
oldEffect->CopyPropertiesFrom(*newEffect); oldEffect->CopyPropertiesFrom(*newEffect);
} }
@ -624,7 +625,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
dest->SetAnimationIndex(static_cast<uint64_t>(animIdx)); dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
aAnimations.AppendElement(dest); aAnimations.AppendElement(dest);
AnimationTiming timing; TimingParams timing;
timing.mDuration.SetAsUnrestrictedDouble() = src.GetDuration(); timing.mDuration.SetAsUnrestrictedDouble() = src.GetDuration();
timing.mDelay = TimeDuration::FromMilliseconds(src.GetDelay()); timing.mDelay = TimeDuration::FromMilliseconds(src.GetDelay());
timing.mIterations = src.GetIterationCount(); timing.mIterations = src.GetIterationCount();

View File

@ -173,7 +173,7 @@ protected:
// This is used for setting the elapsedTime member of CSS AnimationEvents. // This is used for setting the elapsedTime member of CSS AnimationEvents.
TimeDuration InitialAdvance() const { TimeDuration InitialAdvance() const {
return mEffect ? return mEffect ?
std::max(TimeDuration(), mEffect->Timing().mDelay * -1) : std::max(TimeDuration(), mEffect->SpecifiedTiming().mDelay * -1) :
TimeDuration(); TimeDuration();
} }
// Converts an AnimationEvent's elapsedTime value to an equivalent TimeStamp // Converts an AnimationEvent's elapsedTime value to an equivalent TimeStamp

View File

@ -55,7 +55,7 @@ ElementPropertyTransition::CurrentValuePortion() const
// causing us to get called *after* the animation interval. So, just in // causing us to get called *after* the animation interval. So, just in
// case, we override the fill mode to 'both' to ensure the progress // case, we override the fill mode to 'both' to ensure the progress
// is never null. // is never null.
AnimationTiming timingToUse = Timing(); TimingParams timingToUse = SpecifiedTiming();
timingToUse.mFill = dom::FillMode::Both; timingToUse.mFill = dom::FillMode::Both;
ComputedTiming computedTiming = GetComputedTiming(&timingToUse); ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
@ -653,7 +653,7 @@ nsTransitionManager::ConsiderStartingTransition(
reversePortion = valuePortion; reversePortion = valuePortion;
} }
AnimationTiming timing; TimingParams timing;
timing.mDuration.SetAsUnrestrictedDouble() = duration; timing.mDuration.SetAsUnrestrictedDouble() = duration;
timing.mDelay = TimeDuration::FromMilliseconds(delay); timing.mDelay = TimeDuration::FromMilliseconds(delay);
timing.mIterations = 1.0; timing.mIterations = 1.0;

View File

@ -38,7 +38,7 @@ struct ElementPropertyTransition : public dom::KeyframeEffectReadOnly
ElementPropertyTransition(nsIDocument* aDocument, ElementPropertyTransition(nsIDocument* aDocument,
dom::Element* aTarget, dom::Element* aTarget,
nsCSSPseudoElements::Type aPseudoType, nsCSSPseudoElements::Type aPseudoType,
const AnimationTiming &aTiming) const TimingParams &aTiming)
: dom::KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType, aTiming) : dom::KeyframeEffectReadOnly(aDocument, aTarget, aPseudoType, aTiming)
{ } { }