Bug 1330190 - Part 3: Add ResolvePseudoElementStyleWithoutAnimation. ?heycam r=heycam
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 16 Jan 2017 16:57:16 +0900
changeset 374539 69a81a6bb0bde892cd1e91dd069e0fdb6ece32f4
parent 374538 b418519ea4d0693f1a86d869d2be1afa494a00b4
child 374540 0a9984a0cc54c20cb54b8e07c9a84aa72b83e501
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1330190
milestone53.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 1330190 - Part 3: Add ResolvePseudoElementStyleWithoutAnimation. ?heycam r=heycam This has the same functionality of ResolveStyleWithoutAnimation() but for pseudo element instead. MozReview-Commit-ID: I34lrfqdtuP
layout/style/nsStyleSet.cpp
layout/style/nsStyleSet.h
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -1853,20 +1853,22 @@ void
 nsStyleSet::WalkDisableTextZoomRule(Element* aElement, nsRuleWalker* aRuleWalker)
 {
   aRuleWalker->SetLevel(SheetType::Agent, false, false);
   if (aElement->IsSVGElement(nsGkAtoms::text))
     aRuleWalker->Forward(mDisableTextZoomStyleRule);
 }
 
 already_AddRefed<nsStyleContext>
-nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
-                                      CSSPseudoElementType aType,
-                                      nsStyleContext* aParentContext,
-                                      Element* aPseudoElement)
+nsStyleSet::ResolvePseudoElementStyleInternal(
+  Element* aParentElement,
+  CSSPseudoElementType aType,
+  nsStyleContext* aParentContext,
+  Element* aPseudoElement,
+  AnimationFlag aAnimationFlag)
 {
   NS_ENSURE_FALSE(mInShutdown, nullptr);
 
   NS_ASSERTION(aType < CSSPseudoElementType::Count,
                "must have pseudo element type");
   NS_ASSERTION(aParentElement, "Must have parent element");
 
   nsRuleWalker ruleWalker(mRuleTree, mAuthorStyleDisabled);
@@ -1892,31 +1894,60 @@ nsStyleSet::ResolvePseudoElementStyle(El
     visitedRuleNode = ruleWalker.CurrentNode();
   }
 
   // For pseudos, |data.IsLink()| being true means that
   // our parent node is a link.
   uint32_t flags = eNoFlags;
   if (aType == CSSPseudoElementType::before ||
       aType == CSSPseudoElementType::after) {
-    flags |= eDoAnimation;
+    if (aAnimationFlag == eWithAnimation) {
+      flags |= eDoAnimation;
+    }
   } else {
     // Flex and grid containers don't expect to have any pseudo-element children
     // aside from ::before and ::after.  So if we have such a child, we're not
     // actually in a flex/grid container, and we should skip flex/grid item
     // style fixup.
     flags |= eSkipParentDisplayBasedStyleFixup;
   }
 
   return GetContext(aParentContext, ruleNode, visitedRuleNode,
                     nsCSSPseudoElements::GetPseudoAtom(aType), aType,
                     aParentElement, flags);
 }
 
 already_AddRefed<nsStyleContext>
+nsStyleSet::ResolvePseudoElementStyle(Element* aParentElement,
+                                      CSSPseudoElementType aType,
+                                      nsStyleContext* aParentContext,
+                                      Element* aPseudoElement)
+{
+  return ResolvePseudoElementStyleInternal(aParentElement,
+                                           aType,
+                                           aParentContext,
+                                           aPseudoElement,
+                                           eWithAnimation);
+}
+
+already_AddRefed<nsStyleContext>
+nsStyleSet::ResolvePseudoElementStyleWithoutAnimation(
+  Element* aParentElement,
+  CSSPseudoElementType aType,
+  nsStyleContext* aParentContext,
+  Element* aPseudoElement)
+{
+  return ResolvePseudoElementStyleInternal(aParentElement,
+                                           aType,
+                                           aParentContext,
+                                           aPseudoElement,
+                                           eWithoutAnimation);
+}
+
+already_AddRefed<nsStyleContext>
 nsStyleSet::ProbePseudoElementStyle(Element* aParentElement,
                                     CSSPseudoElementType aType,
                                     nsStyleContext* aParentContext)
 {
   TreeMatchContext treeContext(true, nsRuleWalker::eRelevantLinkUnvisited,
                                aParentElement->OwnerDoc());
   InitStyleScopes(treeContext, aParentElement);
   return ProbePseudoElementStyle(aParentElement, aType, aParentContext,
--- a/layout/style/nsStyleSet.h
+++ b/layout/style/nsStyleSet.h
@@ -186,16 +186,24 @@ class nsStyleSet final
                                     nsRestyleHint aWhichToRemove);
 
   // Similar to the above, but resolving style without all animation data in
   // the first place.
   already_AddRefed<nsStyleContext>
     ResolveStyleWithoutAnimation(mozilla::dom::Element* aTarget,
                                  nsStyleContext* aParentContext);
 
+  // Pseudo-element version of the above, ResolveStyleWithoutAnimation.
+  already_AddRefed<nsStyleContext>
+  ResolvePseudoElementStyleWithoutAnimation(
+    mozilla::dom::Element* aParentElement,
+    mozilla::CSSPseudoElementType aType,
+    nsStyleContext* aParentContext,
+    mozilla::dom::Element* aPseudoElement);
+
   // Get a style context for a text node (which no rules will match).
   //
   // The returned style context will have nsCSSAnonBoxes::mozText as its pseudo.
   //
   // (Perhaps mozText should go away and we shouldn't even create style
   // contexts for such content nodes, when text-combine-upright is not
   // present.  However, not doing any rule matching for them is a first step.)
   already_AddRefed<nsStyleContext>
@@ -537,16 +545,23 @@ private:
     eWithoutAnimation,
   };
   already_AddRefed<nsStyleContext>
   ResolveStyleForInternal(mozilla::dom::Element* aElement,
                           nsStyleContext* aParentContext,
                           TreeMatchContext& aTreeMatchContext,
                           AnimationFlag aAnimationFlag);
 
+  already_AddRefed<nsStyleContext>
+  ResolvePseudoElementStyleInternal(mozilla::dom::Element* aParentElement,
+                                    mozilla::CSSPseudoElementType aType,
+                                    nsStyleContext* aParentContext,
+                                    mozilla::dom::Element* aPseudoElement,
+                                    AnimationFlag aAnimationFlag);
+
   nsPresContext* PresContext() { return mRuleTree->PresContext(); }
 
   // The sheets in each array in mSheets are stored with the most significant
   // sheet last.
   // The arrays for ePresHintSheet, eStyleAttrSheet, eTransitionSheet,
   // eAnimationSheet and eSVGAttrAnimationSheet are always empty.
   // (FIXME:  We should reduce the storage needed for them.)
   mozilla::EnumeratedArray<mozilla::SheetType, mozilla::SheetType::Count,