From add5d0af0eacfc8314f6c6babed16881f5e4b298 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Thu, 2 Oct 2014 15:14:14 +0900 Subject: [PATCH] Bug 1074054 part 1 - Add Animation::IsInEffect; r=dbaron This patch adds a utility method to return if an animation is "in effect" or not as defined by Web Animations: http://w3c.github.io/web-animations/#in-effect It also moves the utility method for querying if an animation is "current" (IsCurrent) to the .cpp file since it is fairly long. (Bug 1046055 makes one of the callers of IsCurrent inline-able which should offset any cost introduced by this no longer being inline-able.) --- dom/animation/Animation.cpp | 23 +++++++++++++++++++++++ dom/animation/Animation.h | 11 ++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 91fe3bf91a01..a8c9f75452f8 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -227,6 +227,29 @@ Animation::ActiveDuration(const AnimationTiming& aTiming) aTiming.mIterationDuration.MultDouble(aTiming.mIterationCount)); } +bool +Animation::IsCurrent() const +{ + if (IsFinishedTransition()) { + return false; + } + + ComputedTiming computedTiming = GetComputedTiming(); + return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before || + computedTiming.mPhase == ComputedTiming::AnimationPhase_Active; +} + +bool +Animation::IsInEffect() const +{ + if (IsFinishedTransition()) { + return false; + } + + ComputedTiming computedTiming = GetComputedTiming(); + return computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction; +} + bool Animation::HasAnimationOfProperty(nsCSSProperty aProperty) const { diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index afdb81bc97f2..c76c35c50c2c 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -224,15 +224,8 @@ public: mIsFinishedTransition = true; } - bool IsCurrent() const { - if (IsFinishedTransition()) { - return false; - } - - ComputedTiming computedTiming = GetComputedTiming(); - return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before || - computedTiming.mPhase == ComputedTiming::AnimationPhase_Active; - } + bool IsCurrent() const; + bool IsInEffect() const; enum { LAST_NOTIFICATION_NONE = uint64_t(-1),