Bug 1036287 part 5 - Drop aTime param from IsRunning(At) and IsCurrent(At), since they now use the current timeline time; r=dholbert
authorBrian Birtles <birtles@gmail.com>
Wed, 16 Jul 2014 09:02:33 +0900
changeset 216200 d159f3b81265f994debb9fc51a2eee3f61b816d8
parent 216199 3d6e547234ace59fa28f92125c042fdc3a36feb2
child 216201 713c2e0870f593079211169d4d02e244d0d17e29
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1036287
milestone33.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 1036287 part 5 - Drop aTime param from IsRunning(At) and IsCurrent(At), since they now use the current timeline time; r=dholbert
content/base/src/Element.cpp
layout/base/nsDisplayList.cpp
layout/base/nsLayoutUtils.cpp
layout/style/AnimationCommon.cpp
layout/style/AnimationCommon.h
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -2863,37 +2863,31 @@ void
 Element::MozRequestPointerLock()
 {
   OwnerDoc()->RequestPointerLock(this);
 }
 
 void
 Element::GetAnimationPlayers(nsTArray<nsRefPtr<ElementAnimation> >& aPlayers)
 {
-  mozilla::TimeStamp now = OwnerDoc()->Timeline()->GetCurrentTimeStamp();
-  if (now.IsNull()) {
-    // If the timeline doesn't have a current time, return an empty list.
-    return;
-  }
-
   nsIAtom* properties[] = { nsGkAtoms::transitionsProperty,
                             nsGkAtoms::animationsProperty };
   for (size_t propIdx = 0; propIdx < MOZ_ARRAY_LENGTH(properties);
        propIdx++) {
     ElementAnimationCollection* collection =
       static_cast<ElementAnimationCollection*>(
         GetProperty(properties[propIdx]));
     if (!collection) {
       continue;
     }
     for (size_t animIdx = 0;
          animIdx < collection->mAnimations.Length();
          animIdx++) {
       ElementAnimation* anim = collection->mAnimations[animIdx];
-      if (anim->IsCurrentAt(now)) {
+      if (anim->IsCurrent()) {
         aPlayers.AppendElement(anim);
       }
     }
   }
 }
 
 NS_IMETHODIMP
 Element::GetInnerHTML(nsAString& aInnerHTML)
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -369,22 +369,19 @@ AddAnimationForProperty(nsIFrame* aFrame
   }
 }
 
 static void
 AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
                          ElementAnimationPtrArray& aAnimations,
                          Layer* aLayer, AnimationData& aData,
                          bool aPending) {
-  mozilla::TimeStamp currentTime =
-    aFrame->PresContext()->RefreshDriver()->MostRecentRefresh();
   for (uint32_t animIdx = 0; animIdx < aAnimations.Length(); animIdx++) {
     mozilla::ElementAnimation* anim = aAnimations[animIdx];
-    if (!(anim->HasAnimationOfProperty(aProperty) &&
-          anim->IsRunningAt(currentTime))) {
+    if (!(anim->HasAnimationOfProperty(aProperty) && anim->IsRunning())) {
       continue;
     }
     AddAnimationForProperty(aFrame, aProperty, anim, aLayer, aData, aPending);
     anim->mIsRunningOnCompositor = true;
   }
 }
 
 /* static */ void
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -320,22 +320,20 @@ nsLayoutUtils::HasAnimations(nsIContent*
 bool
 nsLayoutUtils::HasCurrentAnimations(nsIContent* aContent,
                                     nsIAtom* aAnimationProperty,
                                     nsPresContext* aPresContext)
 {
   if (!aContent->MayHaveAnimations())
     return false;
 
-  TimeStamp now = aPresContext->RefreshDriver()->MostRecentRefresh();
-
   ElementAnimationCollection* collection =
     static_cast<ElementAnimationCollection*>(
       aContent->GetProperty(aAnimationProperty));
-  return (collection && collection->HasCurrentAnimationsAt(now));
+  return (collection && collection->HasCurrentAnimations());
 }
 
 static gfxSize
 GetScaleForValue(const StyleAnimationValue& aValue, nsIFrame* aFrame)
 {
   if (!aFrame) {
     NS_WARNING("No frame.");
     return gfxSize();
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -449,28 +449,28 @@ ElementAnimation::CurrentTime() const
   if (currentTime.IsNull()) {
     return 0.0;
   }
 
   return currentTime.Value().ToMilliseconds();
 }
 
 bool
-ElementAnimation::IsRunningAt(TimeStamp aTime) const
+ElementAnimation::IsRunning() const
 {
   if (IsPaused() || IsFinishedTransition()) {
     return false;
   }
 
   ComputedTiming computedTiming = GetComputedTimingAt(GetLocalTime(), mTiming);
   return computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
 }
 
 bool
-ElementAnimation::IsCurrentAt(TimeStamp aTime) const
+ElementAnimation::IsCurrent() const
 {
   if (IsFinishedTransition()) {
     return false;
   }
 
   ComputedTiming computedTiming = GetComputedTimingAt(GetLocalTime(), mTiming);
   return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
          computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
@@ -723,35 +723,33 @@ ElementAnimationCollection::CanPerformOn
                             " not supported.  See bug 771367 (");
       message.Append(nsAtomCString(mElementProperty));
       message.Append(")");
       LogAsyncAnimationFailure(message, mElement);
     }
     return false;
   }
 
-  TimeStamp now = frame->PresContext()->RefreshDriver()->MostRecentRefresh();
-
   for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
     const ElementAnimation* anim = mAnimations[animIdx];
-    bool isRunning = anim->IsRunningAt(now);
+    bool isRunning = anim->IsRunning();
     for (uint32_t propIdx = 0, propEnd = anim->mProperties.Length();
          propIdx != propEnd; ++propIdx) {
       if (IsGeometricProperty(anim->mProperties[propIdx].mProperty) &&
           isRunning) {
         aFlags = CanAnimateFlags(aFlags | CanAnimate_HasGeometricProperty);
         break;
       }
     }
   }
 
   bool existsProperty = false;
   for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
     const ElementAnimation* anim = mAnimations[animIdx];
