Bug 960465 patch 1 - Add parameter to skip animations work to ResolveStyleWithReplacement. r=birtles
authorL. David Baron <dbaron@dbaron.org>
Tue, 17 Feb 2015 11:15:00 +1300
changeset 229379 84e9b82dab4f4d85d15a6be0fa1c6038686b0036
parent 229378 4b118b959ffd1b18e434354d9a583d9b7c0aaca6
child 229380 3faad716fa52993cd88d4472ab806d7480b4d42f
push id11352
push userryanvm@gmail.com
push dateTue, 17 Feb 2015 19:29:37 +0000
treeherderfx-team@b6c56fab513d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs960465
milestone38.0a1
Bug 960465 patch 1 - Add parameter to skip animations work to ResolveStyleWithReplacement. r=birtles This is used in patch 2.
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1572,17 +1572,18 @@ nsStyleSet::RuleNodeWithReplacement(Elem
 
   return ruleWalker.CurrentNode();
 }
 
 already_AddRefed<nsStyleContext>
 nsStyleSet::ResolveStyleWithReplacement(Element* aElement,
                                         nsStyleContext* aNewParentContext,
                                         nsStyleContext* aOldStyleContext,
-                                        nsRestyleHint aReplacements)
+                                        nsRestyleHint aReplacements,
+                                        uint32_t aFlags)
 {
   nsRuleNode* ruleNode =
     RuleNodeWithReplacement(aElement, aOldStyleContext->RuleNode(),
                             aOldStyleContext->GetPseudoType(), aReplacements);
 
   nsRuleNode* visitedRuleNode = nullptr;
   nsStyleContext* oldStyleIfVisited = aOldStyleContext->GetStyleIfVisited();
   if (oldStyleIfVisited) {
@@ -1605,19 +1606,20 @@ nsStyleSet::ResolveStyleWithReplacement(
     // is visited.
     if (aOldStyleContext->RelevantLinkVisited()) {
       flags |= eIsVisitedLink;
     }
   }
 
   nsCSSPseudoElements::Type pseudoType = aOldStyleContext->GetPseudoType();
   Element* elementForAnimation = nullptr;
-  if (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
-      pseudoType == nsCSSPseudoElements::ePseudo_before ||
-      pseudoType == nsCSSPseudoElements::ePseudo_after) {
+  if (!(aFlags & eSkipStartingAnimations) &&
+      (pseudoType == nsCSSPseudoElements::ePseudo_NotPseudoElement ||
+       pseudoType == nsCSSPseudoElements::ePseudo_before ||
+       pseudoType == nsCSSPseudoElements::ePseudo_after)) {
     // We want to compute a correct elementForAnimation to pass in
     // because at this point the parameter is more than just the element
     // for animation; it's also used for the SetBodyTextColor call when
     // it's the body element.
     // However, we only want to set the flag to call CheckAnimationRule
     // if we're dealing with a replacement (such as style attribute
     // replacement) that could lead to the animation property changing,
     // and we explicitly do NOT want to call CheckAnimationRule when
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -128,21 +128,26 @@ class nsStyleSet
   //    for CSS transitions.)
   already_AddRefed<nsStyleContext>
   ResolveStyleByAddingRules(nsStyleContext* aBaseContext,
                             const nsCOMArray<nsIStyleRule> &aRules);
 
   // Resolve style by making replacements in the list of style rules as
   // described by aReplacements, but otherwise maintaining the status
   // quo.
+  enum { // flags for aFlags
+    // Skip starting CSS animations that result from the style.
+    eSkipStartingAnimations = (1<<0),
+  };
   already_AddRefed<nsStyleContext>
   ResolveStyleWithReplacement(mozilla::dom::Element* aElement,
                               nsStyleContext* aNewParentContext,
                               nsStyleContext* aOldStyleContext,
-                              nsRestyleHint aReplacements);
+                              nsRestyleHint aReplacements,
+                              uint32_t aFlags = 0);
 
   // 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.