mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1183461 part 4 - Add CSSAnimation::ElapsedTimeToTimeStamp; r=heycam
The elapsedTime member reported on AnimationEvents measures the time from the *end* of the delay phase (i.e. the beginning of the active interval) to when the event occurred. However, the AnimationTimeToTimeStamp method introduced in the previous patch expects a time relative to the animation's start time (i.e. the *start* of the delay phase). This patch adds a method that performs the necessary conversion from an elapsedTime to an animation time before calling AnimationTimeToTimeStamp. It also provides extra handling for cases such as when the animation's start time has not yet been resolved or when animation effect has disappeared.
This commit is contained in:
parent
cfd6ae6920
commit
aa5953069f
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user