Bug 1381083: Don't hold the style context if we had a frame and re-resolved the style. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 27 Jul 2017 00:45:29 +0200
changeset 617445 f2c1ff3f932456ea910d65217e1cc094f8e9a118
parent 617444 3e6f0571b2a3655d082eeaa46ebe313f2cc2decf
child 617446 3d6e90185b2a3fac9e21d3786b10ff7df30f2834
push id71048
push userbmo:emilio+bugs@crisal.io
push dateFri, 28 Jul 2017 12:58:45 +0000
reviewersheycam
bugs1381083
milestone56.0a1
Bug 1381083: Don't hold the style context if we had a frame and re-resolved the style. r?heycam Otherwise we risk losing track of the frame if we hit the cache. MozReview-Commit-ID: ByHGhcBwIfX
layout/style/nsComputedDOMStyle.cpp
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -955,26 +955,27 @@ nsComputedDOMStyle::UpdateCurrentStyleSo
       mStyleContext = styleIfVisited;
     }
   }
 }
 
 void
 nsComputedDOMStyle::ClearCurrentStyleSources()
 {
+  // Release the current style context if we got it off the frame.
+  // For a style context we resolved, keep it around so that we
+  // can re-use it next time this object is queried, but not if it-s a
+  // re-resolved style context because we were inside a pseudo-element.
+  if (!mResolvedStyleContext || mOuterFrame) {
+    ClearStyleContext();
+  }
+
   mOuterFrame = nullptr;
   mInnerFrame = nullptr;
   mPresShell = nullptr;
-
-  // Release the current style context if we got it off the frame.
-  // For a style context we resolved, keep it around so that we
-  // can re-use it next time this object is queried.
-  if (!mResolvedStyleContext) {
-    mStyleContext = nullptr;
-  }
 }
 
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::GetPropertyCSSValue(const nsAString& aPropertyName, ErrorResult& aRv)
 {
   nsCSSPropertyID prop =
     nsCSSProps::LookupProperty(aPropertyName, CSSEnabledState::eForAllContent);