Bug 1347819 - remove nsFont::Init. r=jfkthame
authorJeremy Chen <jeremychen@mozilla.com>
Thu, 23 Mar 2017 21:59:55 +0800
changeset 399697 5019bbb5beb371143c733af31ab09913f8f1e6c3
parent 399696 17050f0040ef42bc2a921807702ad731c94fcbf6
child 399698 73502ce79ab54ab2ff0375b9504d1c44072602ad
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1347819
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 1347819 - remove nsFont::Init. r=jfkthame nsFont::Init was created to be shared in two different constructors. However, we could simply perform initialization in nsFont by Struct Initialization and get the same effect. The only primitive type that is not taken care of by nsFont::Init is nsFont::size. Since nsFont::size represents the logical size of the font, I think initializing it to '0' should be fine. MozReview-Commit-ID: 6Jo7F2Bt9Sy
gfx/src/nsFont.cpp
gfx/src/nsFont.h
--- a/gfx/src/nsFont.cpp
+++ b/gfx/src/nsFont.cpp
@@ -1,61 +1,37 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsFont.h"
 #include "gfxFont.h"                    // for gfxFontStyle
-#include "gfxFontConstants.h"           // for NS_FONT_KERNING_AUTO, etc
 #include "gfxFontFeatures.h"            // for gfxFontFeature, etc
 #include "gfxFontUtils.h"               // for TRUETYPE_TAG
 #include "nsCRT.h"                      // for nsCRT
 #include "nsDebug.h"                    // for NS_ASSERTION
 #include "nsISupports.h"
 #include "nsUnicharUtils.h"
 #include "nscore.h"                     // for char16_t
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/gfx/2D.h"
 
 using namespace mozilla;
 
 nsFont::nsFont(const FontFamilyList& aFontlist, nscoord aSize)
   : fontlist(aFontlist)
+  , size(aSize)
 {
-  Init();
-  size = aSize;
 }
 
 nsFont::nsFont(FontFamilyType aGenericType, nscoord aSize)
   : fontlist(aGenericType)
-{
-  Init();
-  size = aSize;
-}
-
-void
-nsFont::Init()
+  , size(aSize)
 {
-  style = NS_FONT_STYLE_NORMAL;
-  weight = NS_FONT_WEIGHT_NORMAL;
-  stretch = NS_FONT_STRETCH_NORMAL;
-  systemFont = false;
-  smoothing = NS_FONT_SMOOTHING_AUTO;
-  sizeAdjust = -1.0f;
-  kerning = NS_FONT_KERNING_AUTO;
-  synthesis = NS_FONT_SYNTHESIS_WEIGHT | NS_FONT_SYNTHESIS_STYLE;
-
-  variantAlternates = 0;
-  variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
-  variantEastAsian = 0;
-  variantLigatures = 0;
-  variantNumeric = 0;
-  variantPosition = NS_FONT_VARIANT_POSITION_NORMAL;
-  variantWidth = NS_FONT_VARIANT_WIDTH_NORMAL;
 }
 
 nsFont::nsFont(const nsFont& aOther) = default;
 
 nsFont::nsFont()
 {
 }
 
--- a/gfx/src/nsFont.h
+++ b/gfx/src/nsFont.h
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsFont_h___
 #define nsFont_h___
 
 #include <stdint.h>                     // for uint8_t, uint16_t
 #include <sys/types.h>                  // for int16_t
 #include "gfxFontFamilyList.h"
+#include "gfxFontConstants.h"           // for NS_FONT_KERNING_AUTO, etc
 #include "gfxFontFeatures.h"
 #include "gfxFontVariations.h"
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "nsCoord.h"                    // for nscoord
 #include "nsStringFwd.h"                // for nsSubstring
 #include "nsString.h"               // for nsString
 #include "nsTArray.h"                   // for nsTArray
 
@@ -41,62 +42,62 @@ const uint8_t kGenericFont_fantasy      
 
 // Font structure.
 struct nsFont {
 
   // list of font families, either named or generic
   mozilla::FontFamilyList fontlist;
 
   // The style of font (normal, italic, oblique; see gfxFontConstants.h)
-  uint8_t style;
+  uint8_t style = NS_FONT_STYLE_NORMAL;
 
   // Force this font to not be considered a 'generic' font, even if
   // the name is the same as a CSS generic font family.
-  bool systemFont;
+  bool systemFont = false;
 
   // Variant subproperties
-  uint8_t variantCaps;
-  uint8_t variantNumeric;
-  uint8_t variantPosition;
-  uint8_t variantWidth;
+  uint8_t variantCaps = NS_FONT_VARIANT_CAPS_NORMAL;
+  uint8_t variantNumeric = 0;
+  uint8_t variantPosition = NS_FONT_VARIANT_POSITION_NORMAL;
+  uint8_t variantWidth = NS_FONT_VARIANT_WIDTH_NORMAL;
 
-  uint16_t variantLigatures;
-  uint16_t variantEastAsian;
+  uint16_t variantLigatures = 0;
+  uint16_t variantEastAsian = 0;
 
   // Some font-variant-alternates property values require
   // font-specific settings defined via @font-feature-values rules.
   // These are resolved *after* font matching occurs.
 
   // -- bitmask for both enumerated and functional propvals
-  uint16_t variantAlternates;
+  uint16_t variantAlternates = 0;
 
   // Smoothing - controls subpixel-antialiasing (currently OSX only)
-  uint8_t smoothing;
+  uint8_t smoothing = NS_FONT_SMOOTHING_AUTO;
 
   // The weight of the font; see gfxFontConstants.h.
-  uint16_t weight;
+  uint16_t weight = NS_FONT_WEIGHT_NORMAL;
 
   // The stretch of the font (the sum of various NS_FONT_STRETCH_*
   // constants; see gfxFontConstants.h).
-  int16_t stretch;
+  int16_t stretch = NS_FONT_STRETCH_NORMAL;
 
   // Kerning
-  uint8_t kerning;
+  uint8_t kerning = NS_FONT_KERNING_AUTO;
 
   // Synthesis setting, controls use of fake bolding/italics
-  uint8_t synthesis;
+  uint8_t synthesis = NS_FONT_SYNTHESIS_WEIGHT | NS_FONT_SYNTHESIS_STYLE;
 
   // The logical size of the font, in nscoord units
-  nscoord size;
+  nscoord size = 0;
 
   // The aspect-value (ie., the ratio actualsize:actualxheight) that any
   // actual physical font created from this font structure must have when
   // rendering or measuring a string. A value of -1.0 means no adjustment
   // needs to be done; otherwise the value must be nonnegative.
-  float sizeAdjust;
+  float sizeAdjust = -1.0f;
 
   // -- list of value tags for font-specific alternate features
   nsTArray<gfxAlternateValue> alternateValues;
 
   // -- object used to look these up once the font is matched
   RefPtr<gfxFontFeatureValueSet> featureValueLookup;
 
   // Font features from CSS font-feature-settings
@@ -137,17 +138,14 @@ struct nsFont {
   nsFont& operator=(const nsFont& aOther);
 
   void CopyAlternates(const nsFont& aOther);
 
   // Add featureSettings into style
   void AddFontFeaturesToStyle(gfxFontStyle *aStyle) const;
 
   void AddFontVariationsToStyle(gfxFontStyle *aStyle) const;
-
-protected:
-  void Init(); // helper method for initialization
 };
 
 #define NS_FONT_VARIANT_NORMAL            0
 #define NS_FONT_VARIANT_SMALL_CAPS        1
 
 #endif /* nsFont_h___ */