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
Родитель d03ac9c993
Коммит deee95a0d8
13 изменённых файлов: 56 добавлений и 49 удалений

Просмотреть файл

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

Просмотреть файл

@ -31,11 +31,9 @@ public:
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:
virtual ~AnimationEffectReadOnly() = default;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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