Bug 1328787 - Part 12: Fill Gecko's Keyframe. r?heycam
MozReview-Commit-ID: 5QdUtFj9lK9
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -5,16 +5,17 @@
#include "nsAnimationManager.h"
#include "nsTransitionManager.h"
#include "mozilla/dom/CSSAnimationBinding.h"
#include "mozilla/EffectCompositor.h"
#include "mozilla/EffectSet.h"
#include "mozilla/MemoryReporting.h"
+#include "mozilla/ServoStyleSet.h"
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/dom/DocumentTimeline.h"
#include "mozilla/dom/KeyframeEffectReadOnly.h"
#include "nsPresContext.h"
#include "nsStyleSet.h"
#include "nsStyleChangeList.h"
#include "nsCSSRules.h"
@@ -603,27 +604,41 @@ ConvertTimingFunction(const nsTimingFunc
already_AddRefed<CSSAnimation>
CSSAnimationBuilder::Build(nsPresContext* aPresContext,
const StyleAnimation& aSrc,
uint64_t aAnimationIndex)
{
MOZ_ASSERT(aPresContext);
- nsCSSKeyframesRule* rule =
- aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
- if (!rule) {
- return nullptr;
+ nsTArray<Keyframe> keyframes;
+ if (aPresContext->StyleSet()->IsServo()) {
+ ServoStyleSet* styleSet = aPresContext->StyleSet()->AsServo();
+ MOZ_ASSERT(styleSet);
+ const ServoComputedValues* computedValues =
+ mStyleContext->StyleSource().AsServoComputedValues();
+ const nsTimingFunction& timingFunction = aSrc.GetTimingFunction();
+ if (!styleSet->FillKeyframesForName(aSrc.GetName(),
+ timingFunction,
+ computedValues,
+ keyframes)) {
+ return nullptr;
+ }
+ } else {
+ nsCSSKeyframesRule* rule =
+ aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
+ if (!rule) {
+ return nullptr;
+ }
+
+ keyframes = BuildAnimationFrames(aPresContext, aSrc, rule);
}
TimingParams timing = TimingParamsFrom(aSrc);
- nsTArray<Keyframe> keyframes =
- 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);
@@ -1092,20 +1107,16 @@ nsAnimationManager::BuildAnimations(nsSt
// 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");
-
RefPtr<CSSAnimation> dest =
builder.Build(mPresContext, src, static_cast<uint64_t>(animIdx));
if (!dest) {
continue;
}
dest->SetAnimationIndex(static_cast<uint64_t>(animIdx));
aAnimations.AppendElement(dest);