Bug 1242872 - Part 1.1: Move AnimationManager::BuildAnimations. r?dbaron
MozReview-Commit-ID: ENfBlECSiDP
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -631,58 +631,16 @@ CSSAnimationBuilder::Build(nsPresContext
OwningElementRef(*mTarget, mStyleContext->GetPseudoType()));
animation->SetEffect(effect);
return animation.forget();
}
void
-nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
- dom::Element* aTarget,
- dom::AnimationTimeline* aTimeline,
- AnimationPtrArray& aAnimations)
-{
- MOZ_ASSERT(aAnimations.IsEmpty(), "expect empty array");
-
- const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
-
- CSSAnimationBuilder builder(aStyleContext, aTarget);
-
- for (size_t animIdx = 0, animEnd = disp->mAnimationNameCount;
- animIdx != animEnd; ++animIdx) {
- const StyleAnimation& src = disp->mAnimations[animIdx];
-
- // CSS Animations whose animation-name does not match a @keyframes rule do
- // not generate animation events. This includes when the animation-name is
- // "none" which is represented by an empty name in the StyleAnimation.
- // Since such animations neither affect style nor dispatch events, we do
- // not generate a corresponding Animation for them.
- nsCSSKeyframesRule* rule =
- src.GetName().IsEmpty()
- ? nullptr
- : mPresContext->StyleSet()->KeyframesRuleForName(src.GetName());
- if (!rule) {
- continue;
- }
-
- RefPtr<CSSAnimation> dest = builder.Build(mPresContext, src, rule);
- dest->SetTimeline(aTimeline);
- dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
- aAnimations.AppendElement(dest);
-
- if (src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED) {
- dest->PauseFromStyle();
- } else {
- dest->PlayFromStyle();
- }
- }
-}
-
-void
CSSAnimationBuilder::BuildAnimationProperties(
nsPresContext* aPresContext,
const StyleAnimation& aSrc,
const nsCSSKeyframesRule* aRule,
InfallibleTArray<AnimationProperty>& aResult)
{
// While current drafts of css3-animations say that later keyframes
// with the same key entirely replace earlier ones (no cascading),
@@ -877,8 +835,50 @@ CSSAnimationBuilder::BuildSegment(Infall
if (tf->mType != nsTimingFunction::Type::Linear) {
ComputedTimingFunction computedTimingFunction;
computedTimingFunction.Init(*tf);
segment.mTimingFunction = Some(computedTimingFunction);
}
return true;
}
+
+void
+nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
+ dom::Element* aTarget,
+ dom::AnimationTimeline* aTimeline,
+ AnimationPtrArray& aAnimations)
+{
+ MOZ_ASSERT(aAnimations.IsEmpty(), "expect empty array");
+
+ const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
+
+ CSSAnimationBuilder builder(aStyleContext, aTarget);
+
+ for (size_t animIdx = 0, animEnd = disp->mAnimationNameCount;
+ animIdx != animEnd; ++animIdx) {
+ const StyleAnimation& src = disp->mAnimations[animIdx];
+
+ // CSS Animations whose animation-name does not match a @keyframes rule do
+ // not generate animation events. This includes when the animation-name is
+ // "none" which is represented by an empty name in the StyleAnimation.
+ // Since such animations neither affect style nor dispatch events, we do
+ // not generate a corresponding Animation for them.
+ nsCSSKeyframesRule* rule =
+ src.GetName().IsEmpty()
+ ? nullptr
+ : mPresContext->StyleSet()->KeyframesRuleForName(src.GetName());
+ if (!rule) {
+ continue;
+ }
+
+ RefPtr<CSSAnimation> dest = builder.Build(mPresContext, src, rule);
+ dest->SetTimeline(aTimeline);
+ dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
+ aAnimations.AppendElement(dest);
+
+ if (src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED) {
+ dest->PauseFromStyle();
+ } else {
+ dest->PlayFromStyle();
+ }
+ }
+}