Bug 1260983 - Update animation properties when the style context changes; r?heycam
MozReview-Commit-ID: L4ugcD7BxNX
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -217,16 +217,31 @@ EffectCompositor::PostRestyleForThrottle
iter.Key().mPseudoType,
cascadeLevel);
postedRestyle = true;
}
}
}
void
+EffectCompositor::UpdateEffectProperties(nsStyleContext* aStyleContext,
+ dom::Element* aElement,
+ CSSPseudoElementType aPseudoType)
+{
+ EffectSet* effectSet = EffectSet::GetEffectSet(aElement, aPseudoType);
+ if (!effectSet) {
+ return;
+ }
+
+ for (KeyframeEffectReadOnly* effect : *effectSet) {
+ effect->UpdateProperties(aStyleContext);
+ }
+}
+
+void
EffectCompositor::MaybeUpdateAnimationRule(dom::Element* aElement,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel)
{
// First update cascade results since that may cause some elements to
// be marked as needing a restyle.
MaybeUpdateCascadeResults(aElement, aPseudoType);
--- a/dom/animation/EffectCompositor.h
+++ b/dom/animation/EffectCompositor.h
@@ -106,16 +106,24 @@ public:
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);
// Posts an animation restyle for any elements whose animation style rule
// is out of date but for which an animation restyle has not yet been
// posted because updates on the main thread are throttled.
void PostRestyleForThrottledAnimations();
+ // Called when the style context on the specified (pseudo-) element might
+ // have changed so that any context-sensitive values stored within
+ // animation effects (e.g. em-based endpoints used in keyframe effects)
+ // can be re-resolved to computed values.
+ void UpdateEffectProperties(nsStyleContext* aStyleContext,
+ dom::Element* aElement,
+ CSSPseudoElementType aPseudoType);
+
// Updates the animation rule stored on the EffectSet for the
// specified (pseudo-)element for cascade level |aLevel|.
// If the animation rule is not marked as needing an update,
// no work is done.
void MaybeUpdateAnimationRule(dom::Element* aElement,
CSSPseudoElementType aPseudoType,
CascadeLevel aCascadeLevel);
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -974,16 +974,18 @@ nsStyleSet::GetContext(nsStyleContext* a
// Ignore animations for print or print preview, and for elements
// that are not attached to the document tree.
if (PresContext()->IsDynamic() &&
aElementForAnimation->IsInComposedDoc()) {
// Update CSS animations in case the animation-name has just changed.
PresContext()->AnimationManager()->UpdateAnimations(result,
aElementForAnimation);
+ PresContext()->EffectCompositor()->UpdateEffectProperties(
+ result, aElementForAnimation, result->GetPseudoType());
animRule = PresContext()->EffectCompositor()->
GetAnimationRule(aElementForAnimation,
result->GetPseudoType(),
EffectCompositor::CascadeLevel::Animations);
}
MOZ_ASSERT(result->RuleNode() == aRuleNode,