Bug 1315874 - Make GetStyleContextWithoutAnimation not flush; r=heycam draft
authorBrian Birtles <birtles@gmail.com>
Mon, 03 Apr 2017 16:49:09 +0900
changeset 555972 470c597591e49a16b3aca17679f111e4fd5bc951
parent 555971 6e15f9af32da2ad82d870e27377e0273dadda6f5
child 555973 6f9f8231654952ceadf49c2887b8868c2c18934b
push id52387
push userbbirtles@mozilla.com
push dateWed, 05 Apr 2017 06:09:34 +0000
reviewersheycam
bugs1315874
milestone55.0a1
Bug 1315874 - Make GetStyleContextWithoutAnimation not flush; r=heycam There are currently no call sites of GetStyleContextWithoutAnimation but there are a couple of places (including this patch series) where we would like to use such a method, but without the flushing behavior. This patch drops the flushing from GetStyleContextWithoutAnimation and renames it to GetUnanimatedStyleContextNoFlush. It also makes a few other minor tweaks: * Adds the aStyleType parameter for consistency with GetStyleContextNoFlush and GetStyleContext * Moves the implementation of this method and GetStyleContextNoFlush to the header file since they simply wrap DoGetStyleContextNoFlush. * Changes the order of these declarations so that the more specialized method comes later. * Drops the comment describing the method since both the method name and the inline definition should now make it obvious what it is doing. (Actually making this method not return animation styles when it re-uses an existing style context will happen in the next patch.) MozReview-Commit-ID: JYeim4A9Imr
layout/style/nsComputedDOMStyle.cpp
layout/style/nsComputedDOMStyle.h
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -660,58 +660,16 @@ nsComputedDOMStyle::DoGetStyleContextNoF
   }
 
   return styleResolver.ResolveWithoutAnimation(styleSet,
                                                aElement, type,
                                                parentContext,
                                                inDocWithShell);
 }
 
-
-/* static */
-already_AddRefed<nsStyleContext>
-nsComputedDOMStyle::GetStyleContextNoFlush(Element* aElement,
-                                           nsIAtom* aPseudo,
-                                           nsIPresShell* aPresShell,
-                                           StyleType aStyleType)
-{
-  return DoGetStyleContextNoFlush(aElement,
-                                  aPseudo,
-                                  aPresShell,
-                                  aStyleType,
-                                  eWithAnimation);
-}
-
-/* static */
-already_AddRefed<nsStyleContext>
-nsComputedDOMStyle::GetStyleContextWithoutAnimation(Element* aElement,
-                                                    nsIAtom* aPseudo,
-                                                    nsIPresShell* aPresShell)
-{
-  // If the content has a pres shell, we must use it.  Otherwise we'd
-  // potentially mix rule trees by using the wrong pres shell's style
-  // set.  Using the pres shell from the content also means that any
-  // content that's actually *in* a document will get the style from the
-  // correct document.
-  nsCOMPtr<nsIPresShell> presShell = GetPresShellForContent(aElement);
-  if (!presShell) {
-    presShell = aPresShell;
-    if (!presShell)
-      return nullptr;
-  }
-
-  presShell->FlushPendingNotifications(FlushType::Style);
-
-  return DoGetStyleContextNoFlush(aElement,
-                                  aPseudo,
-                                  presShell,
-                                  eAll,
-                                  eWithoutAnimation);
-}
-
 nsMargin
 nsComputedDOMStyle::GetAdjustedValuesForBoxSizing()
 {
   // We want the width/height of whatever parts 'width' or 'height' controls,
   // which can be different depending on the value of the 'box-sizing' property.
   const nsStylePosition* stylePos = StylePosition();
 
   nsMargin adjustment;
--- a/layout/style/nsComputedDOMStyle.h
+++ b/layout/style/nsComputedDOMStyle.h
@@ -88,27 +88,42 @@ public:
   GetStyleContext(mozilla::dom::Element* aElement, nsIAtom* aPseudo,
                   nsIPresShell* aPresShell,
                   StyleType aStyleType = eAll);
 
   enum AnimationFlag {
     eWithAnimation,
     eWithoutAnimation,
   };
-  // Similar to the above but ignoring animation rules and with StyleType::eAll.
-  static already_AddRefed<nsStyleContext>
-  GetStyleContextWithoutAnimation(mozilla::dom::Element* aElement,
-                                  nsIAtom* aPseudo,
-                                  nsIPresShell* aPresShell);
 
   static already_AddRefed<nsStyleContext>
   GetStyleContextNoFlush(mozilla::dom::Element* aElement,
                          nsIAtom* aPseudo,
                          nsIPresShell* aPresShell,
-                         StyleType aStyleType = eAll);
+                         StyleType aStyleType = eAll)
+  {
+    return DoGetStyleContextNoFlush(aElement,
+                                    aPseudo,
+                                    aPresShell,
+                                    aStyleType,
+                                    eWithAnimation);
+  }
+
+  static already_AddRefed<nsStyleContext>
+  GetUnanimatedStyleContextNoFlush(mozilla::dom::Element* aElement,
+                                   nsIAtom* aPseudo,
+                                   nsIPresShell* aPresShell,
+                                   StyleType aStyleType = eAll)
+  {
+    return DoGetStyleContextNoFlush(aElement,
+                                    aPseudo,
+                                    aPresShell,
+                                    aStyleType,
+                                    eWithoutAnimation);
+  }
 
   static nsIPresShell*
   GetPresShellForContent(nsIContent* aContent);
 
   // Helper for nsDOMWindowUtils::GetVisitedDependentComputedStyle
   void SetExposeVisitedStyle(bool aExpose) {
     NS_ASSERTION(aExpose != mExposeVisitedStyle, "should always be changing");
     mExposeVisitedStyle = aExpose;