Bug 1354501 - Factor out calculations for interval start/end times. r=birtles

MozReview-Commit-ID: H9iXX9VLXLr

--HG--
extra : rebase_source : 736d304858cd0a2c5953f9986dd161ebd21c8099
This commit is contained in:
Hiroyuki Ikezoe 2018-07-03 09:25:02 +09:00
Родитель 3e4ea2fa47
Коммит 1c47aa1edf
3 изменённых файлов: 39 добавлений и 15 удалений

Просмотреть файл

@ -486,6 +486,41 @@ protected:
return GetCurrentTimeForHoldTime(Nullable<TimeDuration>());
}
// Earlier side of the elapsed time range reported in CSS Animations and CSS
// Transitions events.
//
// https://drafts.csswg.org/css-animations-2/#interval-start
// https://drafts.csswg.org/css-transitions-2/#interval-start
StickyTimeDuration
IntervalStartTime(const StickyTimeDuration& aActiveDuration) const
{
MOZ_ASSERT(AsCSSTransition() || AsCSSAnimation(),
"Should be called for CSS animations or transitions");
static constexpr StickyTimeDuration zeroDuration = StickyTimeDuration();
return std::max(
std::min(StickyTimeDuration(-mEffect->SpecifiedTiming().Delay()),
aActiveDuration),
zeroDuration);
}
// Later side of the elapsed time range reported in CSS Animations and CSS
// Transitions events.
//
// https://drafts.csswg.org/css-animations-2/#interval-end
// https://drafts.csswg.org/css-transitions-2/#interval-end
StickyTimeDuration
IntervalEndTime(const StickyTimeDuration& aActiveDuration) const
{
MOZ_ASSERT(AsCSSTransition() || AsCSSAnimation(),
"Should be called for CSS animations or transitions");
static constexpr StickyTimeDuration zeroDuration = StickyTimeDuration();
return std::max(
std::min((EffectEnd() - mEffect->SpecifiedTiming().Delay()),
aActiveDuration),
zeroDuration);
}
nsIDocument* GetRenderedDocument() const;
RefPtr<AnimationTimeline> mTimeline;

Просмотреть файл

@ -193,7 +193,6 @@ CSSAnimation::QueueEvents(const StickyTimeDuration& aActiveTime)
return;
}
static constexpr StickyTimeDuration zeroDuration = StickyTimeDuration();
uint64_t currentIteration = 0;
ComputedTiming::AnimationPhase currentPhase;
StickyTimeDuration intervalStartTime;
@ -211,14 +210,8 @@ CSSAnimation::QueueEvents(const StickyTimeDuration& aActiveTime)
currentIteration == mPreviousIteration) {
return;
}
intervalStartTime =
std::max(std::min(StickyTimeDuration(-mEffect->SpecifiedTiming().Delay()),
computedTiming.mActiveDuration),
zeroDuration);
intervalEndTime =
std::max(std::min((EffectEnd() - mEffect->SpecifiedTiming().Delay()),
computedTiming.mActiveDuration),
zeroDuration);
intervalStartTime = IntervalStartTime(computedTiming.mActiveDuration);
intervalEndTime = IntervalEndTime(computedTiming.mActiveDuration);
uint64_t iterationBoundary = mPreviousIteration > currentIteration
? currentIteration + 1

Просмотреть файл

@ -206,12 +206,8 @@ CSSTransition::QueueEvents(const StickyTimeDuration& aActiveTime)
ComputedTiming computedTiming = mEffect->GetComputedTiming();
currentPhase = static_cast<TransitionPhase>(computedTiming.mPhase);
intervalStartTime =
std::max(std::min(StickyTimeDuration(-mEffect->SpecifiedTiming().Delay()),
computedTiming.mActiveDuration), zeroDuration);
intervalEndTime =
std::max(std::min((EffectEnd() - mEffect->SpecifiedTiming().Delay()),
computedTiming.mActiveDuration), zeroDuration);
intervalStartTime = IntervalStartTime(computedTiming.mActiveDuration);
intervalEndTime = IntervalEndTime(computedTiming.mActiveDuration);
}
// TimeStamps to use for ordering the events when they are dispatched. We