Bug 1355595 - Simplify the default font size calculation; r=dbaron
authorEvelyn Hung <jj.evelyn@gmail.com>
Tue, 11 Apr 2017 18:13:31 -0400
changeset 352831 abfece312d74
parent 352830 c1357df217a4
child 352832 860fb6f3b303
push id31652
push userkwierso@gmail.com
push dateThu, 13 Apr 2017 20:03:53 +0000
treeherdermozilla-central@3243c8fc3ce7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1355595, 1355600
milestone55.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 1355595 - Simplify the default font size calculation; r=dbaron When calculating the thickness of the spellchecker underline, we can directly use aPresContext to get default font size, instead of creating a temporary nsStyleFont object. nsStyleFont does more work than default font size calculation, and destructing its member mFont object is expensive (see bug 1355600), so it's better to avoid it on this hot path. MozReview-Commit-ID: GSvnZHULtL5
layout/generic/nsTextFrame.cpp
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -5796,20 +5796,22 @@ nsTextFrame::ComputeSelectionUnderlineHe
       return aFontMetrics.underlineSize;
     case SelectionType::eSpellCheck: {
       // The thickness of the spellchecker underline shouldn't honor the font
       // metrics.  It should be constant pixels value which is decided from the
       // default font size.  Note that if the actual font size is smaller than
       // the default font size, we should use the actual font size because the
       // computed value from the default font size can be too thick for the
       // current font size.
-      int32_t defaultFontSize =
-        aPresContext->AppUnitsToDevPixels(nsStyleFont(aPresContext).mFont.size);
-      gfxFloat fontSize = std::min(gfxFloat(defaultFontSize),
-                                 aFontMetrics.emHeight);
+      nscoord defaultFontSize = aPresContext->GetDefaultFont(
+          kPresContext_DefaultVariableFont_ID, nullptr)->size;
+      int32_t zoomedFontSize = aPresContext->AppUnitsToDevPixels(
+          nsStyleFont::ZoomText(aPresContext, defaultFontSize));
+      gfxFloat fontSize = std::min(gfxFloat(zoomedFontSize),
+                                   aFontMetrics.emHeight);
       fontSize = std::max(fontSize, 1.0);
       return ceil(fontSize / 20);
     }
     default:
       NS_WARNING("Requested underline style is not valid");
       return aFontMetrics.underlineSize;
   }
 }