Bug 1340916 - Part 3: Add a helper function to create TimingParams CSS animation/transition properties. r=birtles

MozReview-Commit-ID: 3CmCc44FhvA

--HG--
extra : rebase_source : a0d1067916a68fc4bc18793b05ae46902fddff41
This commit is contained in:
Hiroyuki Ikezoe 2017-02-20 11:02:52 +09:00
parent 13fcf0e228
commit 48e5e75277
3 changed files with 32 additions and 21 deletions

View File

@ -15,6 +15,7 @@
#include "mozilla/dom/Animation.h"
#include "mozilla/Attributes.h" // For MOZ_NON_OWNING_REF
#include "mozilla/Assertions.h"
#include "mozilla/TimingParams.h"
#include "nsContentUtils.h"
#include "nsCSSPseudoElements.h"
#include "nsCycleCollectionParticipant.h"
@ -271,6 +272,26 @@ PhaseType GetAnimationPhaseWithoutEffect(const dom::Animation& aAnimation)
: PhaseType::After;
};
inline TimingParams
TimingParamsFromCSSParams(float aDuration, float aDelay,
float aIterationCount,
dom::PlaybackDirection aDirection,
dom::FillMode aFillMode)
{
MOZ_ASSERT(aIterationCount >= 0.0 && !IsNaN(aIterationCount),
"aIterations should be nonnegative & finite, as ensured by "
"CSSParser");
TimingParams timing;
timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(aDuration));
timing.mDelay = TimeDuration::FromMilliseconds(aDelay);
timing.mIterations = aIterationCount;
timing.mDirection = aDirection;
timing.mFill = aFillMode;
return timing;
}
} // namespace mozilla
#endif /* !defined(mozilla_css_AnimationCommon_h) */

View File

@ -584,22 +584,13 @@ private:
nsCSSValue GetComputedValue(nsPresContext* aPresContext,
nsCSSPropertyID aProperty);
static TimingParams TimingParamsFrom(
const StyleAnimation& aStyleAnimation)
static TimingParams TimingParamsFrom(const StyleAnimation& aStyleAnimation)
{
TimingParams timing;
timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(
aStyleAnimation.GetDuration()));
timing.mDelay = TimeDuration::FromMilliseconds(aStyleAnimation.GetDelay());
timing.mIterations = aStyleAnimation.GetIterationCount();
MOZ_ASSERT(timing.mIterations >= 0.0 && !IsNaN(timing.mIterations),
"mIterations should be nonnegative & finite, as ensured by "
"CSSParser");
timing.mDirection = aStyleAnimation.GetDirection();
timing.mFill = aStyleAnimation.GetFillMode();
return timing;
return TimingParamsFromCSSParams(aStyleAnimation.GetDuration(),
aStyleAnimation.GetDelay(),
aStyleAnimation.GetIterationCount(),
aStyleAnimation.GetDirection(),
aStyleAnimation.GetFillMode());
}
RefPtr<nsStyleContext> mStyleContext;

View File

@ -894,12 +894,11 @@ nsTransitionManager::ConsiderInitiatingTransition(
reversePortion = valuePortion;
}
TimingParams timing;
timing.mDuration.emplace(StickyTimeDuration::FromMilliseconds(duration));
timing.mDelay = TimeDuration::FromMilliseconds(delay);
timing.mIterations = 1.0;
timing.mDirection = dom::PlaybackDirection::Normal;
timing.mFill = dom::FillMode::Backwards;
TimingParams timing =
TimingParamsFromCSSParams(duration, delay,
1.0 /* iteration count */,
dom::PlaybackDirection::Normal,
dom::FillMode::Backwards);
// aElement is non-null here, so we emplace it directly.
Maybe<OwningAnimationTarget> target;