Bug 1340322 - Part 13: Update CSS Animations with servo's computed values. r?birtles
MozReview-Commit-ID: B7uSH7wrx3b
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -163,23 +163,29 @@ ServoStyleSet::GetContext(already_AddRef
// Ignore animations for print or print preview, and for elements
// that are not attached to the document tree.
if (mPresContext->IsDynamic() &&
aElementForAnimation &&
aElementForAnimation->IsInComposedDoc()) {
// Update/build CSS animations in the case where animation properties are
// changed.
- // FIXME: This isn't right place to update CSS animations. We should do it
- // , presumably, in cascade_node() in servo side and process the initial
- // restyle there too.
- // To do that we need to make updating CSS animations process independent
- // from nsStyleContext. Also we need to make the process thread safe.
- mPresContext->AnimationManager()->UpdateAnimations(result,
- aElementForAnimation);
+ // FIXME: Bug 1341985: This isn't right place to update CSS animations.
+ // We should do it in a SequentialTask and trigger the second traversal for
+ // the animation's restyle after the SequentialTask.
+ const ServoComputedValues* currentStyle =
+ result->StyleSource().AsServoComputedValues();
+ const ServoComputedValues* parentStyle =
+ result->GetParent()
+ ? result->GetParent()->StyleSource().AsServoComputedValues()
+ : nullptr;
+ mPresContext->AnimationManager()->UpdateAnimations(aElementForAnimation,
+ aPseudoTag,
+ currentStyle,
+ parentStyle);
}
return result.forget();
}
void
ServoStyleSet::ResolveMappedAttrDeclarationBlocks()
{
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -635,38 +635,26 @@ BuildAnimation(nsPresContext* aPresConte
}
bool
GeckoCSSAnimationBuilder::BuildKeyframes(nsPresContext* aPresContext,
const StyleAnimation& aSrc,
nsTArray<Keyframe>& aKeyframes)
{
MOZ_ASSERT(aPresContext);
+ MOZ_ASSERT(aPresContext->StyleSet()->IsGecko());
- 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,
- aKeyframes)) {
- return false;
- }
- } else {
- nsCSSKeyframesRule* rule =
- aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
- if (!rule) {
- return false;
- }
- aKeyframes = BuildAnimationFrames(aPresContext, aSrc, rule);
+ nsCSSKeyframesRule* rule =
+ aPresContext->StyleSet()->AsGecko()->KeyframesRuleForName(aSrc.GetName());
+ if (!rule) {
+ return false;
}
+ aKeyframes = BuildAnimationFrames(aPresContext, aSrc, rule);
+
return true;
}
nsTArray<Keyframe>
GeckoCSSAnimationBuilder::BuildAnimationFrames(nsPresContext* aPresContext,
const StyleAnimation& aSrc,
const nsCSSKeyframesRule* aRule)
{