Bug 1242872 - Part 6: Trigger a layer update explicitely when copying animation properties. r?birtles draft
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Sat, 13 Feb 2016 11:42:08 +0900
changeset 330826 79526245ab49ad57989f87ffc6d9c39454cdbd4b
parent 330825 b6996591aeef8a6743eab1384e5b47b41905941a
child 330827 5e64bed905777344bdd3a8ccc426c241688ed7e8
push id10851
push userbmo:hiikezoe@mozilla-japan.org
push dateSat, 13 Feb 2016 11:34:41 +0000
reviewersbirtles
bugs1242872
milestone47.0a1
Bug 1242872 - Part 6: Trigger a layer update explicitely when copying animation properties. r?birtles MozReview-Commit-ID: LnnNqsBDH0p
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
layout/style/nsAnimationManager.cpp
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -444,20 +444,27 @@ KeyframeEffectReadOnly::HasAnimationOfPr
   for (size_t i = 0; i < aPropertyCount; i++) {
     if (HasAnimationOfProperty(aProperties[i])) {
       return true;
     }
   }
   return false;
 }
 
-void
+bool
 KeyframeEffectReadOnly::UpdateProperties(
     const InfallibleTArray<AnimationProperty>& aProperties)
 {
+  // ANimationProperty::operator== does not compare mWinsInCascade and
+  // mIsRunningOnCompositor, we don't need to update anything here because
+  // we want to preserve
+  if (mProperties == aProperties) {
+    return false;
+  }
+
   nsCSSPropertySet winningInCascadeProperties;
   nsCSSPropertySet runningOnCompositorProperties;
 
   for (const AnimationProperty& property : mProperties) {
     if (property.mWinsInCascade) {
       winningInCascadeProperties.AddProperty(property.mProperty);
     }
     if (property.mIsRunningOnCompositor) {
@@ -468,16 +475,28 @@ KeyframeEffectReadOnly::UpdateProperties
   mProperties = aProperties;
 
   for (AnimationProperty& property : mProperties) {
     property.mWinsInCascade =
       winningInCascadeProperties.HasProperty(property.mProperty);
     property.mIsRunningOnCompositor =
       runningOnCompositorProperties.HasProperty(property.mProperty);
   }
+
+  if (mAnimation) {
+    nsPresContext* presContext = GetPresContext();
+    if (presContext) {
+      presContext->EffectCompositor()->
+        RequestRestyle(mTarget, mPseudoType,
+                       EffectCompositor::RestyleType::Layer,
+                       mAnimation->CascadeLevel());
+    }
+  }
+
+  return true;
 }
 
 void
 KeyframeEffectReadOnly::ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
                                      nsCSSPropertySet& aSetProperties)
 {
   ComputedTiming computedTiming = GetComputedTiming();
   mProgressOnLastCompose = computedTiming.mProgress;
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -280,18 +280,19 @@ public:
   const InfallibleTArray<AnimationProperty>& Properties() const {
     return mProperties;
   }
   InfallibleTArray<AnimationProperty>& Properties() {
     return mProperties;
   }
   // Updates the set of properties using the supplied list whilst preserving
   // the mWinsInCascade and mIsRunningOnCompositor state of any matching
-  // properties
-  void UpdateProperties(
+  // properties.
+  // Returns true if we updated anything in the properties.
+  bool UpdateProperties(
     const InfallibleTArray<AnimationProperty>& aProperties);
 
   // Updates |aStyleRule| with the animation values produced by this
   // AnimationEffect for the current time except any properties already
   // contained in |aSetProperties|.
   // Any updated properties are added to |aSetProperties|.
   void ComposeStyle(RefPtr<AnimValuesStyleRule>& aStyleRule,
                     nsCSSPropertySet& aSetProperties);
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -332,20 +332,20 @@ UpdateOldAnimationPropertiesWithNew(CSSA
   bool animationChanged = false;
 
   // Update the old from the new so we can keep the original object
   // identity (and any expando properties attached to it).
   if (aOld.GetEffect() && aNew.GetEffect()) {
     KeyframeEffectReadOnly* oldEffect = aOld.GetEffect();
     KeyframeEffectReadOnly* newEffect = aNew.GetEffect();
     animationChanged =
-      oldEffect->SpecifiedTiming() != newEffect->SpecifiedTiming() ||
-      oldEffect->Properties() != newEffect->Properties();
+      oldEffect->SpecifiedTiming() != newEffect->SpecifiedTiming();
     oldEffect->SetSpecifiedTiming(newEffect->SpecifiedTiming());
-    oldEffect->UpdateProperties(newEffect->Properties());
+    animationChanged |=
+      oldEffect->UpdateProperties(newEffect->Properties());
   }
 
   // Handle changes in play state. If the animation is idle, however,
   // changes to animation-play-state should *not* restart it.
   if (aOld.PlayState() != AnimationPlayState::Idle) {
     // CSSAnimation takes care of override behavior so that,
     // for example, if the author has called pause(), that will
     // override the animation-play-state.