Bug 1328787 - Part 2: Don't pass nsCSSKeyframesRule* to CSSAnimationBuild::Build. r?heycam
Because, in case of stylo, we don't have nsCSSKeyframesRule.
MozReview-Commit-ID: uWlrFihjbx
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -532,24 +532,22 @@ public:
, mTarget(aTarget)
, mCollection(aCollection)
{
MOZ_ASSERT(aStyleContext);
MOZ_ASSERT(aTarget);
mTimeline = mTarget->OwnerDoc()->Timeline();
}
- // Returns a new animation set up with given StyleAnimation and
- // keyframe rules.
+ // Returns a new animation set up with given StyleAnimation.
// Or returns an existing animation matching StyleAnimation's name updated
- // with the new StyleAnimation and keyframe rules.
+ // with the new StyleAnimation.
already_AddRefed<CSSAnimation>
Build(nsPresContext* aPresContext,
const StyleAnimation& aSrc,
- const nsCSSKeyframesRule* aRule,
uint64_t aAnimationIndex);
private:
nsTArray<Keyframe> BuildAnimationFrames(nsPresContext* aPresContext,
const StyleAnimation& aSrc,
const nsCSSKeyframesRule* aRule);
Maybe<ComputedTimingFunction> GetKeyframeTimingFunction(
nsPresContext* aPresContext,
@@ -601,26 +599,30 @@ private:
};
static Maybe<ComputedTimingFunction>
ConvertTimingFunction(const nsTimingFunction& aTimingFunction);
already_AddRefed<CSSAnimation>
CSSAnimationBuilder::Build(nsPresContext* aPresContext,
const StyleAnimation& aSrc,
- const nsCSSKeyframesRule* aRule,
uint64_t aAnimationIndex)
{
MOZ_ASSERT(aPresContext);
- MOZ_ASSERT(aRule);
+
+ nsCSSKeyframesRule* rule =
+ aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
+ if (!rule) {
+ return nullptr;
+ }
TimingParams timing = TimingParamsFrom(aSrc);
nsTArray<Keyframe> keyframes =
- BuildAnimationFrames(aPresContext, aSrc, aRule);
+ BuildAnimationFrames(aPresContext, aSrc, rule);
bool isStylePaused =
aSrc.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
// Find the matching animation with animation name in the old list
// of animations and remove the matched animation from the list.
RefPtr<CSSAnimation> oldAnim =
PopExistingAnimation(aSrc.GetName(), mCollection);
@@ -1086,26 +1088,27 @@ nsAnimationManager::BuildAnimations(nsSt
for (size_t animIdx = disp->mAnimationNameCount; animIdx-- != 0;) {
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 CSSAnimation for them.
+ if (src.GetName().IsEmpty()) {
+ continue;
+ }
+
MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
"ServoStyleSet should not use nsAnimationManager for "
"animations");
- nsCSSKeyframesRule* rule =
- src.GetName().IsEmpty()
- ? nullptr
- : mPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(src.GetName());
- if (!rule) {
+
+ RefPtr<CSSAnimation> dest =
+ builder.Build(mPresContext, src, static_cast<uint64_t>(animIdx));
+ if (!dest) {
continue;
}
- RefPtr<CSSAnimation> dest =
- builder.Build(mPresContext, src, rule, static_cast<uint64_t>(animIdx));
dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
aAnimations.AppendElement(dest);
}
}