Backed out changeset 4ed63d7489fe (bug 1087541) for b2g mochitest-9 failures
authorWes Kocher <wkocher@mozilla.com>
Thu, 30 Oct 2014 14:56:03 -0700
changeset 213253 7fa64f4f16a84237392dab7478e315252b5190fa
parent 213252 5f1bda02950aa0a585646f96b0057b779f27235a
child 213254 f41055343fd709788fb159ac894d9b6513d3d06e
push id27745
push usercbook@mozilla.com
push dateFri, 31 Oct 2014 13:09:12 +0000
treeherdermozilla-central@6bd2071b373f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1087541
milestone36.0a1
backs out4ed63d7489fe03bdee9bbe41abb5cc6183db61b2
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
Backed out changeset 4ed63d7489fe (bug 1087541) for b2g mochitest-9 failures
layout/style/nsAnimationManager.h
layout/style/nsStyleSet.cpp
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -219,18 +219,16 @@ public:
       DoDispatchEvents();
     }
   }
 
   mozilla::AnimationPlayerCollection*
   GetAnimationPlayers(mozilla::dom::Element *aElement,
                       nsCSSPseudoElements::Type aPseudoType,
                       bool aCreateIfNeeded);
-  nsIStyleRule* GetAnimationRule(mozilla::dom::Element* aElement,
-                                 nsCSSPseudoElements::Type aPseudoType);
 
 protected:
   virtual void ElementCollectionRemoved() MOZ_OVERRIDE
   {
     CheckNeedsRefresh();
   }
   virtual void
   AddElementCollection(mozilla::AnimationPlayerCollection* aData) MOZ_OVERRIDE;
@@ -247,16 +245,18 @@ private:
                        mozilla::AnimationPlayerPtrArray& aAnimations);
   bool BuildSegment(InfallibleTArray<mozilla::AnimationPropertySegment>&
                       aSegments,
                     nsCSSProperty aProperty,
                     const mozilla::StyleAnimation& aAnimation,
                     float aFromKey, nsStyleContext* aFromContext,
                     mozilla::css::Declaration* aFromDeclaration,
                     float aToKey, nsStyleContext* aToContext);
+  nsIStyleRule* GetAnimationRule(mozilla::dom::Element* aElement,
+                                 nsCSSPseudoElements::Type aPseudoType);
 
   // The guts of DispatchEvents
   void DoDispatchEvents();
 
   mozilla::EventArray mPendingEvents;
 
   bool mObservingRefreshDriver;
 };
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1362,23 +1362,30 @@ nsStyleSet::RuleNodeWithReplacement(Elem
                                         eRestyle_ChangeAnimationPhase |
                                         eRestyle_Force |
                                         eRestyle_ForceDescendants)),
                     // FIXME: Once bug 979133 lands we'll have a better
                     // way to print these.
                     nsPrintfCString("unexpected replacement bits 0x%lX",
                                     uint32_t(aReplacements)).get());
 
+  bool skipAnimationRules = false;
+  bool postAnimationRestyles = false;
+
   // If we're changing animation phase, we have to reconsider what rules
   // are in these four levels.
   if (aReplacements & eRestyle_ChangeAnimationPhase) {
     aReplacements |= eRestyle_CSSTransitions |
                      eRestyle_CSSAnimations |
                      eRestyle_SVGAttrAnimations |
                      eRestyle_StyleAttribute;
+
+    RestyleManager* restyleManager = PresContext()->RestyleManager();
+    skipAnimationRules = restyleManager->SkipAnimationRules();
+    postAnimationRestyles = restyleManager->PostAnimationRestyles();
   }
 
   // FIXME (perf): This should probably not rebuild the whole path, but
   // only the path from the last change in the rule tree, like
   // ReplaceAnimationRule in nsStyleSet.cpp does.  (That could then
   // perhaps share this code, too?)
   // But if we do that, we'll need to pass whether we are rebuilding the
   // rule tree from ElementRestyler::RestyleSelf to avoid taking that
