Bug 1073336 part 14a - Update animation generation when changing animations via the API; r=dbaron
authorBrian Birtles <birtles@gmail.com>
Mon, 17 Nov 2014 13:45:59 +0900
changeset 240288 3ab8b0f5f2c7e7aa0ab72e622aa1b74b001583d5
parent 240287 52a3c36054d602faf5ce1f84447e26efac7a78ca
child 240289 3c5e1c6d06c3c59d9a1a61028f41ec9c774c3679
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1073336
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1073336 part 14a - Update animation generation when changing animations via the API; r=dbaron
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
layout/style/AnimationCommon.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1555,17 +1555,17 @@ RestyleManager::ProcessPendingRestyles()
 
   // Before we process any restyles, we need to ensure that style
   // resulting from any throttled animations (animations that we're
   // running entirely on the compositor thread) is up-to-date, so that
   // if any style changes we cause trigger transitions, we have the
   // correct old style for starting the transition.
   if (nsLayoutUtils::AreAsyncAnimationsEnabled() &&
       mPendingRestyles.Count() > 0) {
-    ++mAnimationGeneration;
+    IncrementAnimationGeneration();
     UpdateOnlyAnimationStyles();
   }
 
   // Until we get rid of these phases in bug 960465, we need to skip
   // animation restyles during the non-animation phase, and post
   // animation restyles so that we restyle those elements again in the
   // animation phase.
   mSkipAnimationRules = true;
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -87,16 +87,24 @@ public:
   // Get an integer that increments every time there is a style change
   // as a result of a change to the :hover content state.
   uint32_t GetHoverGeneration() const { return mHoverGeneration; }
 
   // Get a counter that increments on every style change, that we use to
   // track whether off-main-thread animations are up-to-date.
   uint64_t GetAnimationGeneration() const { return mAnimationGeneration; }
 
+  // Update the animation generation count to mark that animation state
+  // has changed.
+  //
+  // This is normally performed automatically by ProcessPendingRestyles
+  // but it is also called when we have out-of-band changes to animations
+  // such as changes made through the Web Animations API.
+  void IncrementAnimationGeneration() { ++mAnimationGeneration; }
+
   // Whether rule matching should skip styles associated with animation
   bool SkipAnimationRules() const {
     MOZ_ASSERT(mSkipAnimationRules || !mPostAnimationRestyles,
                "inconsistent state");
     return mSkipAnimationRules;
   }
 
   // Whether rule matching should post animation restyles when it skips
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -226,16 +226,18 @@ CommonAnimationManager::AddStyleUpdatesT
 }
 
 void
 CommonAnimationManager::NotifyCollectionUpdated(AnimationPlayerCollection&
                                                   aCollection)
 {
   CheckNeedsRefresh();
   mPresContext->ClearLastStyleUpdateForAllAnimations();
+  mPresContext->RestyleManager()->IncrementAnimationGeneration();
+  aCollection.UpdateAnimationGeneration(mPresContext);
   aCollection.PostRestyleForAnimation(mPresContext);
 }
 
 /* static */ bool
 CommonAnimationManager::ExtractComputedValueForTransition(
                           nsCSSProperty aProperty,
                           nsStyleContext* aStyleContext,
                           StyleAnimationValue& aComputedValue)