Bug 1354501 - Bail out if we know there is no need to dispatch any animation events in advance of checking which animation event we need. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 03 Jul 2018 11:06:46 +0900
changeset 813418 b76580eebaab4a23fbde4d8d738d2fad13da3bb1
parent 813417 069a372d1bddb2cca4ccb7e8b2e67f4d15cc7f54
push id114891
push userhikezoe@mozilla.com
push dateTue, 03 Jul 2018 04:49:25 +0000
reviewersbirtles
bugs1354501
milestone63.0a1
Bug 1354501 - Bail out if we know there is no need to dispatch any animation events in advance of checking which animation event we need. r?birtles MozReview-Commit-ID: JhOs0CD49R
layout/style/nsAnimationManager.cpp
layout/style/nsTransitionManager.cpp
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -197,16 +197,19 @@ CSSAnimation::QueueEvents(const StickyTi
   ComputedTiming::AnimationPhase currentPhase;
   StickyTimeDuration intervalStartTime;
   StickyTimeDuration intervalEndTime;
   StickyTimeDuration iterationStartTime;
 
   if (!mEffect) {
     currentPhase = GetAnimationPhaseWithoutEffect
       <ComputedTiming::AnimationPhase>(*this);
+    if (currentPhase == mPreviousPhase) {
+      return;
+    }
   } else {
     ComputedTiming computedTiming = mEffect->GetComputedTiming();
     currentPhase = computedTiming.mPhase;
     currentIteration = computedTiming.mCurrentIteration;
     if (currentPhase == mPreviousPhase &&
         currentIteration == mPreviousIteration) {
       return;
     }
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -205,32 +205,35 @@ CSSTransition::QueueEvents(const StickyT
   } else {
     ComputedTiming computedTiming = mEffect->GetComputedTiming();
 
     currentPhase = static_cast<TransitionPhase>(computedTiming.mPhase);
     intervalStartTime = IntervalStartTime(computedTiming.mActiveDuration);
     intervalEndTime = IntervalEndTime(computedTiming.mActiveDuration);
   }
 
+  if (mPendingState != PendingState::NotPending &&
+      (mPreviousTransitionPhase == TransitionPhase::Idle ||
+       mPreviousTransitionPhase == TransitionPhase::Pending)) {
+    currentPhase = TransitionPhase::Pending;
+  }
+
+  if (currentPhase == mPreviousTransitionPhase) {
+    return;
+  }
+
   // TimeStamps to use for ordering the events when they are dispatched. We
   // use a TimeStamp so we can compare events produced by different elements,
   // perhaps even with different timelines.
   // The zero timestamp is for transitionrun events where we ignore the delay
   // for the purpose of ordering events.
   TimeStamp zeroTimeStamp  = AnimationTimeToTimeStamp(zeroDuration);
   TimeStamp startTimeStamp = ElapsedTimeToTimeStamp(intervalStartTime);
   TimeStamp endTimeStamp   = ElapsedTimeToTimeStamp(intervalEndTime);
 
-  if (mPendingState != PendingState::NotPending &&
-      (mPreviousTransitionPhase == TransitionPhase::Idle ||
-       mPreviousTransitionPhase == TransitionPhase::Pending))
-  {
-    currentPhase = TransitionPhase::Pending;
-  }
-
   AutoTArray<AnimationEventInfo, 3> events;
 
   auto appendTransitionEvent = [&](EventMessage aMessage,
                                    const StickyTimeDuration& aElapsedTime,
                                    const TimeStamp& aTimeStamp) {
     double elapsedTime = aElapsedTime.ToSeconds();
     if (aMessage == eTransitionCancel) {
       // 0 is an inappropriate value for this callsite. What we need to do is