Bug 1260983 - Update animation properties when the style context changes; r?heycam draft
authorBrian Birtles <birtles@gmail.com>
Fri, 01 Apr 2016 09:31:51 +0900
changeset 346447 e24407917b239e31560910cb91d0e4e65bfdcfed
parent 346373 841e2b505d7d137e242f605e1deb1069484f768b
child 346448 0a49d850c4407ceebe1ffe953370af91b545275a
push id14377
push userbbirtles@mozilla.com
push dateFri, 01 Apr 2016 03:11:29 +0000
reviewersheycam
bugs1260983
milestone48.0a1
Bug 1260983 - Update animation properties when the style context changes; r?heycam MozReview-Commit-ID: L4ugcD7BxNX
dom/animation/EffectCompositor.cpp
dom/animation/EffectCompositor.h
layout/style/nsStyleSet.cpp
--- 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,