@@ -1409,33 +1416,63 @@ nsStyleSet::RuleNodeWithReplacement(Elem
     bool doReplace = level->mLevelReplacementHint & aReplacements;
 
     ruleWalker.SetLevel(level->mLevel, level->mIsImportant,
                         level->mCheckForImportantRules && doReplace);
 
     if (doReplace) {
       switch (level->mLevelReplacementHint) {
         case eRestyle_CSSAnimations: {
-          if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
-              aPseudoType == nsCSSPseudoElements::ePseudo_before ||
-              aPseudoType == nsCSSPseudoElements::ePseudo_after) {
-            nsIStyleRule* rule = PresContext()->AnimationManager()->
-              GetAnimationRule(aElement, aPseudoType);
-            if (rule) {
-              ruleWalker.ForwardOnPossiblyCSSRule(rule);
+          // FIXME: This should probably be more similar to what
+          // FileRules does; this feels like too much poking into the
+          // internals of nsAnimationManager.
+          nsPresContext* presContext = PresContext();
+          nsAnimationManager* animationManager =
+            presContext->AnimationManager();
+          AnimationPlayerCollection* collection =
+            animationManager->GetAnimationPlayers(aElement, aPseudoType, false);
+
+          if (collection) {
+            if (skipAnimationRules) {
+              if (postAnimationRestyles) {
+                collection->PostRestyleForAnimation(presContext);
+              }
+            } else {
+              animationManager->UpdateStyleAndEvents(
+                collection, PresContext()->RefreshDriver()->MostRecentRefresh(),
+                EnsureStyleRule_IsNotThrottled);
+              if (collection->mStyleRule) {
+                ruleWalker.ForwardOnPossiblyCSSRule(collection->mStyleRule);
+              }
             }
           }
           break;
         }
         case eRestyle_CSSTransitions: {
-          if (aPseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
-              aPseudoType == nsCSSPseudoElements::ePseudo_before ||
-              aPseudoType == nsCSSPseudoElements::ePseudo_after) {
-            PresContext()->TransitionManager()->
-              WalkTransitionRule(aElement, aPseudoType, &ruleWalker);
+          // FIXME: This should probably be more similar to what
+          // FileRules does; this feels like too much poking into the
+          // internals of nsTransitionManager.
+          nsPresContext* presContext = PresContext();
+          AnimationPlayerCollection* collection =
+            presContext->TransitionManager()->GetElementTransitions(
+              aElement, aPseudoType, false);
+
+          if (collection) {
+            if (skipAnimationRules) {
+              if (postAnimationRestyles) {
+                collection->PostRestyleForAnimation(presContext);
+              }
+            } else {
+              collection->EnsureStyleRuleFor(
+                presContext->RefreshDriver()->MostRecentRefresh(),
+                EnsureStyleRule_IsNotThrottled);
+              if (collection->mStyleRule) {
+                ruleWalker.ForwardOnPossiblyCSSRule(collection->mStyleRule);
+              }
+            }
           }
           break;
         }
         case eRestyle_SVGAttrAnimations: {
           MOZ_ASSERT(aReplacements & eRestyle_ChangeAnimationPhase,
                      "don't know how to do this level without phase change");
 
           SVGAttrAnimationRuleProcessor* ruleProcessor =
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -621,77 +621,75 @@ nsTransitionManager::GetElementTransitio
   return collection;
 }
 
 /*
  * nsIStyleRuleProcessor implementation
  */
 
 void
-nsTransitionManager::WalkTransitionRule(dom::Element* aElement,
-                                        nsCSSPseudoElements::Type aPseudoType,
-                                        nsRuleWalker* aRuleWalker)
+nsTransitionManager::WalkTransitionRule(
+  ElementDependentRuleProcessorData* aData,
+  nsCSSPseudoElements::Type aPseudoType)
 {
   AnimationPlayerCollection* collection =
-    GetElementTransitions(aElement, aPseudoType, false);
+    GetElementTransitions(aData->mElement, aPseudoType, false);
   if (!collection) {
     return;
   }
 
   if (!mPresContext->IsDynamic()) {
     // For print or print preview, ignore animations.
     return;
   }
 
-  RestyleManager* restyleManager = mPresContext->RestyleManager();
+  RestyleManager* restyleManager = aData->mPresContext->RestyleManager();
   if (restyleManager->SkipAnimationRules()) {
     // If we're processing a normal style change rather than one from
     // animation, don't add the transition rule.  This allows us to
     // compute the new style value rather than having the transition
     // override it, so that we can start transitioning differently.
 
     if (restyleManager->PostAnimationRestyles()) {
       // We need to immediately restyle with animation
       // after doing this.
       collection->PostRestyleForAnimation(mPresContext);
     }
     return;
   }
 
   collection->mNeedsRefreshes = true;
   collection->EnsureStyleRuleFor(
-    mPresContext->RefreshDriver()->MostRecentRefresh(),
+    aData->mPresContext->RefreshDriver()->MostRecentRefresh(),
     EnsureStyleRule_IsNotThrottled);
 
   if (collection->mStyleRule) {
-    aRuleWalker->Forward(collection->mStyleRule);
+    aData->mRuleWalker->Forward(collection->mStyleRule);
   }
 }
 
 /* virtual */ void
 nsTransitionManager::RulesMatching(ElementRuleProcessorData* aData)
 {
   NS_ABORT_IF_FALSE(aData->mPresContext == mPresContext,
                     "pres context mismatch");
-  WalkTransitionRule(aData->mElement,
-                     nsCSSPseudoElements::ePseudo_NotPseudoElement,
-                     aData->mRuleWalker);
+  WalkTransitionRule(aData,
+                     nsCSSPseudoElements::ePseudo_NotPseudoElement);
 }
 
 /* virtual */ void
 nsTransitionManager::RulesMatching(PseudoElementRuleProcessorData* aData)
 {
   NS_ABORT_IF_FALSE(aData->mPresContext == mPresContext,
                     "pres context mismatch");
 
   // Note:  If we're the only thing keeping a pseudo-element frame alive
   // (per ProbePseudoStyleContext), we still want to keep it alive, so
   // this is ok.
-  WalkTransitionRule(aData->mElement, aData->mPseudoType,
-                     aData->mRuleWalker);
+  WalkTransitionRule(aData, aData->mPseudoType);
 }
 
 /* virtual */ void
 nsTransitionManager::RulesMatching(AnonBoxRuleProcessorData* aData)
 {
 }
 
 #ifdef MOZ_XUL
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -143,32 +143,31 @@ public:
   virtual void WillRefresh(mozilla::TimeStamp aTime) MOZ_OVERRIDE;
 
   void FlushTransitions(FlushFlags aFlags);
 
   AnimationPlayerCollection* GetElementTransitions(
     mozilla::dom::Element *aElement,
     nsCSSPseudoElements::Type aPseudoType,
     bool aCreateIfNeeded);
-  void WalkTransitionRule(mozilla::dom::Element* aElement,
-                          nsCSSPseudoElements::Type aPseudoType,
-                          nsRuleWalker* aRuleWalker);
 
 protected:
   virtual void ElementCollectionRemoved() MOZ_OVERRIDE;
   virtual void
   AddElementCollection(AnimationPlayerCollection* aCollection) MOZ_OVERRIDE;
 
 private:
   void
   ConsiderStartingTransition(nsCSSProperty aProperty,
                              const mozilla::StyleTransition& aTransition,
                              mozilla::dom::Element* aElement,
                              AnimationPlayerCollection*& aElementTransitions,
                              nsStyleContext* aOldStyleContext,
                              nsStyleContext* aNewStyleContext,
                              bool* aStartedAny,
                              nsCSSPropertySet* aWhichStarted);
+  void WalkTransitionRule(ElementDependentRuleProcessorData* aData,
+                          nsCSSPseudoElements::Type aPseudoType);
 
   bool mInAnimationOnlyStyleUpdate;
 };
 
 #endif /* !defined(nsTransitionManager_h_) */