-    if (!anim->IsRunningAt(now)) {
+    if (!anim->IsRunning()) {
       continue;
     }
 
     existsProperty = true;
 
     for (uint32_t propIdx = 0, propEnd = anim->mProperties.Length();
          propIdx != propEnd; ++propIdx) {
       const AnimationProperty& prop = anim->mProperties[propIdx];
@@ -1056,20 +1054,20 @@ void
 ElementAnimationCollection::UpdateAnimationGeneration(
   nsPresContext* aPresContext)
 {
   mAnimationGeneration =
     aPresContext->RestyleManager()->GetAnimationGeneration();
 }
 
 bool
-ElementAnimationCollection::HasCurrentAnimationsAt(TimeStamp aTime)
+ElementAnimationCollection::HasCurrentAnimations()
 {
   for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
-    if (mAnimations[animIdx]->IsCurrentAt(aTime)) {
+    if (mAnimations[animIdx]->IsCurrent()) {
       return true;
     }
   }
 
   return false;
 }
 
 }
--- a/layout/style/AnimationCommon.h
+++ b/layout/style/AnimationCommon.h
@@ -355,18 +355,18 @@ public:
   }
   void SetFinishedTransition() {
     MOZ_ASSERT(AsTransition(),
                "Calling SetFinishedTransition but it's not a transition");
     mIsFinishedTransition = true;
   }
 
   bool HasAnimationOfProperty(nsCSSProperty aProperty) const;
-  bool IsRunningAt(mozilla::TimeStamp aTime) const;
-  bool IsCurrentAt(mozilla::TimeStamp aTime) const;
+  bool IsRunning() const;
+  bool IsCurrent() const;
 
   // Return the duration since the start of the delay period, taking into
   // account the pause state.  May be negative.
   // Returns a null value if the timeline associated with this object has a
   // current timestamp that is null or if the start time of this object is
   // null.
   Nullable<mozilla::TimeDuration> GetLocalTime() const {
     const mozilla::TimeStamp& timelineTime = mTimeline->GetCurrentTimeStamp();
@@ -566,19 +566,19 @@ struct ElementAnimationCollection : publ
   // mAnimationGeneration is the sequence number of the last flush where a
   // transition/animation changed.  We keep a similar count on the
   // corresponding layer so we can check that the layer is up to date with
   // the animation manager.
   uint64_t mAnimationGeneration;
   // Update mAnimationGeneration to nsCSSFrameConstructor's count
   void UpdateAnimationGeneration(nsPresContext* aPresContext);
 
-  // Returns true if there is an animation in the before or active phase at
-  // the given time.
-  bool HasCurrentAnimationsAt(mozilla::TimeStamp aTime);
+  // Returns true if there is an animation in the before or active phase
+  // at the current time.
+  bool HasCurrentAnimations();
 
   // The refresh time associated with mStyleRule.
   TimeStamp mStyleRuleRefreshTime;
 
   // Generation counter for flushes of throttled animations.
   // Used to prevent updating the styles twice for a given element during
   // UpdateAllThrottledStyles.
   TimeStamp mFlushGeneration;