Bug 1164330 - Rename time fraction to (iteration) progress; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Wed, 13 May 2015 13:57:35 +0900
changeset 244708 e6826d9be450d58145fedea05423c3616ea523e9
parent 244707 9841c5d229b8e7b439df88071a65b28caaea8cce
child 244709 ae4b781ca3ca7cb281249f5278a95c2fc8075068
push id28786
push usercbook@mozilla.com
push dateWed, 20 May 2015 13:54:15 +0000
treeherdermozilla-central@8d8df22fe72d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1164330
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1164330 - Rename time fraction to (iteration) progress; r=jwatt
dom/animation/Animation.h
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
gfx/layers/composite/AsyncCompositionManager.cpp
layout/style/nsTransitionManager.cpp
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -238,19 +238,18 @@ public:
   {
     return GetEffect() && GetEffect()->IsInEffect();
   }
 
   /**
    * "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
   {
     // We need to have an effect in its active interval, and
     // be either running or waiting to run.
     return HasInPlayEffect() &&
            (PlayState() == AnimationPlayState::Running ||
             mPendingState == PendingState::PlayPending);
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -49,19 +49,19 @@ ComputedTimingFunction::GetValue(double 
     default:
       MOZ_ASSERT(false, "bad type");
       // fall through
     case nsTimingFunction::StepEnd:
       return StepEnd(mSteps, aPortion);
   }
 }
 
-// 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 {
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(KeyframeEffectReadOnly,
                                    AnimationEffectReadOnly,
                                    mTarget)
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(KeyframeEffectReadOnly,
@@ -120,30 +120,30 @@ KeyframeEffectReadOnly::GetComputedTimin
   bool isEndOfFinalIteration = false;
 
   // Get the normalized time within the active interval.
   StickyTimeDuration activeTime;
   if (localTime >= aTiming.mDelay + result.mActiveDuration) {
     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;
     // Note that infinity == floor(infinity) so this will also be true when we
     // have finished an infinitely repeating animation of zero duration.
     isEndOfFinalIteration =
       aTiming.mIterationCount != 0.0 &&
       aTiming.mIterationCount == floor(aTiming.mIterationCount);
   } else if (localTime < aTiming.mDelay) {
     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
   } else {
     MOZ_ASSERT(result.mActiveDuration != zeroDuration,
                "How can we be in the middle of a zero-duration interval?");
     result.mPhase = ComputedTiming::AnimationPhase_Active;
     activeTime = localTime - aTiming.mDelay;
@@ -175,29 +175,28 @@ KeyframeEffectReadOnly::GetComputedTimin
       : 0;
   } else {
     result.mCurrentIteration =
       static_cast<uint64_t>(activeTime / aTiming.mIterationDuration); // floor
   }
 
   // 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;
   switch (aTiming.mDirection) {
     case NS_STYLE_ANIMATION_DIRECTION_NORMAL:
       thisIterationReverse = false;
       break;
     case NS_STYLE_ANIMATION_DIRECTION_REVERSE:
@@ -206,17 +205,17 @@ KeyframeEffectReadOnly::GetComputedTimin
     case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE:
       thisIterationReverse = (result.mCurrentIteration & 1) == 1;
       break;
     case NS_STYLE_ANIMATION_DIRECTION_ALTERNATE_REVERSE:
       thisIterationReverse = (result.mCurrentIteration & 1) == 0;
       break;
   }
   if (thisIterationReverse) {
-    result.mTimeFraction = 1.0 - result.mTimeFraction;
+    result.mProgress = 1.0 - result.mProgress;
   }
 
   return result;
 }
 
 StickyTimeDuration
 KeyframeEffectReadOnly::ActiveDuration(const AnimationTiming& aTiming)
 {
@@ -262,17 +261,17 @@ KeyframeEffectReadOnly::IsCurrent(const 
 bool
 KeyframeEffectReadOnly::IsInEffect() const
 {
   if (IsFinishedTransition()) {
     return false;
   }
 
   ComputedTiming computedTiming = GetComputedTiming();
-  return computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction;
+  return computedTiming.mProgress != ComputedTiming::kNullProgress;
 }
 
 const AnimationProperty*
 KeyframeEffectReadOnly::GetAnimationOfProperty(nsCSSProperty aProperty) const
 {
   for (size_t propIdx = 0, propEnd = mProperties.Length();
        propIdx != propEnd; ++propIdx) {
     if (aProperty == mProperties[propIdx].mProperty) {
@@ -301,25 +300,25 @@ KeyframeEffectReadOnly::HasAnimationOfPr
 
 void
 KeyframeEffectReadOnly::ComposeStyle(
                           nsRefPtr<css::AnimValuesStyleRule>& aStyleRule,
                           nsCSSPropertySet& aSetProperties)
 {
   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)
   {
     const AnimationProperty& prop = mProperties[propIdx];
 
     MOZ_ASSERT(prop.mSegments[0].mFromKey == 0.0, "incorrect first from key");
     MOZ_ASSERT(prop.mSegments[prop.mSegments.Length() - 1].mToKey == 1.0,
@@ -346,21 +345,21 @@ KeyframeEffectReadOnly::ComposeStyle(
     aSetProperties.AddProperty(prop.mProperty);
 
     MOZ_ASSERT(prop.mSegments.Length() > 0,
                "property should not be in animations if it has no segments");
 
     // 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");
     }
     if (segment == segmentEnd) {
       continue;
     }
     MOZ_ASSERT(segment->mFromKey < segment->mToKey, "incorrect keys");
@@ -370,17 +369,17 @@ KeyframeEffectReadOnly::ComposeStyle(
                "out of array bounds");
 
     if (!aStyleRule) {
       // Allocate the style rule now that we know we have animation data.
       aStyleRule = new css::AnimValuesStyleRule();
     }
 
     double positionInSegment =
-      (computedTiming.mTimeFraction - segment->mFromKey) /
+      (computedTiming.mProgress - segment->mFromKey) /
       (segment->mToKey - segment->mFromKey);
     double valuePosition =
       segment->mTimingFunction.GetValue(positionInSegment);
 
     StyleAnimationValue *val = aStyleRule->AddEmptyValue(prop.mProperty);
 
 #ifdef DEBUG
     bool result =
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -67,34 +67,35 @@ struct AnimationTiming
 
 /**
  * Stores the results of calculating the timing properties of an animation
  * at a given sample time.
  */
 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 {
     // Not sampled (null sample time)
     AnimationPhase_Null,
     // Sampled prior to the start of the active interval
     AnimationPhase_Before,
     // Sampled within the active interval
@@ -270,19 +271,19 @@ public:
 
   // This function takes as input the timing parameters of an animation and
   // returns the computed timing at the specified local time.
   //
   // The local time may be null in which case only static parameters such as the
   // 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);
 
   // 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 {
--- a/gfx/layers/composite/AsyncCompositionManager.cpp
+++ b/gfx/layers/composite/AsyncCompositionManager.cpp
@@ -472,29 +472,29 @@ SampleAnimations(Layer* aLayer, TimeStam
     // example, while they are waiting to be removed) we currently just
     // assume that we should fill.
     timing.mFillMode = NS_STYLE_ANIMATION_FILL_MODE_BOTH;
 
     ComputedTiming computedTiming =
       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 =
       animData.mFunctions[segmentIndex]->GetValue(positionInSegment);
 
     // interpolate the property
     Animatable interpolatedValue;
     SampleValue(portion, animation, animData.mStartValues[segmentIndex],
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -47,43 +47,43 @@ ElementPropertyTransition::Name() const
        NS_ConvertUTF8toUTF16(nsCSSProps::GetStringValue(TransitionProperty()));
    }
    return dom::KeyframeEffectReadOnly::Name();
 }
 
 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");
   MOZ_ASSERT(!GetLocalTime().IsNull(),
              "Getting the value portion of an animation that's not being "
              "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);
 }
 
 /*****************************************************************************
  * CSSTransition                                                             *
  *****************************************************************************/
 
 mozilla::dom::AnimationPlayState
 CSSTransition::PlayStateFromJS() const