Bug 1228229 part 6 - Mark the animation cascade results as dirty when an effect goes in or out of being "in effect"; r=dbaron
authorBrian Birtles <birtles@gmail.com>
Wed, 06 Jan 2016 11:04:05 +0900
changeset 319232 9e2e1114aece2cfb745f62d4b061798c8264d112
parent 319231 04b47b12e54655b52b9d5e56e30084b3fa8683f6
child 319233 4974afc6e1a5e578b9a82e03f3ae6efe71d79c77
push id8999
push userbenj@benj.me
push dateWed, 06 Jan 2016 10:10:00 +0000
reviewersdbaron
bugs1228229
milestone46.0a1
Bug 1228229 part 6 - Mark the animation cascade results as dirty when an effect goes in or out of being "in effect"; r=dbaron This patch implements "case 2" described in the commit message from part 4 of this patch series.
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -89,16 +89,17 @@ KeyframeEffectReadOnly::KeyframeEffectRe
   nsIDocument* aDocument,
   Element* aTarget,
   nsCSSPseudoElements::Type aPseudoType,
   const AnimationTiming& aTiming)
   : AnimationEffectReadOnly(aDocument)
   , mTarget(aTarget)
   , mTiming(aTiming)
   , mPseudoType(aPseudoType)
+  , mInEffectOnLastAnimationTimingUpdate(false)
 {
   MOZ_ASSERT(aTarget, "null animation target is not yet supported");
 }
 
 JSObject*
 KeyframeEffectReadOnly::WrapObject(JSContext* aCx,
                                    JS::Handle<JSObject*> aGivenProto)
 {
@@ -142,16 +143,29 @@ KeyframeEffectReadOnly::NotifyAnimationT
   // will not be included in the set of candidate effects for running on
   // the compositor and hence they won't have their compositor status
   // updated. As a result, we need to make sure we clear their compositor
   // status here.
   bool isRelevant = mAnimation && mAnimation->IsRelevant();
   if (!isRelevant) {
     ResetIsRunningOnCompositor();
   }
+
+  // Detect changes to "in effect" status since we need to recalculate the
+  // animation cascade for this element whenever that changes.
+  bool inEffect = IsInEffect();
+  if (inEffect != mInEffectOnLastAnimationTimingUpdate) {
+    if (mTarget) {
+      EffectSet* effectSet = EffectSet::GetEffectSet(mTarget, mPseudoType);
+      if (effectSet) {
+        effectSet->MarkCascadeNeedsUpdate();
+      }
+    }
+    mInEffectOnLastAnimationTimingUpdate = inEffect;
+  }
 }
 
 Nullable<TimeDuration>
 KeyframeEffectReadOnly::GetLocalTime() const
 {
   // Since the *animation* start time is currently always zero, the local
   // time is equal to the parent time.
   Nullable<TimeDuration> result;
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -344,16 +344,20 @@ protected:
   nsCOMPtr<Element> mTarget;
   RefPtr<Animation> mAnimation;
 
   AnimationTiming mTiming;
   nsCSSPseudoElements::Type mPseudoType;
 
   InfallibleTArray<AnimationProperty> mProperties;
 
+  // We need to track when we go to or from being "in effect" since
+  // we need to re-evaluate the cascade of animations when that changes.
+  bool mInEffectOnLastAnimationTimingUpdate;
+
 private:
   nsIFrame* GetAnimationFrame() const;
 
   bool CanThrottleTransformChanges(nsIFrame& aFrame) const;
 
   // Returns true unless Gecko limitations prevent performing transform
   // animations for |aFrame|. Any limitations that are encountered are
   // logged using |aContent| to describe the affected content.