Bug 1263063 - Part 4: Move ActiveDuration() into TimingParams. r=dholbert
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Thu, 14 Apr 2016 19:39:39 +0900
changeset 293375 4160ea9c6de3c74e97a42a5fcef7f6739de0c002
parent 293374 2c606174ee177c27f1230d65eb3ead1c70b4af1f
child 293376 eeda1ce1705512036048ac378d3ac8cbfc8030f4
push id30180
push userkwierso@gmail.com
push dateFri, 15 Apr 2016 21:31:41 +0000
treeherdermozilla-central@ded7cf683d5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1263063
milestone48.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 1263063 - Part 4: Move ActiveDuration() into TimingParams. r=dholbert MozReview-Commit-ID: 4HS8vTJYtDe
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
dom/animation/TimingParams.h
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -248,17 +248,17 @@ KeyframeEffectReadOnly::GetComputedTimin
              "mIterations should be nonnegative & finite, as ensured by "
              "ValidateIterations or CSSParser");
   result.mIterations = aTiming.mIterations;
   MOZ_ASSERT(aTiming.mIterationStart >= 0.0,
              "mIterationStart should be nonnegative, as ensured by "
              "ValidateIterationStart");
   result.mIterationStart = aTiming.mIterationStart;
 
-  result.mActiveDuration = ActiveDuration(result.mDuration, result.mIterations);
+  result.mActiveDuration = aTiming.ActiveDuration();
   result.mEndTime = aTiming.mDelay + result.mActiveDuration +
                     aTiming.mEndDelay;
   result.mFill = aTiming.mFill == dom::FillMode::Auto ?
                  dom::FillMode::None :
                  aTiming.mFill;
 
   // The default constructor for ComputedTiming sets all other members to
   // values consistent with an animation that has not been sampled.
@@ -401,33 +401,16 @@ KeyframeEffectReadOnly::GetComputedTimin
     result.mProgress.SetValue(
       aTiming.mFunction->GetValue(result.mProgress.Value(),
                                   result.mBeforeFlag));
   }
 
   return result;
 }
 
-StickyTimeDuration
-KeyframeEffectReadOnly::ActiveDuration(
-  const StickyTimeDuration& aIterationDuration,
-  double aIterationCount)
-{
-  // If either the iteration duration or iteration count is zero,
-  // Web Animations says that the active duration is zero. This is to
-  // ensure that the result is defined when the other argument is Infinity.
-  const StickyTimeDuration zeroDuration;
-  if (aIterationDuration == zeroDuration ||
-      aIterationCount == 0.0) {
-    return zeroDuration;
-  }
-
-  return aIterationDuration.MultDouble(aIterationCount);
-}
-
 // https://w3c.github.io/web-animations/#in-play
 bool
 KeyframeEffectReadOnly::IsInPlay() const
 {
   if (!mAnimation || mAnimation->PlayState() == AnimationPlayState::Finished) {
     return false;
   }
 
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -269,22 +269,16 @@ public:
   {
     return GetComputedTimingAt(GetLocalTime(),
                                aTiming ? *aTiming : SpecifiedTiming());
   }
 
   void
   GetComputedTimingAsDict(ComputedTimingProperties& aRetVal) const override;
 
-  // Return the duration of the active interval for the given duration and
-  // iteration count.
-  static StickyTimeDuration
-  ActiveDuration(const StickyTimeDuration& aIterationDuration,
-                 double aIterationCount);
-
   bool IsInPlay() const;
   bool IsCurrent() const;
   bool IsInEffect() const;
 
   void SetAnimation(Animation* aAnimation);
   Animation* GetAnimation() const { return mAnimation; }
 
   void SetFrames(nsTArray<Keyframe>&& aFrames, nsStyleContext* aStyleContext);
--- a/dom/animation/TimingParams.h
+++ b/dom/animation/TimingParams.h
@@ -92,16 +92,31 @@ struct TimingParams
   TimeDuration mDelay;      // Initializes to zero
   TimeDuration mEndDelay;
   double mIterations = 1.0; // Can be NaN, negative, +/-Infinity
   double mIterationStart = 0.0;
   dom::PlaybackDirection mDirection = dom::PlaybackDirection::Normal;
   dom::FillMode mFill = dom::FillMode::Auto;
   Maybe<ComputedTimingFunction> mFunction;
 
+  // Return the duration of the active interval calculated by duration and
+  // iteration count.
+  StickyTimeDuration ActiveDuration() const
+  {
+    // If either the iteration duration or iteration count is zero,
+    // Web Animations says that the active duration is zero. This is to
+    // ensure that the result is defined when the other argument is Infinity.
+    static const StickyTimeDuration zeroDuration;
+    if (!mDuration || *mDuration == zeroDuration || mIterations == 0.0) {
+      return zeroDuration;
+    }
+
+    return mDuration->MultDouble(mIterations);
+  }
+
   bool operator==(const TimingParams& aOther) const;
   bool operator!=(const TimingParams& aOther) const
   {
     return !(*this == aOther);
   }
 };
 
 } // namespace mozilla