Bug 1406750 - Use GetStyleContextNoFlush in UpdateCurrentStyleSources, and avoid flushing mPresShell twice. r=bz, a=abillings
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 24 Oct 2017 17:44:12 -0400
changeset 432735 39a3a1dd8c6b87d09b9d4f8959eeb8e905d529a2
parent 432734 596eecad379298febb37693026b4667e9f60f4f5
child 432736 1f57ef43bb6589efcbd746134b6c8d18de9f7e28
push id8045
push userryanvm@gmail.com
push dateWed, 25 Oct 2017 13:02:35 +0000
treeherdermozilla-beta@39a3a1dd8c6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, abillings
bugs1406750
milestone57.0
Bug 1406750 - Use GetStyleContextNoFlush in UpdateCurrentStyleSources, and avoid flushing mPresShell twice. r=bz, a=abillings MozReview-Commit-ID: Nfu9FZcIzQ
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -827,16 +827,21 @@ nsComputedDOMStyle::UpdateCurrentStyleSo
 #endif
 
   mPresShell = document->GetShell();
   if (!mPresShell || !mPresShell->GetPresContext()) {
     ClearStyleContext();
     return;
   }
 
+  nsCOMPtr<nsIPresShell> presShellForContent = GetPresShellForContent(mContent);
+  if (presShellForContent && presShellForContent != mPresShell) {
+    presShellForContent->FlushPendingNotifications(FlushType::Style);
+  }
+
   // We need to use GetUndisplayedRestyleGeneration instead of
   // GetRestyleGeneration, because the caching of mStyleContext is an
   // optimization that is useful only for displayed elements.
   // For undisplayed elements we need to take into account any DOM changes that
   // might cause a restyle, because Servo will not increase the generation for
   // undisplayed elements.
   // As for Gecko, GetUndisplayedRestyleGeneration is effectively equal to
   // GetRestyleGeneration, since the generation is incremented whenever we
@@ -917,20 +922,21 @@ nsComputedDOMStyle::UpdateCurrentStyleSo
       assertMsg.Append(')');
       NS_ASSERTION(nsCSSPseudoElements::PseudoElementContainsElements(pseudo) ||
                    mContent->IsNativeAnonymous(),
                    NS_LossyConvertUTF16toASCII(assertMsg).get());
     }
 #endif
     // Need to resolve a style context
     RefPtr<nsStyleContext> resolvedStyleContext =
-      nsComputedDOMStyle::GetStyleContext(mContent->AsElement(),
-                                          mPseudo,
-                                          mPresShell,
-                                          mStyleType);
+      nsComputedDOMStyle::GetStyleContextNoFlush(
+          mContent->AsElement(),
+          mPseudo,
+          presShellForContent ? presShellForContent.get() : mPresShell,
+          mStyleType);
     if (!resolvedStyleContext) {
       ClearStyleContext();
       return;
     }
 
     // No need to re-get the generation, even though GetStyleContext
     // will flush, since we flushed style at the top of this function.
     NS_ASSERTION(mPresShell &&