diff --git a/gfx/layers/AnimationHelper.cpp b/gfx/layers/AnimationHelper.cpp index 12c3529f87b8..554a8b427503 100644 --- a/gfx/layers/AnimationHelper.cpp +++ b/gfx/layers/AnimationHelper.cpp @@ -166,8 +166,7 @@ static AnimationHelper::SampleResult SampleAnimationForProperty( // Process in order, since later animations override earlier ones. for (PropertyAnimation& animation : aPropertyAnimations) { MOZ_ASSERT( - (!animation.mOriginTime.IsNull() && - animation.mStartTime.type() == MaybeTimeDuration::TTimeDuration) || + (!animation.mOriginTime.IsNull() && animation.mStartTime.isSome()) || animation.mIsNotPlaying, "If we are playing, we should have an origin time and a start time"); @@ -192,7 +191,7 @@ static AnimationHelper::SampleResult SampleAnimationForProperty( // underflow in the middle of the calulation. const TimeStamp readyTime = animation.mOriginTime + - (animation.mStartTime.get_TimeDuration() + + (animation.mStartTime.ref() + animation.mHoldTime.MultDouble(1.0 / animation.mPlaybackRate)); hasFutureReadyTime = !readyTime.IsNull() && readyTime > aPreviousFrameTime; @@ -216,11 +215,9 @@ static AnimationHelper::SampleResult SampleAnimationForProperty( // If the animation is not currently playing, e.g. paused or // finished, then use the hold time to stay at the same position. TimeDuration elapsedDuration = - animation.mIsNotPlaying || - animation.mStartTime.type() != MaybeTimeDuration::TTimeDuration + animation.mIsNotPlaying || animation.mStartTime.isNothing() ? animation.mHoldTime - : (timeStamp - animation.mOriginTime - - animation.mStartTime.get_TimeDuration()) + : (timeStamp - animation.mOriginTime - animation.mStartTime.ref()) .MultDouble(animation.mPlaybackRate); ComputedTiming computedTiming = dom::AnimationEffect::GetComputedTimingAt( diff --git a/gfx/layers/AnimationHelper.h b/gfx/layers/AnimationHelper.h index ec374b1ddf37..29c614ebb3c9 100644 --- a/gfx/layers/AnimationHelper.h +++ b/gfx/layers/AnimationHelper.h @@ -52,7 +52,7 @@ struct PropertyAnimation { dom::Nullable mPortionInSegmentOnLastCompose; TimeStamp mOriginTime; - MaybeTimeDuration mStartTime; + Maybe mStartTime; TimeDuration mHoldTime; float mPlaybackRate; dom::IterationCompositeOperation mIterationComposite; diff --git a/gfx/layers/AnimationInfo.cpp b/gfx/layers/AnimationInfo.cpp index 877983aec574..ec50e75ab17b 100644 --- a/gfx/layers/AnimationInfo.cpp +++ b/gfx/layers/AnimationInfo.cpp @@ -88,23 +88,21 @@ bool AnimationInfo::StartPendingAnimations(const TimeStamp& aReadyTime) { // If the animation is doing an async update of its playback rate, then we // want to match whatever its current time would be at *aReadyTime*. - if (!std::isnan(anim.previousPlaybackRate()) && - anim.startTime().type() == MaybeTimeDuration::TTimeDuration && + if (!std::isnan(anim.previousPlaybackRate()) && anim.startTime().isSome() && !anim.originTime().IsNull() && !anim.isNotPlaying()) { TimeDuration readyTime = aReadyTime - anim.originTime(); anim.holdTime() = dom::Animation::CurrentTimeFromTimelineTime( - readyTime, anim.startTime().get_TimeDuration(), - anim.previousPlaybackRate()); + readyTime, anim.startTime().ref(), anim.previousPlaybackRate()); // Make start time null so that we know to update it below. - anim.startTime() = null_t(); + anim.startTime() = Nothing(); } // If the animation is play-pending, resolve the start time. - if (anim.startTime().type() == MaybeTimeDuration::Tnull_t && - !anim.originTime().IsNull() && !anim.isNotPlaying()) { + if (anim.startTime().isNothing() && !anim.originTime().IsNull() && + !anim.isNotPlaying()) { TimeDuration readyTime = aReadyTime - anim.originTime(); - anim.startTime() = dom::Animation::StartTimeFromTimelineTime( - readyTime, anim.holdTime(), anim.playbackRate()); + anim.startTime() = Some(dom::Animation::StartTimeFromTimelineTime( + readyTime, anim.holdTime(), anim.playbackRate())); updated = true; } } diff --git a/gfx/layers/ipc/LayersMessages.ipdlh b/gfx/layers/ipc/LayersMessages.ipdlh index dc445e2eb929..0afe4bc492f5 100644 --- a/gfx/layers/ipc/LayersMessages.ipdlh +++ b/gfx/layers/ipc/LayersMessages.ipdlh @@ -162,11 +162,6 @@ union TransformFunction { TransformMatrix; }; -union MaybeTimeDuration { - null_t; - TimeDuration; -}; - union Animatable { null_t; float; @@ -214,7 +209,7 @@ struct Animation { TimeStamp originTime; // The start time is relative to the originTime. This allows us to represent // start times in the distant past that cannot be expressed using a TimeStamp. - MaybeTimeDuration startTime; + TimeDuration? startTime; TimeDuration delay; TimeDuration endDelay; // The value of the animation's current time at the moment it was sent to the diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 762833b1cb05..1255ba083147 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -570,9 +570,9 @@ static void AddAnimationForProperty(nsIFrame* aFrame, Nullable startTime = aAnimation->GetCurrentOrPendingStartTime(); if (startTime.IsNull()) { - animation->startTime() = null_t(); + animation->startTime() = Nothing(); } else { - animation->startTime() = startTime.Value(); + animation->startTime() = Some(startTime.Value()); } animation->holdTime() = aAnimation->GetCurrentTimeAsDuration().Value();