Bug 1403592: Never flush the user font set when getting font metrics from style resolution. r=Manishearth
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 27 Sep 2017 18:09:31 +0200
changeset 383431 0a0cc4bb885a2487b643e94fc244620751616d03
parent 383430 c62e4471a0e31fde6ef570137e8648eb5612fbc8
child 383432 c050d8574203c0344a9570fef73df51a1a489091
push id32594
push userkwierso@gmail.com
push dateThu, 28 Sep 2017 22:49:33 +0000
treeherdermozilla-central@6dea0ee45b66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersManishearth
bugs1403592
milestone58.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 1403592: Never flush the user font set when getting font metrics from style resolution. r=Manishearth In this case, the caller doesn't go through all the PreTraverseSync stuff (we don't really want it to do so), via GetComputedStyleNoFlush. It makes sense to not flush the user font set that case, we'll schedule a restyle properly if / when needed. Since the set should be flushed otherwise, let's just not flush it from the styling code. MozReview-Commit-ID: LLHfxemJ8QQ
layout/style/ServoBindings.cpp
layout/style/nsRuleNode.cpp
layout/style/nsRuleNode.h
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2477,19 +2477,20 @@ Gecko_GetFontMetrics(RawGeckoPresContext
   // and if so, appends PostTraversalTasks to the current ServoStyleSet
   // to be performed immediately after the traversal is finished.  This
   // works well for starting downloadable font loads, since we don't have
   // those fonts available to get metrics for anyway.  Platform fonts and
   // ArrayBuffer-backed FontFace objects are handled synchronously.
 
   nsPresContext* presContext = const_cast<nsPresContext*>(aPresContext);
   presContext->SetUsesExChUnits(true);
-  RefPtr<nsFontMetrics> fm = nsRuleNode::GetMetricsFor(presContext, aIsVertical,
-                                                       aFont, aFontSize,
-                                                       aUseUserFontSet);
+  RefPtr<nsFontMetrics> fm = nsRuleNode::GetMetricsFor(
+      presContext, aIsVertical, aFont, aFontSize, aUseUserFontSet,
+      nsRuleNode::FlushUserFontSet::No);
+
   ret.mXSize = fm->XHeight();
   gfxFloat zeroWidth = fm->GetThebesFontGroup()->GetFirstValidFont()->
                            GetMetrics(fm->Orientation()).zeroOrAveCharWidth;
   ret.mChSize = ceil(aPresContext->AppUnitsPerDevPixel() * zeroWidth);
   return ret;
 }
 
 int32_t
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -372,28 +372,30 @@ static inline nscoord ScaleViewportCoord
 }
 
 /* static */
 already_AddRefed<nsFontMetrics>
 nsRuleNode::GetMetricsFor(nsPresContext* aPresContext,
                           bool aIsVertical,
                           const nsStyleFont* aStyleFont,
                           nscoord aFontSize,
-                          bool aUseUserFontSet)
+                          bool aUseUserFontSet,
+                          FlushUserFontSet aFlushUserFontSet)
 {
   nsFont font = aStyleFont->mFont;
   font.size = aFontSize;
   gfxFont::Orientation orientation
     = aIsVertical ? gfxFont::eVertical : gfxFont::eHorizontal;
   nsFontMetrics::Params params;
   params.language = aStyleFont->mLanguage;
   params.explicitLanguage = aStyleFont->mExplicitLanguage;
   params.orientation = orientation;
-  params.userFontSet =
-    aUseUserFontSet ? aPresContext->GetUserFontSet() : nullptr;
+  params.userFontSet = aUseUserFontSet
+    ? aPresContext->GetUserFontSet(aFlushUserFontSet == FlushUserFontSet::Yes)
+    : nullptr;
   params.textPerf = aPresContext->GetTextPerfMetrics();
   return aPresContext->DeviceContext()->GetMetricsFor(font, params);
 }
 
 /* static */
 already_AddRefed<nsFontMetrics>
 nsRuleNode::GetMetricsFor(nsPresContext* aPresContext,
                           nsStyleContext* aStyleContext,
@@ -403,18 +405,19 @@ nsRuleNode::GetMetricsFor(nsPresContext*
 {
   bool isVertical = false;
   if (aStyleContext) {
     WritingMode wm(aStyleContext);
     if (wm.IsVertical() && !wm.IsSideways()) {
       isVertical = true;
     }
   }
-  return nsRuleNode::GetMetricsFor(aPresContext, isVertical, aStyleFont,
-                                   aFontSize, aUseUserFontSet);
+  return nsRuleNode::GetMetricsFor(
+      aPresContext, isVertical, aStyleFont, aFontSize, aUseUserFontSet,
+      FlushUserFontSet::Yes);
 }
 
 /* static */
 void
 nsRuleNode::FixupNoneGeneric(nsFont* aFont,
                              const nsPresContext* aPresContext,
                              uint8_t aGenericFontID,
                              const nsFont* aDefaultVariableFont)
--- a/layout/style/nsRuleNode.h
+++ b/layout/style/nsRuleNode.h
@@ -802,21 +802,27 @@ private:
 public:
   // This is infallible; it will never return nullptr.
   static already_AddRefed<nsRuleNode> CreateRootNode(nsPresContext* aPresContext);
 
   static void EnsureBlockDisplay(mozilla::StyleDisplay& display,
                                  bool aConvertListItem = false);
   static void EnsureInlineDisplay(mozilla::StyleDisplay& display);
 
+  enum class FlushUserFontSet {
+    Yes,
+    No,
+  };
+
   static already_AddRefed<nsFontMetrics> GetMetricsFor(nsPresContext* aPresContext,
                                                        bool aIsVertical,
                                                        const nsStyleFont* aStyleFont,
                                                        nscoord aFontSize,
-                                                       bool aUseUserFontSet);
+                                                       bool aUseUserFontSet,
+                                                       FlushUserFontSet aFlushUserFontSet);
 
   static already_AddRefed<nsFontMetrics> GetMetricsFor(nsPresContext* aPresContext,
                                                        nsStyleContext* aStyleContext,
                                                        const nsStyleFont* aStyleFont,
                                                        nscoord aFontSize,
                                                        bool aUseUserFontSet);
 
   /**