Bug 1164330 - Rename time fraction to (iteration) progress; r=jwatt

--HG--
extra : rebase_source : ca36d4d5dab2d08d42c7daa1e6778cda1408f465
This commit is contained in:
Brian Birtles 2015-05-13 13:57:35 +09:00
parent 691812c1ac
commit 87aaa8fc5f
5 changed files with 45 additions and 46 deletions

View File

@ -243,9 +243,8 @@ public:
* "Playing" is different to "running". An animation in its delay phase is
* still running but we only consider it playing when it is in its active
* interval. This definition is used for fetching the animations that are
* are candidates for running on the compositor (since we don't ship
* animations to the compositor when they are in their delay phase or
* paused).
* candidates for running on the compositor (since we don't ship animations
* to the compositor when they are in their delay phase or paused).
*/
bool IsPlaying() const
{

View File

@ -54,9 +54,9 @@ ComputedTimingFunction::GetValue(double aPortion) const
}
}
// In the Web Animations model, the time fraction can be outside the range
// In the Web Animations model, the iteration progress can be outside the range
// [0.0, 1.0] but it shouldn't be Infinity.
const double ComputedTiming::kNullTimeFraction = PositiveInfinity<double>();
const double ComputedTiming::kNullProgress = PositiveInfinity<double>();
namespace dom {
@ -125,7 +125,7 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
result.mPhase = ComputedTiming::AnimationPhase_After;
if (!aTiming.FillsForwards()) {
// The animation isn't active or filling at this time.
result.mTimeFraction = ComputedTiming::kNullTimeFraction;
result.mProgress = ComputedTiming::kNullProgress;
return result;
}
activeTime = result.mActiveDuration;
@ -138,7 +138,7 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
result.mPhase = ComputedTiming::AnimationPhase_Before;
if (!aTiming.FillsBackwards()) {
// The animation isn't active or filling at this time.
result.mTimeFraction = ComputedTiming::kNullTimeFraction;
result.mProgress = ComputedTiming::kNullProgress;
return result;
}
// activeTime is zero
@ -180,19 +180,18 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
// Normalize the iteration time into a fraction of the iteration duration.
if (result.mPhase == ComputedTiming::AnimationPhase_Before) {
result.mTimeFraction = 0.0;
result.mProgress = 0.0;
} else if (result.mPhase == ComputedTiming::AnimationPhase_After) {
result.mTimeFraction = isEndOfFinalIteration
? 1.0
: fmod(aTiming.mIterationCount, 1.0f);
result.mProgress = isEndOfFinalIteration
? 1.0
: fmod(aTiming.mIterationCount, 1.0f);
} else {
// We are in the active phase so the iteration duration can't be zero.
MOZ_ASSERT(aTiming.mIterationDuration != zeroDuration,
"In the active phase of a zero-duration animation?");
result.mTimeFraction =
aTiming.mIterationDuration == TimeDuration::Forever()
? 0.0
: iterationTime / aTiming.mIterationDuration;
result.mProgress = aTiming.mIterationDuration == TimeDuration::Forever()
? 0.0
: iterationTime / aTiming.mIterationDuration;
}
bool thisIterationReverse = false;
@ -211,7 +210,7 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
break;
}
if (thisIterationReverse) {
result.mTimeFraction = 1.0 - result.mTimeFraction;
result.mProgress = 1.0 - result.mProgress;
}
return result;
@ -267,7 +266,7 @@ KeyframeEffectReadOnly::IsInEffect() const
}
ComputedTiming computedTiming = GetComputedTiming();
return computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction;
return computedTiming.mProgress != ComputedTiming::kNullProgress;
}
const AnimationProperty*
@ -306,15 +305,15 @@ KeyframeEffectReadOnly::ComposeStyle(
{
ComputedTiming computedTiming = GetComputedTiming();
// If the time fraction is null, we don't have fill data for the current
// If the progress is null, we don't have fill data for the current
// time so we shouldn't animate.
if (computedTiming.mTimeFraction == ComputedTiming::kNullTimeFraction) {
if (computedTiming.mProgress == ComputedTiming::kNullProgress) {
return;
}
MOZ_ASSERT(0.0 <= computedTiming.mTimeFraction &&
computedTiming.mTimeFraction <= 1.0,
"timing fraction should be in [0-1]");
MOZ_ASSERT(0.0 <= computedTiming.mProgress &&
computedTiming.mProgress <= 1.0,
"iteration progress should be in [0-1]");
for (size_t propIdx = 0, propEnd = mProperties.Length();
propIdx != propEnd; ++propIdx)
@ -351,11 +350,11 @@ KeyframeEffectReadOnly::ComposeStyle(
// FIXME: Maybe cache the current segment?
const AnimationPropertySegment *segment = prop.mSegments.Elements(),
*segmentEnd = segment + prop.mSegments.Length();
while (segment->mToKey < computedTiming.mTimeFraction) {
while (segment->mToKey < computedTiming.mProgress) {
MOZ_ASSERT(segment->mFromKey < segment->mToKey, "incorrect keys");
++segment;
if (segment == segmentEnd) {
MOZ_ASSERT_UNREACHABLE("incorrect time fraction");
MOZ_ASSERT_UNREACHABLE("incorrect iteration progress");
break; // in order to continue in outer loop (just below)
}
MOZ_ASSERT(segment->mFromKey == (segment-1)->mToKey, "incorrect keys");
@ -375,7 +374,7 @@ KeyframeEffectReadOnly::ComposeStyle(
}
double positionInSegment =
(computedTiming.mTimeFraction - segment->mFromKey) /
(computedTiming.mProgress - segment->mFromKey) /
(segment->mToKey - segment->mFromKey);
double valuePosition =
segment->mTimingFunction.GetValue(positionInSegment);

View File

@ -72,24 +72,25 @@ struct AnimationTiming
struct ComputedTiming
{
ComputedTiming()
: mTimeFraction(kNullTimeFraction)
: mProgress(kNullProgress)
, mCurrentIteration(0)
, mPhase(AnimationPhase_Null)
{ }
static const double kNullTimeFraction;
static const double kNullProgress;
// The total duration of the animation including all iterations.
// Will equal StickyTimeDuration::Forever() if the animation repeats
// indefinitely.
StickyTimeDuration mActiveDuration;
// Will be kNullTimeFraction if the animation is neither animating nor
// Progress towards the end of the current iteration. If the effect is
// being sampled backwards, this will go from 1.0 to 0.0.
// Will be kNullProgress if the animation is neither animating nor
// filling at the sampled time.
double mTimeFraction;
double mProgress;
// Zero-based iteration index (meaningless if mTimeFraction is
// kNullTimeFraction).
// Zero-based iteration index (meaningless if mProgress is kNullProgress).
uint64_t mCurrentIteration;
enum {
@ -275,9 +276,9 @@ public:
// active duration are calculated. All other members of the returned object
// are given a null/initial value.
//
// This function returns ComputedTiming::kNullTimeFraction for the
// mTimeFraction member of the return value if the animation should not be
// run (because it is not currently active and is not filling at this time).
// This function returns ComputedTiming::kNullProgress for the mProgress
// member of the return value if the animation should not be run
// (because it is not currently active and is not filling at this time).
static ComputedTiming
GetComputedTimingAt(const Nullable<TimeDuration>& aLocalTime,
const AnimationTiming& aTiming);

View File

@ -477,19 +477,19 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
dom::KeyframeEffectReadOnly::GetComputedTimingAt(
Nullable<TimeDuration>(elapsedDuration), timing);
MOZ_ASSERT(0.0 <= computedTiming.mTimeFraction &&
computedTiming.mTimeFraction <= 1.0,
"time fraction should be in [0-1]");
MOZ_ASSERT(0.0 <= computedTiming.mProgress &&
computedTiming.mProgress <= 1.0,
"iteration progress should be in [0-1]");
int segmentIndex = 0;
AnimationSegment* segment = animation.segments().Elements();
while (segment->endPortion() < computedTiming.mTimeFraction) {
while (segment->endPortion() < computedTiming.mProgress) {
++segment;
++segmentIndex;
}
double positionInSegment =
(computedTiming.mTimeFraction - segment->startPortion()) /
(computedTiming.mProgress - segment->startPortion()) /
(segment->endPortion() - segment->startPortion());
double portion =

View File

@ -52,8 +52,8 @@ ElementPropertyTransition::Name() const
double
ElementPropertyTransition::CurrentValuePortion() const
{
// It would be easy enough to handle finished transitions by using a time
// fraction of 1 but currently we should not be called for finished
// It would be easy enough to handle finished transitions by using a
// progress of 1 but currently we should not be called for finished
// transitions.
MOZ_ASSERT(!IsFinishedTransition(),
"Getting the value portion of a finished transition");
@ -62,23 +62,23 @@ ElementPropertyTransition::CurrentValuePortion() const
"sampled");
// Transitions use a fill mode of 'backwards' so GetComputedTiming will
// never return a null time fraction due to being *before* the animation
// never return a null time progress due to being *before* the animation
// interval. However, it might be possible that we're behind on flushing
// causing us to get called *after* the animation interval. So, just in
// case, we override the fill mode to 'both' to ensure the time fraction
// case, we override the fill mode to 'both' to ensure the progress
// is never null.
AnimationTiming timingToUse = mTiming;
timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
MOZ_ASSERT(computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction,
"Got a null time fraction for a fill mode of 'both'");
MOZ_ASSERT(computedTiming.mProgress != ComputedTiming::kNullProgress,
"Got a null progress for a fill mode of 'both'");
MOZ_ASSERT(mProperties.Length() == 1,
"Should have one animation property for a transition");
MOZ_ASSERT(mProperties[0].mSegments.Length() == 1,
"Animation property should have one segment for a transition");
return mProperties[0].mSegments[0].mTimingFunction
.GetValue(computedTiming.mTimeFraction);
.GetValue(computedTiming.mProgress);
}
/*****************************************************************************