Bug 1000745 - Part 2: Remove font.mathfont-glyph-tables. r=karlt
authorFrédéric Wang <fred.wang@free.fr>
Thu, 24 Apr 2014 02:41:00 -0400
changeset 180339 570a6e27b76ee5b9fc689ba1b53a1de522e952a9
parent 180338 7564b6bb7720dd9f77cb341759a2cba97e39f821
child 180340 36f02c47f4be7a98953649d4cc051bc4a578c42b
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerskarlt
bugs1000745
milestone31.0a1
Bug 1000745 - Part 2: Remove font.mathfont-glyph-tables. r=karlt
layout/mathml/mathfont.properties
layout/mathml/nsMathMLChar.cpp
--- a/layout/mathml/mathfont.properties
+++ b/layout/mathml/mathfont.properties
@@ -1,26 +1,15 @@
 # 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/.
 
 #  LOCALIZATION NOTE: FILE
 #  Do not translate anything in this file
 
-# List of fonts that have corresponding properties files containing special
-# glyph tables for stretching MathML characters.  See the documentation at the
-# end of this file for details on the setup of the property file associated to
-# each font.  Do not include the Unicode table in this list.
-
-%ifdef XP_WIN
-font.mathfont-glyph-tables = MathJax_Main, STIXNonUnicode, STIXSizeOneSym, Standard Symbols L, Symbol
-%else
-font.mathfont-glyph-tables = MathJax_Main, STIXNonUnicode, STIXSizeOneSym, Standard Symbols L
-%endif
-
 # The ordered list of fonts with which to attempt to stretch MathML
 # characters is controlled by setting pref("font.mathfont-family",
 # "CMSY10, CMEX10, ...") for example, or by setting the font-family list in
 # :-moz-math-stretchy in mathml.css.
 #
 # Note: setting base fonts for non-stretchy characters only works
 # for operators that are ultimately handled by nsMathMLChar.
 # @see how |useMathMLChar| is set in nsMathMLmoFrame::Stretch() & Paint().
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -674,24 +674,16 @@ nsGlyphTableList::GetGlyphTableFor(const
     }
   }
   // Fall back to default Unicode table
   return &mUnicodeTable;
 }
 
 // -----------------------------------------------------------------------------
 
-static bool
-MathFontEnumCallback(const nsString& aFamily, bool aGeneric, void *aData)
-{
-  if (!gGlyphTableList->AddGlyphTable(aFamily))
-    return false; // stop in low-memory situations
-  return true; // don't stop
-}
-
 static nsresult
 InitGlobals(nsPresContext* aPresContext)
 {
   NS_ASSERTION(!gGlyphTableInitialized, "Error -- already initialized");
   gGlyphTableInitialized = true;
 
   // Allocate the placeholders for the preferred parts and variants
   nsresult rv = NS_ERROR_OUT_OF_MEMORY;
@@ -699,45 +691,31 @@ InitGlobals(nsPresContext* aPresContext)
   if (gGlyphTableList) {
     rv = gGlyphTableList->Initialize();
   }
   if (NS_FAILED(rv)) {
     delete gGlyphTableList;
     gGlyphTableList = nullptr;
     return rv;
   }
-  /*
-  else
-    The gGlyphTableList has been successfully registered as a shutdown observer.
-    It will be deleted at shutdown, even if a failure happens below.
-  */
-
-  nsAutoCString key;
-  nsAutoString value;
-  nsCOMPtr<nsIPersistentProperties> mathfontProp;
-
-  // Add the math fonts in the gGlyphTableList in order of preference ...
-  // Note: we only load font-names at this stage. The actual glyph tables will
-  // be loaded lazily (see nsGlyphTable::ElementAt()).
+  // The gGlyphTableList has been successfully registered as a shutdown
+  // observer and will be deleted at shutdown. We now add some private
+  // per font-family tables for stretchy operators, in order of preference.
+  // Do not include the Unicode table in this list.
+  if (!gGlyphTableList->AddGlyphTable(NS_LITERAL_STRING("MathJax_Main")) ||
+      !gGlyphTableList->AddGlyphTable(NS_LITERAL_STRING("STIXNonUnicode")) ||
+      !gGlyphTableList->AddGlyphTable(NS_LITERAL_STRING("STIXSizeOneSym")) ||
+      !gGlyphTableList->AddGlyphTable(NS_LITERAL_STRING("Standard Symbols L"))
+#ifdef XP_WIN
+      || !gGlyphTableList->AddGlyphTable(NS_LITERAL_STRING("Symbol"))
+#endif
+      ) {
+    rv = NS_ERROR_OUT_OF_MEMORY;
+  }
 
-  // Load the "mathfont.properties" file
-  value.Truncate();
-  rv = LoadProperties(value, mathfontProp);
-  if (NS_FAILED(rv)) return rv;
-
-  // Get the list of mathfonts having special glyph tables to be used for
-  // stretchy characters.
-  // We just want to iterate over the font-family list using the
-  // callback mechanism that nsFont has...
-  nsFont font("", 0, 0, 0, 0, 0, 0);
-  NS_NAMED_LITERAL_CSTRING(defaultKey, "font.mathfont-glyph-tables");
-  rv = mathfontProp->GetStringProperty(defaultKey, font.name);
-  if (NS_FAILED(rv)) return rv;
-
-  font.EnumerateFamilies(MathFontEnumCallback, nullptr);
   return rv;
 }
 
 // -----------------------------------------------------------------------------
 // And now the implementation of nsMathMLChar
 
 nsMathMLChar::~nsMathMLChar()
 {