Bug 960465 patch 2 - Add method to return a modified version of a style context, with all or part of the animation data removed. r=birtles
authorL. David Baron <dbaron@dbaron.org>
Tue, 17 Feb 2015 11:15:01 +1300
changeset 256493 3faad716fa52993cd88d4472ab806d7480b4d42f
parent 256492 84e9b82dab4f4d85d15a6be0fa1c6038686b0036
child 256494 d5fa940bfd9ccb26df75b4a572094a640b7c90c5
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs960465
milestone38.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 960465 patch 2 - Add method to return a modified version of a style context, with all or part of the animation data removed. r=birtles This is used in patch 3.
layout/base/RestyleManager.h
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -109,25 +109,33 @@ public:
 
   // Whether rule matching should skip styles associated with animation
   bool SkipAnimationRules() const {
     MOZ_ASSERT(mSkipAnimationRules || !mPostAnimationRestyles,
                "inconsistent state");
     return mSkipAnimationRules;
   }
 
+  void SetSkipAnimationRules(bool aSkipAnimationRules) {
+    mSkipAnimationRules = aSkipAnimationRules;
+  }
+
   // Whether rule matching should post animation restyles when it skips
   // styles associated with animation.  Only true when
   // SkipAnimationRules() is also true.
   bool PostAnimationRestyles() const {
     MOZ_ASSERT(mSkipAnimationRules || !mPostAnimationRestyles,
                "inconsistent state");
     return mPostAnimationRestyles;
   }
 
+  void SetPostAnimationRestyles(bool aPostAnimationRestyles) {
+    mPostAnimationRestyles = aPostAnimationRestyles;
+  }
+
   // Whether we're currently in the animation phase of restyle
   // processing (to be eliminated in bug 960465)
   bool IsProcessingAnimationStyleChange() const {
     return mIsProcessingAnimationStyleChange;
   }
 
   /**
    * Reparent the style contexts of this frame subtree.  The parent frame of
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1644,16 +1644,38 @@ nsStyleSet::ResolveStyleWithReplacement(
     flags |= eSkipParentDisplayBasedStyleFixup;
   }
 
   return GetContext(aNewParentContext, ruleNode, visitedRuleNode,
                     aOldStyleContext->GetPseudo(), pseudoType,
                     elementForAnimation, flags);
 }
 
+already_AddRefed<nsStyleContext>
+nsStyleSet::ResolveStyleWithoutAnimation(dom::Element* aTarget,
+                                         nsStyleContext* aStyleContext,
+                                         nsRestyleHint aWhichToRemove)
+{
+  RestyleManager* restyleManager = PresContext()->RestyleManager();
+
+  bool oldSkipAnimationRules = restyleManager->SkipAnimationRules();
+  restyleManager->SetSkipAnimationRules(true);
+  bool oldPostAnimationRestyles = restyleManager->PostAnimationRestyles();
+  restyleManager->SetPostAnimationRestyles(false);
+
+  nsRefPtr<nsStyleContext> result =
+    ResolveStyleWithReplacement(aTarget, aStyleContext->GetParent(),
+                                aStyleContext, aWhichToRemove,
+                                eSkipStartingAnimations);
+
+  restyleManager->SetPostAnimationRestyles(oldPostAnimationRestyles);
+  restyleManager->SetSkipAnimationRules(oldSkipAnimationRules);
+
+  return result.forget();
+}
 
 already_AddRefed<nsStyleContext>
 nsStyleSet::ResolveStyleForNonElement(nsStyleContext* aParentContext)
 {
   return GetContext(aParentContext, mRuleTree, nullptr,
                     nsCSSAnonBoxes::mozNonElement,
                     nsCSSPseudoElements::ePseudo_AnonBox, nullptr,
                     eNoFlags);
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -139,16 +139,25 @@ class nsStyleSet
   };
   already_AddRefed<nsStyleContext>
   ResolveStyleWithReplacement(mozilla::dom::Element* aElement,
                               nsStyleContext* aNewParentContext,
                               nsStyleContext* aOldStyleContext,
                               nsRestyleHint aReplacements,
                               uint32_t aFlags = 0);
 
+  // Resolve style by returning a style context with the specified
+  // animation data removed.  It is allowable to remove all animation
+  // data with eRestyle_ChangeAnimationPhase, or by using any other
+  // hints that are allowed by ResolveStyleWithReplacement.
+  already_AddRefed<nsStyleContext>
+    ResolveStyleWithoutAnimation(mozilla::dom::Element* aElement,
+                                 nsStyleContext* aStyleContext,
+                                 nsRestyleHint aWhichToRemove);
+
   // Get a style context for a non-element (which no rules will match),
   // such as text nodes, placeholder frames, and the nsFirstLetterFrame
   // for everything after the first letter.
   //
   // Perhaps this should go away and we shouldn't even create style
   // contexts for such content nodes.  However, not doing any rule
   // matching for them is a first step.
   already_AddRefed<nsStyleContext>