diff --git a/layout/style/nsAnimationManager.cpp b/layout/style/nsAnimationManager.cpp index 1ee6eb266ac..eb1e2fca559 100644 --- a/layout/style/nsAnimationManager.cpp +++ b/layout/style/nsAnimationManager.cpp @@ -309,6 +309,30 @@ CSSAnimation::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag) Animation::UpdateTiming(aSeekFlag, aSyncNotifyFlag); } +TimeStamp +CSSAnimation::ElapsedTimeToTimeStamp(const StickyTimeDuration& + aElapsedTime) const +{ + // Initializes to null. We always return this object to benefit from + // return-value-optimization. + TimeStamp result; + + // Currently we may dispatch animationstart events before resolving + // mStartTime if we have a delay <= 0. This will change in bug 1134163 + // but until then we should just use the latest refresh driver time as + // the event timestamp in that case. + if (!mEffect || mStartTime.IsNull()) { + nsPresContext* presContext = GetPresContext(); + if (presContext) { + result = presContext->RefreshDriver()->MostRecentRefresh(); + } + return result; + } + + result = AnimationTimeToTimeStamp(aElapsedTime + mEffect->Timing().mDelay); + return result; +} + ////////////////////////// nsAnimationManager //////////////////////////// NS_IMPL_CYCLE_COLLECTION(nsAnimationManager, mEventDispatcher) diff --git a/layout/style/nsAnimationManager.h b/layout/style/nsAnimationManager.h index 536ae15f87a..ba29d5fbd45 100644 --- a/layout/style/nsAnimationManager.h +++ b/layout/style/nsAnimationManager.h @@ -176,6 +176,10 @@ protected: std::max(TimeDuration(), mEffect->Timing().mDelay * -1) : TimeDuration(); } + // Converts an AnimationEvent's elapsedTime value to an equivalent TimeStamp + // that can be used to sort events by when they occurred. + TimeStamp ElapsedTimeToTimeStamp(const StickyTimeDuration& aElapsedTime) + const; nsString mAnimationName;