mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 18:50:08 +00:00
Bug 1164330 - Rename time fraction to (iteration) progress; r=jwatt
--HG-- extra : rebase_source : ca36d4d5dab2d08d42c7daa1e6778cda1408f465
This commit is contained in:
parent
691812c1ac
commit
87aaa8fc5f
@ -243,9 +243,8 @@ public:
|
|||||||
* "Playing" is different to "running". An animation in its delay phase is
|
* "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
|
* 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
|
* interval. This definition is used for fetching the animations that are
|
||||||
* are candidates for running on the compositor (since we don't ship
|
* candidates for running on the compositor (since we don't ship animations
|
||||||
* animations to the compositor when they are in their delay phase or
|
* to the compositor when they are in their delay phase or paused).
|
||||||
* paused).
|
|
||||||
*/
|
*/
|
||||||
bool IsPlaying() const
|
bool IsPlaying() const
|
||||||
{
|
{
|
||||||
|
@ -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.
|
// [0.0, 1.0] but it shouldn't be Infinity.
|
||||||
const double ComputedTiming::kNullTimeFraction = PositiveInfinity<double>();
|
const double ComputedTiming::kNullProgress = PositiveInfinity<double>();
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
|
|||||||
result.mPhase = ComputedTiming::AnimationPhase_After;
|
result.mPhase = ComputedTiming::AnimationPhase_After;
|
||||||
if (!aTiming.FillsForwards()) {
|
if (!aTiming.FillsForwards()) {
|
||||||
// The animation isn't active or filling at this time.
|
// The animation isn't active or filling at this time.
|
||||||
result.mTimeFraction = ComputedTiming::kNullTimeFraction;
|
result.mProgress = ComputedTiming::kNullProgress;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
activeTime = result.mActiveDuration;
|
activeTime = result.mActiveDuration;
|
||||||
@ -138,7 +138,7 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
|
|||||||
result.mPhase = ComputedTiming::AnimationPhase_Before;
|
result.mPhase = ComputedTiming::AnimationPhase_Before;
|
||||||
if (!aTiming.FillsBackwards()) {
|
if (!aTiming.FillsBackwards()) {
|
||||||
// The animation isn't active or filling at this time.
|
// The animation isn't active or filling at this time.
|
||||||
result.mTimeFraction = ComputedTiming::kNullTimeFraction;
|
result.mProgress = ComputedTiming::kNullProgress;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// activeTime is zero
|
// activeTime is zero
|
||||||
@ -180,19 +180,18 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
|
|||||||
|
|
||||||
// Normalize the iteration time into a fraction of the iteration duration.
|
// Normalize the iteration time into a fraction of the iteration duration.
|
||||||
if (result.mPhase == ComputedTiming::AnimationPhase_Before) {
|
if (result.mPhase == ComputedTiming::AnimationPhase_Before) {
|
||||||
result.mTimeFraction = 0.0;
|
result.mProgress = 0.0;
|
||||||
} else if (result.mPhase == ComputedTiming::AnimationPhase_After) {
|
} else if (result.mPhase == ComputedTiming::AnimationPhase_After) {
|
||||||
result.mTimeFraction = isEndOfFinalIteration
|
result.mProgress = isEndOfFinalIteration
|
||||||
? 1.0
|
? 1.0
|
||||||
: fmod(aTiming.mIterationCount, 1.0f);
|
: fmod(aTiming.mIterationCount, 1.0f);
|
||||||
} else {
|
} else {
|
||||||
// We are in the active phase so the iteration duration can't be zero.
|
// We are in the active phase so the iteration duration can't be zero.
|
||||||
MOZ_ASSERT(aTiming.mIterationDuration != zeroDuration,
|
MOZ_ASSERT(aTiming.mIterationDuration != zeroDuration,
|
||||||
"In the active phase of a zero-duration animation?");
|
"In the active phase of a zero-duration animation?");
|
||||||
result.mTimeFraction =
|
result.mProgress = aTiming.mIterationDuration == TimeDuration::Forever()
|
||||||
aTiming.mIterationDuration == TimeDuration::Forever()
|
? 0.0
|
||||||
? 0.0
|
: iterationTime / aTiming.mIterationDuration;
|
||||||
: iterationTime / aTiming.mIterationDuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool thisIterationReverse = false;
|
bool thisIterationReverse = false;
|
||||||
@ -211,7 +210,7 @@ KeyframeEffectReadOnly::GetComputedTimingAt(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (thisIterationReverse) {
|
if (thisIterationReverse) {
|
||||||
result.mTimeFraction = 1.0 - result.mTimeFraction;
|
result.mProgress = 1.0 - result.mProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -267,7 +266,7 @@ KeyframeEffectReadOnly::IsInEffect() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ComputedTiming computedTiming = GetComputedTiming();
|
ComputedTiming computedTiming = GetComputedTiming();
|
||||||
return computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction;
|
return computedTiming.mProgress != ComputedTiming::kNullProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AnimationProperty*
|
const AnimationProperty*
|
||||||
@ -306,15 +305,15 @@ KeyframeEffectReadOnly::ComposeStyle(
|
|||||||
{
|
{
|
||||||
ComputedTiming computedTiming = GetComputedTiming();
|
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.
|
// time so we shouldn't animate.
|
||||||
if (computedTiming.mTimeFraction == ComputedTiming::kNullTimeFraction) {
|
if (computedTiming.mProgress == ComputedTiming::kNullProgress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(0.0 <= computedTiming.mTimeFraction &&
|
MOZ_ASSERT(0.0 <= computedTiming.mProgress &&
|
||||||
computedTiming.mTimeFraction <= 1.0,
|
computedTiming.mProgress <= 1.0,
|
||||||
"timing fraction should be in [0-1]");
|
"iteration progress should be in [0-1]");
|
||||||
|
|
||||||
for (size_t propIdx = 0, propEnd = mProperties.Length();
|
for (size_t propIdx = 0, propEnd = mProperties.Length();
|
||||||
propIdx != propEnd; ++propIdx)
|
propIdx != propEnd; ++propIdx)
|
||||||
@ -351,11 +350,11 @@ KeyframeEffectReadOnly::ComposeStyle(
|
|||||||
// FIXME: Maybe cache the current segment?
|
// FIXME: Maybe cache the current segment?
|
||||||
const AnimationPropertySegment *segment = prop.mSegments.Elements(),
|
const AnimationPropertySegment *segment = prop.mSegments.Elements(),
|
||||||
*segmentEnd = segment + prop.mSegments.Length();
|
*segmentEnd = segment + prop.mSegments.Length();
|
||||||
while (segment->mToKey < computedTiming.mTimeFraction) {
|
while (segment->mToKey < computedTiming.mProgress) {
|
||||||
MOZ_ASSERT(segment->mFromKey < segment->mToKey, "incorrect keys");
|
MOZ_ASSERT(segment->mFromKey < segment->mToKey, "incorrect keys");
|
||||||
++segment;
|
++segment;
|
||||||
if (segment == segmentEnd) {
|
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)
|
break; // in order to continue in outer loop (just below)
|
||||||
}
|
}
|
||||||
MOZ_ASSERT(segment->mFromKey == (segment-1)->mToKey, "incorrect keys");
|
MOZ_ASSERT(segment->mFromKey == (segment-1)->mToKey, "incorrect keys");
|
||||||
@ -375,7 +374,7 @@ KeyframeEffectReadOnly::ComposeStyle(
|
|||||||
}
|
}
|
||||||
|
|
||||||
double positionInSegment =
|
double positionInSegment =
|
||||||
(computedTiming.mTimeFraction - segment->mFromKey) /
|
(computedTiming.mProgress - segment->mFromKey) /
|
||||||
(segment->mToKey - segment->mFromKey);
|
(segment->mToKey - segment->mFromKey);
|
||||||
double valuePosition =
|
double valuePosition =
|
||||||
segment->mTimingFunction.GetValue(positionInSegment);
|
segment->mTimingFunction.GetValue(positionInSegment);
|
||||||
|
@ -72,24 +72,25 @@ struct AnimationTiming
|
|||||||
struct ComputedTiming
|
struct ComputedTiming
|
||||||
{
|
{
|
||||||
ComputedTiming()
|
ComputedTiming()
|
||||||
: mTimeFraction(kNullTimeFraction)
|
: mProgress(kNullProgress)
|
||||||
, mCurrentIteration(0)
|
, mCurrentIteration(0)
|
||||||
, mPhase(AnimationPhase_Null)
|
, mPhase(AnimationPhase_Null)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
static const double kNullTimeFraction;
|
static const double kNullProgress;
|
||||||
|
|
||||||
// The total duration of the animation including all iterations.
|
// The total duration of the animation including all iterations.
|
||||||
// Will equal StickyTimeDuration::Forever() if the animation repeats
|
// Will equal StickyTimeDuration::Forever() if the animation repeats
|
||||||
// indefinitely.
|
// indefinitely.
|
||||||
StickyTimeDuration mActiveDuration;
|
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.
|
// filling at the sampled time.
|
||||||
double mTimeFraction;
|
double mProgress;
|
||||||
|
|
||||||
// Zero-based iteration index (meaningless if mTimeFraction is
|
// Zero-based iteration index (meaningless if mProgress is kNullProgress).
|
||||||
// kNullTimeFraction).
|
|
||||||
uint64_t mCurrentIteration;
|
uint64_t mCurrentIteration;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -275,9 +276,9 @@ public:
|
|||||||
// active duration are calculated. All other members of the returned object
|
// active duration are calculated. All other members of the returned object
|
||||||
// are given a null/initial value.
|
// are given a null/initial value.
|
||||||
//
|
//
|
||||||
// This function returns ComputedTiming::kNullTimeFraction for the
|
// This function returns ComputedTiming::kNullProgress for the mProgress
|
||||||
// mTimeFraction member of the return value if the animation should not be
|
// member of the return value if the animation should not be run
|
||||||
// run (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 AnimationTiming& aTiming);
|
||||||
|
@ -477,19 +477,19 @@ SampleAnimations(Layer* aLayer, TimeStamp aPoint)
|
|||||||
dom::KeyframeEffectReadOnly::GetComputedTimingAt(
|
dom::KeyframeEffectReadOnly::GetComputedTimingAt(
|
||||||
Nullable<TimeDuration>(elapsedDuration), timing);
|
Nullable<TimeDuration>(elapsedDuration), timing);
|
||||||
|
|
||||||
MOZ_ASSERT(0.0 <= computedTiming.mTimeFraction &&
|
MOZ_ASSERT(0.0 <= computedTiming.mProgress &&
|
||||||
computedTiming.mTimeFraction <= 1.0,
|
computedTiming.mProgress <= 1.0,
|
||||||
"time fraction should be in [0-1]");
|
"iteration progress should be in [0-1]");
|
||||||
|
|
||||||
int segmentIndex = 0;
|
int segmentIndex = 0;
|
||||||
AnimationSegment* segment = animation.segments().Elements();
|
AnimationSegment* segment = animation.segments().Elements();
|
||||||
while (segment->endPortion() < computedTiming.mTimeFraction) {
|
while (segment->endPortion() < computedTiming.mProgress) {
|
||||||
++segment;
|
++segment;
|
||||||
++segmentIndex;
|
++segmentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
double positionInSegment =
|
double positionInSegment =
|
||||||
(computedTiming.mTimeFraction - segment->startPortion()) /
|
(computedTiming.mProgress - segment->startPortion()) /
|
||||||
(segment->endPortion() - segment->startPortion());
|
(segment->endPortion() - segment->startPortion());
|
||||||
|
|
||||||
double portion =
|
double portion =
|
||||||
|
@ -52,8 +52,8 @@ ElementPropertyTransition::Name() const
|
|||||||
double
|
double
|
||||||
ElementPropertyTransition::CurrentValuePortion() const
|
ElementPropertyTransition::CurrentValuePortion() const
|
||||||
{
|
{
|
||||||
// It would be easy enough to handle finished transitions by using a time
|
// It would be easy enough to handle finished transitions by using a
|
||||||
// fraction of 1 but currently we should not be called for finished
|
// progress of 1 but currently we should not be called for finished
|
||||||
// transitions.
|
// transitions.
|
||||||
MOZ_ASSERT(!IsFinishedTransition(),
|
MOZ_ASSERT(!IsFinishedTransition(),
|
||||||
"Getting the value portion of a finished transition");
|
"Getting the value portion of a finished transition");
|
||||||
@ -62,23 +62,23 @@ ElementPropertyTransition::CurrentValuePortion() const
|
|||||||
"sampled");
|
"sampled");
|
||||||
|
|
||||||
// Transitions use a fill mode of 'backwards' so GetComputedTiming will
|
// 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
|
// interval. However, it might be possible that we're behind on flushing
|
||||||
// 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 time fraction
|
// case, we override the fill mode to 'both' to ensure the progress
|
||||||
// is never null.
|
// is never null.
|
||||||
AnimationTiming timingToUse = mTiming;
|
AnimationTiming timingToUse = mTiming;
|
||||||
timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
|
timingToUse.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
|
||||||
ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
|
ComputedTiming computedTiming = GetComputedTiming(&timingToUse);
|
||||||
|
|
||||||
MOZ_ASSERT(computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction,
|
MOZ_ASSERT(computedTiming.mProgress != ComputedTiming::kNullProgress,
|
||||||
"Got a null time fraction for a fill mode of 'both'");
|
"Got a null progress for a fill mode of 'both'");
|
||||||
MOZ_ASSERT(mProperties.Length() == 1,
|
MOZ_ASSERT(mProperties.Length() == 1,
|
||||||
"Should have one animation property for a transition");
|
"Should have one animation property for a transition");
|
||||||
MOZ_ASSERT(mProperties[0].mSegments.Length() == 1,
|
MOZ_ASSERT(mProperties[0].mSegments.Length() == 1,
|
||||||
"Animation property should have one segment for a transition");
|
"Animation property should have one segment for a transition");
|
||||||
return mProperties[0].mSegments[0].mTimingFunction
|
return mProperties[0].mSegments[0].mTimingFunction
|
||||||
.GetValue(computedTiming.mTimeFraction);
|
.GetValue(computedTiming.mProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user