Bug 1264125 part 3 - Add member of active time to ComputedTiming. r?birtles draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Thu, 17 Nov 2016 09:59:52 +0900
changeset 444207 4eabc0ab14d190699ca7a69ef42eeaeb522d0b56
parent 444206 60f80b69cd5b58bb7fc919d0a29edac4d2daf4a9
child 444208 4302bfad6cc6ec93c93d243f68f69283122cc5d2
child 444447 86e6065065ce1a5621b22b52c3fed15d88f64c0c
push id37232
push usermantaroh@gmail.com
push dateSun, 27 Nov 2016 23:34:33 +0000
reviewersbirtles
bugs1264125
milestone52.0a1
Bug 1264125 part 3 - Add member of active time to ComputedTiming. r?birtles MozReview-Commit-ID: 5Jec1jak6Sm
dom/animation/AnimationEffectReadOnly.cpp
dom/animation/ComputedTiming.h
--- a/dom/animation/AnimationEffectReadOnly.cpp
+++ b/dom/animation/AnimationEffectReadOnly.cpp
@@ -122,20 +122,16 @@ AnimationEffectReadOnly::GetComputedTimi
 
   // The default constructor for ComputedTiming sets all other members to
   // values consistent with an animation that has not been sampled.
   if (aLocalTime.IsNull()) {
     return result;
   }
   const TimeDuration& localTime = aLocalTime.Value();
 
-  // Calculate the time within the active interval.
-  // https://w3c.github.io/web-animations/#active-time
-  StickyTimeDuration activeTime;
-
   StickyTimeDuration beforeActiveBoundary =
     std::max(std::min(StickyTimeDuration(aTiming.mDelay), result.mEndTime),
              zeroDuration);
 
   StickyTimeDuration activeAfterBoundary =
     std::max(std::min(StickyTimeDuration(aTiming.mDelay +
                                          result.mActiveDuration),
                       result.mEndTime),
@@ -143,45 +139,46 @@ AnimationEffectReadOnly::GetComputedTimi
 
   if (localTime > activeAfterBoundary ||
       (aPlaybackRate >= 0 && localTime == activeAfterBoundary)) {
     result.mPhase = ComputedTiming::AnimationPhase::After;
     if (!result.FillsForwards()) {
       // The animation isn't active or filling at this time.
       return result;
     }
-    activeTime =
+    result.mActiveTime =
       std::max(std::min(StickyTimeDuration(localTime - aTiming.mDelay),
                         result.mActiveDuration),
                zeroDuration);
   } else if (localTime < beforeActiveBoundary ||
              (aPlaybackRate < 0 && localTime == beforeActiveBoundary)) {
     result.mPhase = ComputedTiming::AnimationPhase::Before;
     if (!result.FillsBackwards()) {
       // The animation isn't active or filling at this time.
       return result;
     }
-    activeTime = std::max(StickyTimeDuration(localTime - aTiming.mDelay),
-                          zeroDuration);
+    result.mActiveTime
+      = std::max(StickyTimeDuration(localTime - aTiming.mDelay),
+                 zeroDuration);
   } 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;
+    result.mActiveTime = localTime - aTiming.mDelay;
   }
 
   // Convert active time to a multiple of iterations.
   // https://w3c.github.io/web-animations/#overall-progress
   double overallProgress;
   if (result.mDuration == zeroDuration) {
     overallProgress = result.mPhase == ComputedTiming::AnimationPhase::Before
                       ? 0.0
                       : result.mIterations;
   } else {
-    overallProgress = activeTime / result.mDuration;
+    overallProgress = result.mActiveTime / result.mDuration;
   }
 
   // Factor in iteration start offset.
   if (IsFinite(overallProgress)) {
     overallProgress += result.mIterationStart;
   }
 
   // Determine the 0-based index of the current iteration.
@@ -203,17 +200,18 @@ AnimationEffectReadOnly::GetComputedTimi
   // When we finish exactly at the end of an iteration we need to report
   // the end of the final iteration and not the start of the next iteration.
   // We *don't* want to do this when we have a zero-iteration animation or
   // when the animation has been effectively made into a zero-duration animation
   // using a negative end-delay, however.
   if (result.mPhase == ComputedTiming::AnimationPhase::After &&
       progress == 0.0 &&
       result.mIterations != 0.0 &&
-      (activeTime != zeroDuration || result.mDuration == zeroDuration)) {
+      (result.mActiveTime != zeroDuration ||
+       result.mDuration == zeroDuration)) {
     // The only way we can be in the after phase with a progress of zero and
     // a current iteration of zero, is if we have a zero iteration count or
     // were clipped using a negative end delay--both of which we should have
     // detected above.
     MOZ_ASSERT(result.mCurrentIteration != 0,
                "Should not have zero current iteration");
     progress = 1.0;
     if (result.mCurrentIteration != UINT64_MAX) {
--- a/dom/animation/ComputedTiming.h
+++ b/dom/animation/ComputedTiming.h
@@ -24,16 +24,18 @@ namespace mozilla {
  * at a given sample time.
  */
 struct ComputedTiming
 {
   // The total duration of the animation including all iterations.
   // Will equal StickyTimeDuration::Forever() if the animation repeats
   // indefinitely.
   StickyTimeDuration  mActiveDuration;
+  // The time within the active interval.
+  StickyTimeDuration mActiveTime;
   // The effect end time in local time (i.e. an offset from the effect's
   // start time). Will equal StickyTimeDuration::Forever() if the animation
   // plays indefinitely.
   StickyTimeDuration  mEndTime;
   // 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 null if the animation is neither animating nor
   // filling at the sampled time.
@@ -66,13 +68,14 @@ struct ComputedTiming
     Before, // Sampled prior to the start of the active interval
     Active, // Sampled within the active interval
     After   // Sampled after (or at) the end of the active interval
   };
   AnimationPhase      mPhase = AnimationPhase::Null;
 
   ComputedTimingFunction::BeforeFlag mBeforeFlag =
     ComputedTimingFunction::BeforeFlag::Unset;
+
 };
 
 } // namespace mozilla
 
 #endif // mozilla_ComputedTiming_h