Bug 1383925 - Remove unnecessary copy construction of default font in nsRuleNode.cpp. r=dholbert
authorKevin Hsieh <kevin.hsieh@ucla.edu>
Mon, 24 Jul 2017 17:56:54 -0700
changeset 419675 756aa07a185219e8340a196ad215fcd2d5b4d349
parent 419674 70c20fc0105491ba111c188a23e93b35d86554e7
child 419676 e8f4b9ab34dd17a405a0e22bfe973799e4780d84
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1383925
milestone56.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 1383925 - Remove unnecessary copy construction of default font in nsRuleNode.cpp. r=dholbert MozReview-Commit-ID: 6awjBjmEBsM
layout/style/nsRuleNode.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3689,23 +3689,26 @@ nsRuleNode::SetFont(nsPresContext* aPres
     NS_STYLE_FONT_DIALOG         == LookAndFeel::eFont_Dialog &&
     NS_STYLE_FONT_BUTTON         == LookAndFeel::eFont_Button &&
     NS_STYLE_FONT_PULL_DOWN_MENU == LookAndFeel::eFont_PullDownMenu &&
     NS_STYLE_FONT_LIST           == LookAndFeel::eFont_List &&
     NS_STYLE_FONT_FIELD          == LookAndFeel::eFont_Field,
     "LookAndFeel.h system-font constants out of sync with nsStyleConsts.h");
 
   // Fall back to defaultVariableFont.
-  nsFont systemFont = *defaultVariableFont;
+  Maybe<nsFont> lazySystemFont;
   const nsCSSValue* systemFontValue = aRuleData->ValueForSystemFont();
   if (eCSSUnit_Enumerated == systemFontValue->GetUnit()) {
+    lazySystemFont.emplace(*defaultVariableFont);
     LookAndFeel::FontID fontID =
       (LookAndFeel::FontID)systemFontValue->GetIntValue();
-    ComputeSystemFont(&systemFont, fontID, aPresContext, defaultVariableFont);
-  }
+    ComputeSystemFont(lazySystemFont.ptr(), fontID, aPresContext,
+                      defaultVariableFont);
+  }
+  const nsFont& systemFont = lazySystemFont.refOr(*defaultVariableFont);
 
   // font-family: font family list, enum, inherit
   const nsCSSValue* familyValue = aRuleData->ValueForFontFamily();
   NS_ASSERTION(eCSSUnit_Enumerated != familyValue->GetUnit(),
                "system fonts should not be in mFamily anymore");
   if (eCSSUnit_FontFamilyList == familyValue->GetUnit()) {
     // set the correct font if we are using DocumentFonts OR we are overriding for XUL
     // MJA: bug 31816