Bug 781494 - Change line length in nsMathMLChar to be 80 characters or less. r=karlt
authorFrédéric Wang <fred.wang@free.fr>
Fri, 10 Aug 2012 11:29:59 -0400
changeset 102089 54568120778aabb3757c2425a4e1134165df092b
parent 102088 8a43488f1543c91e1f2d886087436b5e0e58d6b8
child 102090 343e745e40166cbe5ff5e990bc8fbff6109a8d5b
push id13307
push userryanvm@gmail.com
push dateFri, 10 Aug 2012 15:30:07 +0000
treeherdermozilla-inbound@343e745e4016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs781494
milestone17.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 781494 - Change line length in nsMathMLChar to be 80 characters or less. r=karlt
layout/mathml/nsMathMLChar.cpp
layout/mathml/nsMathMLChar.h
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -30,64 +30,69 @@
 
 #include "nsMathMLOperators.h"
 #include "nsMathMLChar.h"
 
 using namespace mozilla;
 
 //#define NOISY_SEARCH 1
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 static const PRUnichar   kSpaceCh   = PRUnichar(' ');
 static const nsGlyphCode kNullGlyph = {{0, 0}, 0};
 typedef enum {eExtension_base, eExtension_variants, eExtension_parts}
   nsMathfontPrefExtension;
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // nsGlyphTable is a class that provides an interface for accessing glyphs
 // of stretchy chars. It acts like a table that stores the variants of bigger
 // sizes (if any) and the partial glyphs needed to build extensible symbols.
 // An instance of nsGlyphTable is associated to one primary font. Extra glyphs
 // can be taken in other additional fonts when stretching certain characters.
 // These supplementary fonts are referred to as "external" fonts to the table.
 //
 // A char for which nsGlyphTable::Has(aChar) is true means that the table
 // contains some glyphs (bigger and/or partial) that can be used to render
 // the char. Bigger sizes (if any) of the char can then be retrieved with
 // BigOf(aSize). Partial glyphs can be retrieved with TopOf(), GlueOf(), etc.
 //
 // A table consists of "nsGlyphCode"s which are viewed either as Unicode
 // points or as direct glyph indices, depending on the type of the table.
 // XXX The latter is not yet supported.
 
-// General format of MathFont Property Files from which glyph data are retrieved:
-// -----------------------------------------------------------------------------------
+// General format of MathFont Property Files from which glyph data are
+// retrieved:
+// -----------------------------------------------------------------------------
 // Each font should have its set of glyph data. For example, the glyph data for
 // the "Symbol" font and the "MT Extra" font are in "mathfontSymbol.properties"
-// and "mathfontMTExtra.properties", respectively. The mathfont property file is a
-// set of all the stretchy MathML characters that can be rendered with that font
-// using larger and/or partial glyphs. The entry of each stretchy character in the
-// mathfont property file gives, in that order, the 4 partial glyphs: Top (or Left),
-// Middle, Bottom (or Right), Glue; and the variants of bigger sizes (if any).
+// and "mathfontMTExtra.properties", respectively. The mathfont property file
+// is a set of all the stretchy MathML characters that can be rendered with that
+// font using larger and/or partial glyphs. The entry of each stretchy character
+// in the mathfont property file gives, in that order, the 4 partial glyphs:
+// Top (or Left), Middle, Bottom (or Right), Glue; and the variants of bigger
+// sizes (if any).
 // A position that is not relevant to a particular character is indicated there
 // with the UNICODE REPLACEMENT CHARACTER 0xFFFD.
 // Characters that need to be built recursively from other characters are said
 // to be composite. For example, chars like over/underbrace in CMEX10 have to
-// be built from two half stretchy chars and joined in the middle (TeXbook, p.225).
-// Such chars are handled in a special manner by the nsMathMLChar class, which allows
-// several (2 or more) child chars to be composed in order to render another char.
-// To specify such chars, their list of glyphs in the property file should be given
-// as space-separated segments of glyphs. Each segment gives the 4 partial
+// be built from two half stretchy chars and joined in the middle
+// (TeXbook, p.225).
+// Such chars are handled in a special manner by the nsMathMLChar class, which
+// allows several (2 or more) child chars to be composed in order to render
+// another char.
+// To specify such chars, their list of glyphs in the property file should be
+// given as space-separated segments of glyphs. Each segment gives the 4 partial
 // glyphs with which to build the child char that will be joined with its other
-// siblings. In this code, when this situation happens (see the detailed description
-// of Stretch() below), the original char (referred to as "parent") creates a
-// singly-linked list of child chars, asking them to stretch in an equally divided
-// space. The nsGlyphTable embeds the necessary logic to guarantee correctness in a
-// recursive stretch (and in the use of TopOf(), GlueOf(), etc) on these child chars.
-// -----------------------------------------------------------------------------------
+// siblings. In this code, when this situation happens (see the detailed
+// description of Stretch() below), the original char (referred to as "parent")
+// creates a singly-linked list of child chars, asking them to stretch in an
+// equally divided space. The nsGlyphTable embeds the necessary logic to
+// guarantee correctness in a recursive stretch (and in the use of TopOf(),
+// GlueOf(), etc) on these child chars.
+// -----------------------------------------------------------------------------
 
 #define NS_TABLE_TYPE_UNICODE       0
 #define NS_TABLE_TYPE_GLYPH_INDEX   1
 
 #define NS_TABLE_STATE_ERROR       -1
 #define NS_TABLE_STATE_EMPTY        0
 #define NS_TABLE_STATE_READY        1
 
@@ -110,31 +115,32 @@ LoadProperties(const nsString& aName,
   uriStr.AssignLiteral("resource://gre/res/fonts/mathfont");
   uriStr.Append(aName);
   uriStr.StripWhitespace(); // that may come from aName
   uriStr.AppendLiteral(".properties");
   return NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(aProperties), 
                                                 NS_ConvertUTF16toUTF8(uriStr));
 }
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 
 class nsGlyphTable {
 public:
   explicit nsGlyphTable(const nsString& aPrimaryFontName)
     : mType(NS_TABLE_TYPE_UNICODE),
       mFontName(1), // ensure space for primary font name.
       mState(NS_TABLE_STATE_EMPTY),
       mCharCache(0)
   {
     MOZ_COUNT_CTOR(nsGlyphTable);
     mFontName.AppendElement(aPrimaryFontName);
   }
 
-  ~nsGlyphTable() // not a virtual destructor: this class is not intended to be subclassed
+  // not a virtual destructor: this class is not intended to be subclassed
+  ~nsGlyphTable()
   {
     MOZ_COUNT_DTOR(nsGlyphTable);
   }
 
   const nsAString& PrimaryFontName() const
   {
     return mFontName[0];
   }
@@ -168,65 +174,72 @@ public:
     return ElementAt(aPresContext, aChar, 1);
   }
   nsGlyphCode BottomOf(nsPresContext* aPresContext, nsMathMLChar* aChar) {
     return ElementAt(aPresContext, aChar, 2);
   }
   nsGlyphCode GlueOf(nsPresContext* aPresContext, nsMathMLChar* aChar) {
     return ElementAt(aPresContext, aChar, 3);
   }
-  nsGlyphCode BigOf(nsPresContext* aPresContext, nsMathMLChar* aChar, PRInt32 aSize) {
+  nsGlyphCode BigOf(nsPresContext* aPresContext, nsMathMLChar* aChar,
+                    PRInt32 aSize) {
     return ElementAt(aPresContext, aChar, 4 + aSize);
   }
   nsGlyphCode LeftOf(nsPresContext* aPresContext, nsMathMLChar* aChar) {
     return ElementAt(aPresContext, aChar, 0);
   }
   nsGlyphCode RightOf(nsPresContext* aPresContext, nsMathMLChar* aChar) {
     return ElementAt(aPresContext, aChar, 2);
   }
 
 private:
-  nsGlyphCode ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint32 aPosition);
+  nsGlyphCode ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar,
+                        PRUint32 aPosition);
 
   // The type is either NS_TABLE_TYPE_UNICODE or NS_TABLE_TYPE_GLYPH_INDEX
   PRInt32 mType;    
                            
   // mFontName[0] is the primary font associated to this table. The others 
   // are possible "external" fonts for glyphs not in the primary font
   // but which are needed to stretch certain characters in the table
   nsTArray<nsString> mFontName; 
                                
   // Tri-state variable for error/empty/ready
   PRInt32 mState;
 
-  // The set of glyph data in this table, as provided by the MathFont Property File
+  // The set of glyph data in this table, as provided by the MathFont Property
+  // File
   nsCOMPtr<nsIPersistentProperties> mGlyphProperties;
 
   // For speedy re-use, we always cache the last data used in the table.
   // mCharCache is the Unicode point of the last char that was queried in this
   // table. mGlyphCache is a buffer containing the glyph data associated to
   // that char. For a property line 'key = value' in the MathFont Property File,
-  // mCharCache will retain the 'key' -- which is a Unicode point, while mGlyphCache
-  // will retain the 'value', which is a consecutive list of nsGlyphCodes, i.e.,
-  // the pairs of 'code@font' needed by the char -- in which 'code@0' can be specified
-  // without the optional '@0'. However, to ease subsequent processing, mGlyphCache
-  // excludes the '@' symbol and explicitly inserts all optional '0' that indicates
-  // the primary font identifier. Specifically therefore, the k-th glyph is
-  // characterized by :
-  // 1) mGlyphCache[3*k],mGlyphCache[3*k+1] : its Unicode point (or glyph index -- depending on mType),
-  // 2) mGlyphCache[3*k+2] : the numeric identifier of the font where it comes from.
+  // mCharCache will retain the 'key' -- which is a Unicode point, while
+  // mGlyphCache will retain the 'value', which is a consecutive list of
+  // nsGlyphCodes, i.e., the pairs of 'code@font' needed by the char -- in
+  // which 'code@0' can be specified
+  // without the optional '@0'. However, to ease subsequent processing,
+  // mGlyphCache excludes the '@' symbol and explicitly inserts all optional '0'
+  // that indicates the primary font identifier. Specifically therefore, the
+  // k-th glyph is characterized by :
+  // 1) mGlyphCache[3*k],mGlyphCache[3*k+1] : its Unicode point (or glyph index
+  // -- depending on mType),
+  // 2) mGlyphCache[3*k+2] : the numeric identifier of the font where it comes
+  // from.
   // A font identifier of '0' means the default primary font associated to this
-  // table. Other digits map to the "external" fonts that may have been specified
-  // in the MathFont Property File.
+  // table. Other digits map to the "external" fonts that may have been
+  // specified in the MathFont Property File.
   nsString  mGlyphCache;
   PRUnichar mCharCache;
 };
 
 nsGlyphCode
-nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar, PRUint32 aPosition)
+nsGlyphTable::ElementAt(nsPresContext* aPresContext, nsMathMLChar* aChar,
+                        PRUint32 aPosition)
 {
   if (mState == NS_TABLE_STATE_ERROR) return kNullGlyph;
   // Load glyph properties if this is the first time we have been here
   if (mState == NS_TABLE_STATE_EMPTY) {
     nsresult rv = LoadProperties(mFontName[0], mGlyphProperties);
 #ifdef DEBUG
     nsCAutoString uriStr;
     uriStr.AssignLiteral("resource://gre/res/fonts/mathfont");
@@ -262,25 +275,29 @@ nsGlyphTable::ElementAt(nsPresContext* a
 
   // Update our cache if it is not associated to this character
   PRUnichar uchar = aChar->mData[0];
   if (mCharCache != uchar) {
     // The key in the property file is interpreted as ASCII and kept
     // as such ...
     char key[10]; PR_snprintf(key, sizeof(key), "\\u%04X", uchar);
     nsAutoString value;
-    nsresult rv = mGlyphProperties->GetStringProperty(nsDependentCString(key), value);
+    nsresult rv = mGlyphProperties->GetStringProperty(nsDependentCString(key),
+                                                      value);
     if (NS_FAILED(rv)) return kNullGlyph;
     Clean(value);
-    // See if this char uses external fonts; e.g., if the 2nd glyph is taken from the
-    // external font '1', the property line looks like \uNNNN = \uNNNN\uNNNN@1\uNNNN.
-    // This is where mGlyphCache is pre-processed to explicitly store all glyph codes
-    // as combined pairs of 'code@font', excluding the '@' separator. This means that
-    // mGlyphCache[3*k],mGlyphCache[3*k+1] will later be rendered with mFontName[mGlyphCache[3*k+2]]
-    // Note: font identifier is internally an ASCII digit to avoid the null char issue
+    // See if this char uses external fonts; e.g., if the 2nd glyph is taken
+    // from the external font '1', the property line looks like
+    // \uNNNN = \uNNNN\uNNNN@1\uNNNN.
+    // This is where mGlyphCache is pre-processed to explicitly store all glyph
+    // codes as combined pairs of 'code@font', excluding the '@' separator. This
+    // means that mGlyphCache[3*k],mGlyphCache[3*k+1] will later be rendered
+    // with mFontName[mGlyphCache[3*k+2]]
+    // Note: font identifier is internally an ASCII digit to avoid the null
+    // char issue
     nsAutoString buffer;
     PRInt32 length = value.Length();
     PRInt32 i = 0; // index in value
     PRInt32 j = 0; // part/variant index
     while (i < length) {
       PRUnichar code = value[i];
       ++i;
       buffer.Append(code);
@@ -357,19 +374,21 @@ nsGlyphTable::ElementAt(nsPresContext* a
   PRUint32 length = mGlyphCache.Length();
   if (aChar->mParent) {
     nsMathMLChar* child = aChar->mParent->mSibling;
     // XXXkt composite chars can't have size variants
     while (child && (child != aChar)) {
       offset += 5; // skip the 4 partial glyphs + the whitespace separator
       child = child->mSibling;
     }
-    length = 3*(offset + 4); // stay confined in the 4 partial glyphs of this child
+    // stay confined in the 4 partial glyphs of this child
+    length = 3*(offset + 4);
   }
-  PRUint32 index = 3*(offset + aPosition); // 3* is to account for the code@font pairs
+  // 3* is to account for the code@font pairs
+  PRUint32 index = 3*(offset + aPosition);
   if (index+2 >= length) return kNullGlyph;
   nsGlyphCode ch;
   ch.code[0] = mGlyphCache.CharAt(index);
   ch.code[1] = mGlyphCache.CharAt(index + 1);
   ch.font = mGlyphCache.CharAt(index + 2);
   return ch.code[0] == PRUnichar(0xFFFD) ? kNullGlyph : ch;
 }
 
@@ -414,17 +433,17 @@ nsGlyphTable::HasPartsOf(nsPresContext* 
 {
   return GlueOf(aPresContext, aChar).Exists() ||
     TopOf(aPresContext, aChar).Exists() ||
     BottomOf(aPresContext, aChar).Exists() ||
     MiddleOf(aPresContext, aChar).Exists() ||
     IsComposite(aPresContext, aChar);
 }
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // This is the list of all the applicable glyph tables.
 // We will maintain a single global instance that will only reveal those
 // glyph tables that are associated to fonts currently installed on the
 // user' system. The class is an XPCOM shutdown observer to allow us to
 // free its allocated data at shutdown
 
 class nsGlyphTableList : public nsIObserver
 {
@@ -470,17 +489,17 @@ private:
   }
 
   // List of glyph tables;
   nsTArray<nsGlyphTable> mTableList;
 };
 
 NS_IMPL_ISUPPORTS1(nsGlyphTableList, nsIObserver)
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // Here is the global list of applicable glyph tables that we will be using
 static nsGlyphTableList* gGlyphTableList = nullptr;
 
 static bool gInitialized = false;
 
 // XPCOM shutdown observer
 NS_IMETHODIMP
 nsGlyphTableList::Observe(nsISupports*     aSubject,
@@ -562,17 +581,17 @@ nsGlyphTableList::GetGlyphTableFor(const
     if (fontName.Equals(aFamily, nsCaseInsensitiveStringComparator())) {
       return glyphTable;
     }
   }
   // Fall back to default Unicode table
   return &mUnicodeTable;
 }
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 
 // Lookup the preferences:
 // "font.mathfont-family.\uNNNN.base"     -- fonts for the base size
 // "font.mathfont-family.\uNNNN.variants" -- fonts for larger glyphs
 // "font.mathfont-family.\uNNNN.parts"    -- fonts for partial glyphs
 // Given the char code and mode of stretch, retrieve the preferred extension
 // font families.
 static bool
@@ -581,17 +600,18 @@ GetFontExtensionPref(PRUnichar aChar,
 {
   // initialize OUT param
   aValue.Truncate();
 
   // We are going to try two keys because some users specify their pref as 
   // user_pref("font.mathfont-family.\uNNNN.base", "...") rather than
   // user_pref("font.mathfont-family.\\uNNNN.base", "...").
   // The \uNNNN in the former is interpreted as an UTF16 escape sequence by
-  // JavaScript and is converted to the internal UTF8 string that JavaScript uses. 
+  // JavaScript and is converted to the internal UTF8 string that JavaScript
+  // uses. 
   // But clueless users who are not savvy of JavaScript have no idea as to what 
   // is going on and are baffled as to why their pref setting is not working.
   // So to save countless explanations, we are going to support both keys.
 
   static const char* kMathFontPrefix = "font.mathfont-family.";
 
   nsCAutoString extension;
   switch (aExtension)
@@ -686,17 +706,17 @@ InitGlobals(nsPresContext* aPresContext)
 
   // Parse the font list and append an entry for each family to gGlyphTableList
   nsAutoString missingFamilyList;
 
   font.EnumerateFamilies(MathFontEnumCallback, nullptr);
   return rv;
 }
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 // And now the implementation of nsMathMLChar
 
 nsStyleContext*
 nsMathMLChar::GetStyleContext() const
 {
   NS_ASSERTION(!mParent, "invalid call - not allowed for child chars");
   NS_ASSERTION(mStyleContext, "chars should always have style context");
   return mStyleContext;
@@ -742,17 +762,17 @@ nsMathMLChar::SetData(nsPresContext* aPr
   if (gGlyphTableList && (1 == mData.Length())) {
     mDirection = nsMathMLOperators::GetStretchyDirection(mData);
     // default tentative table (not the one that is necessarily going
     // to be used)
     mGlyphTable = gGlyphTableList->GetGlyphTableFor(aPresContext, this);
   }
 }
 
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 /*
  The Stretch:
  @param aContainerSize - suggested size for the stretched char
  @param aDesiredStretchSize - OUT parameter. The desired size
  after stretching. If no stretching is done, the output will
  simply give the base size.
 
  How it works?
@@ -825,17 +845,17 @@ nsMathMLChar::SetData(nsPresContext* aPr
 
  Of note:
  When the pipeline completes successfully, the desired size of the
  stretched char can actually be slightly larger or smaller than
  aContainerSize. But it is the responsibility of the caller to
  account for the spacing when setting aContainerSize, and to leave
  any extra margin when placing the stretched char.
 */
-// -----------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
 
 
 // plain TeX settings (TeXbook p.152)
 #define NS_MATHML_DELIMITER_FACTOR             0.901f
 #define NS_MATHML_DELIMITER_SHORTFALL_POINTS   5.0f
 
 static bool
 IsSizeOK(nsPresContext* aPresContext, nscoord a, nscoord b, PRUint32 aHint)
@@ -849,17 +869,18 @@ IsSizeOK(nsPresContext* aPresContext, ns
     && bool(float(NS_ABS(a - b))
               < (1.0f - NS_MATHML_DELIMITER_FACTOR) * float(b));
   // Nearer: True if 'a' is around max{ +/-10% of 'b' , 'b' - 5pt },
   // as documented in The TeXbook, Ch.17, p.152.
   // i.e. within 10% and within 5pt
   bool isNearer = false;
   if (aHint & (NS_STRETCH_NEARER | NS_STRETCH_LARGEOP)) {
     float c = NS_MAX(float(b) * NS_MATHML_DELIMITER_FACTOR,
-                     float(b) - nsPresContext::CSSPointsToAppUnits(NS_MATHML_DELIMITER_SHORTFALL_POINTS));
+                     float(b) - nsPresContext::
+                     CSSPointsToAppUnits(NS_MATHML_DELIMITER_SHORTFALL_POINTS));
     isNearer = bool(float(NS_ABS(b - a)) <= (float(b) - c));
   }
   // Smaller: Mainly for transitory use, to compare two candidate
   // choices
   bool isSmaller =
     (aHint & NS_STRETCH_SMALLER)
     && bool((float(a) >= (NS_MATHML_DELIMITER_FACTOR * float(b)))
               && (a <= b));
@@ -1173,17 +1194,18 @@ nsMathMLChar::StretchEnumContext::TryVar
     }
 
     // if largeopOnly is set, break now
     if (largeopOnly) break;
     ++size;
   }
 
   return haveBetter &&
-    (largeopOnly || IsSizeOK(mPresContext, bestSize, mTargetSize, mStretchHint));
+    (largeopOnly ||
+     IsSizeOK(mPresContext, bestSize, mTargetSize, mStretchHint));
 }
 
 // 3. Build by parts.
 // Returns true if the size is OK, false to keep searching.
 // Always updates the char if a better match is found.
 bool
 nsMathMLChar::StretchEnumContext::TryParts(nsGlyphTable*    aGlyphTable,
                                            const nsAString& aFamily)
@@ -1310,17 +1332,18 @@ nsMathMLChar::StretchEnumContext::TryPar
       if (width < bm.width) width = bm.width;
       if (lbearing > bm.leftBearing) lbearing = bm.leftBearing;
       if (rbearing < bm.rightBearing) rbearing = bm.rightBearing;
     }
     mBoundingMetrics.width = width;
     // When maxWidth, updating ascent and descent indicates that no characters
     // larger than this character's minimum size need to be checked as they
     // will not be used.
-    mBoundingMetrics.ascent = bmdata[0].ascent; // not used except with descent for height
+    mBoundingMetrics.ascent = bmdata[0].ascent; // not used except with descent
+                                                // for height
     mBoundingMetrics.descent = computedSize - mBoundingMetrics.ascent;
     mBoundingMetrics.leftBearing = lbearing;
     mBoundingMetrics.rightBearing = rbearing;
   }
   else {
     nscoord ascent = bmdata[0].ascent;
     nscoord descent = bmdata[0].descent;
     for (PRInt32 i = 1; i < 4; i++) {
@@ -1351,17 +1374,18 @@ bool
 nsMathMLChar::StretchEnumContext::EnumCallback(const nsString& aFamily,
                                                bool aGeneric, void *aData)
 {
   StretchEnumContext* context = static_cast<StretchEnumContext*>(aData);
 
   // See if there is a special table for the family, but always use the
   // Unicode table for generic fonts.
   nsGlyphTable* glyphTable = aGeneric ?
-    &gGlyphTableList->mUnicodeTable : gGlyphTableList->GetGlyphTableFor(aFamily);
+    &gGlyphTableList->mUnicodeTable :
+    gGlyphTableList->GetGlyphTableFor(aFamily);
 
   if (context->mTablesTried.Contains(glyphTable))
     return true; // already tried this one
 
   // Check font family if it is not a generic one
   // We test with the kNullGlyph
   nsStyleContext *sc = context->mChar->mStyleContext;
   nsFont font = sc->GetStyleFont()->mFont;
@@ -1432,19 +1456,19 @@ nsMathMLChar::StretchInternal(nsPresCont
   aRenderingContext.SetFont(fm);
   aDesiredStretchSize =
     aRenderingContext.GetBoundingMetrics(mData.get(), PRUint32(mData.Length()));
 
   if (!maxWidth) {
     mUnscaledAscent = aDesiredStretchSize.ascent;
   }
 
-  ////////////////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////////
   // 1. Check the common situations where stretching is not actually needed
-  ////////////////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////////
 
   // quick return if there is nothing special about this char
   if ((aStretchDirection != direction &&
        aStretchDirection != NS_STRETCH_DIRECTION_DEFAULT) ||
       (aStretchHint & ~NS_STRETCH_MAXWIDTH) == NS_STRETCH_NONE) {
     mDirection = NS_STRETCH_DIRECTION_UNSUPPORTED;
     return NS_OK;
   }
@@ -1514,19 +1538,19 @@ nsMathMLChar::StretchInternal(nsPresCont
     // Doing Stretch() not GetMaxWidth(),
     // and not a largeop in display mode; we're done if size fits
     if ((targetSize <= 0) || 
         ((isVertical && charSize >= targetSize) ||
          IsSizeOK(aPresContext, charSize, targetSize, aStretchHint)))
       done = true;
   }
 
-  ////////////////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////////
   // 2/3. Search for a glyph or set of part glyphs of appropriate size
-  ////////////////////////////////////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////////////////////////////
 
   bool glyphFound = false;
   nsAutoString cssFamilies;
 
   if (!done) {
     font = mStyleContext->GetStyleFont()->mFont;
     cssFamilies = font.name;
   }
@@ -1722,17 +1746,18 @@ nsMathMLChar::ComposeChildren(nsPresCont
                               PRUint32             aStretchHint)
 {
   PRInt32 i = 0;
   nsMathMLChar* child;
   PRInt32 count = aGlyphTable->ChildCountOf(aPresContext, this);
   NS_ASSERTION(count, "something is wrong somewhere");
   if (!count) return NS_ERROR_FAILURE;
   // if we haven't been here before, create the linked list of children now
-  // otherwise, use what we have, adding more children as needed or deleting the extra
+  // otherwise, use what we have, adding more children as needed or deleting
+  // the extra
   nsMathMLChar* last = this;
   while ((i < count) && last->mSibling) {
     i++;
     last = last->mSibling;
   }
   while (i < count) {
     child = new nsMathMLChar(this);
     last->mSibling = child;
@@ -1748,33 +1773,37 @@ nsMathMLChar::ComposeChildren(nsPresCont
   if (NS_STRETCH_DIRECTION_HORIZONTAL == mDirection)
     splitSize.width = aTargetSize / count;
   else {
     splitSize.ascent = aTargetSize / (count * 2);
     splitSize.descent = splitSize.ascent;
   }
   nscoord dx = 0, dy = 0;
   for (i = 0, child = mSibling; child; child = child->mSibling, i++) {
-    // child chars should just inherit our values - which may change between calls...
+    // child chars should just inherit our values - which may change between
+    // calls...
     child->mData = mData;
     child->mDirection = mDirection;
     child->mStyleContext = mStyleContext;
     child->mGlyphTable = aGlyphTable; // the child is associated to this table
     child->mMirrored = mMirrored;
     // there goes the Stretch() ...
     nsBoundingMetrics childSize;
     nsresult rv = child->Stretch(aPresContext, aRenderingContext, mDirection,
                                  splitSize, childSize, aStretchHint, mMirrored);
-    // check if something went wrong or the child couldn't fit in the alloted space
-    if (NS_FAILED(rv) || (NS_STRETCH_DIRECTION_UNSUPPORTED == child->mDirection)) {
+    // check if something went wrong or the child couldn't fit in the alloted
+    // space
+    if (NS_FAILED(rv) ||
+        (NS_STRETCH_DIRECTION_UNSUPPORTED == child->mDirection)) {
       delete mSibling; // don't leave a dangling list behind ...
       mSibling = nullptr;
       return NS_ERROR_FAILURE;
     }
-    child->SetRect(nsRect(dx, dy, childSize.width, childSize.ascent+childSize.descent));
+    child->SetRect(nsRect(dx, dy, childSize.width,
+                          childSize.ascent+childSize.descent));
     if (0 == i)
       aCompositeSize = childSize;
     else {
       if (NS_STRETCH_DIRECTION_HORIZONTAL == mDirection)
         aCompositeSize += childSize;
       else {
         aCompositeSize.descent += childSize.ascent + childSize.descent;
         if (aCompositeSize.leftBearing > childSize.leftBearing)
@@ -1822,17 +1851,18 @@ void nsDisplayMathMLSelectionRect::Paint
   aCtx->FillRect(mRect + ToReferenceFrame());
 }
 
 class nsDisplayMathMLCharBackground : public nsDisplayItem {
 public:
   nsDisplayMathMLCharBackground(nsDisplayListBuilder* aBuilder,
                                 nsIFrame* aFrame, const nsRect& aRect,
                                 nsStyleContext* aStyleContext)
-    : nsDisplayItem(aBuilder, aFrame), mStyleContext(aStyleContext), mRect(aRect) {
+    : nsDisplayItem(aBuilder, aFrame), mStyleContext(aStyleContext),
+      mRect(aRect) {
     MOZ_COUNT_CTOR(nsDisplayMathMLCharBackground);
   }
 #ifdef NS_BUILD_REFCNT_LOGGING
   virtual ~nsDisplayMathMLCharBackground() {
     MOZ_COUNT_DTOR(nsDisplayMathMLCharBackground);
   }
 #endif
 
@@ -1891,17 +1921,20 @@ public:
   NS_DISPLAY_DECL_NAME("MathMLCharForeground", TYPE_MATHML_CHAR_FOREGROUND)
 
   virtual nsRect GetComponentAlphaBounds(nsDisplayListBuilder* aBuilder)
   {
     bool snap;
     return GetBounds(aBuilder, &snap);
   }
   
-  virtual PRUint32 GetPerFrameKey() { return (mIndex << nsDisplayItem::TYPE_BITS) | nsDisplayItem::GetPerFrameKey(); }
+  virtual PRUint32 GetPerFrameKey() {
+    return (mIndex << nsDisplayItem::TYPE_BITS)
+      | nsDisplayItem::GetPerFrameKey();
+  }
 
 private:
   nsMathMLChar* mChar;
   PRUint32      mIndex;
   bool          mIsSelected;
 };
 
 #ifdef DEBUG
@@ -1971,33 +2004,35 @@ nsMathMLChar::Display(nsDisplayListBuild
         nsDisplayMathMLSelectionRect(aBuilder, aForFrame, *aSelectedRect));
     NS_ENSURE_SUCCESS(rv, rv);
   }
   else if (mRect.width && mRect.height) {
     const nsStyleBackground* backg = styleContext->GetStyleBackground();
     if (styleContext != parentContext &&
         NS_GET_A(backg->mBackgroundColor) > 0) {
       rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
-          nsDisplayMathMLCharBackground(aBuilder, aForFrame, mRect, styleContext));
+          nsDisplayMathMLCharBackground(aBuilder, aForFrame, mRect,
+                                        styleContext));
       NS_ENSURE_SUCCESS(rv, rv);
     }
     //else
     //  our container frame will take care of painting its background
 
 #if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
     // for visual debug
     rv = aLists.BorderBackground()->AppendToTop(new (aBuilder)
         nsDisplayMathMLCharDebug(aBuilder, aForFrame, mRect));
     NS_ENSURE_SUCCESS(rv, rv);
 #endif
   }
   return aLists.Content()->AppendNewToTop(new (aBuilder)
         nsDisplayMathMLCharForeground(aBuilder, aForFrame, this,
                                       aIndex,
-                                      aSelectedRect && !aSelectedRect->IsEmpty()));
+                                      aSelectedRect &&
+                                      !aSelectedRect->IsEmpty()));
 }
 
 void
 nsMathMLChar::ApplyTransforms(nsRenderingContext& aRenderingContext, nsRect &r)
 {
   // apply the transforms
   if (mMirrored) {
     aRenderingContext.Translate(r.TopRight());
@@ -2065,26 +2100,26 @@ nsMathMLChar::PaintForeground(nsPresCont
       aRenderingContext.DrawString(mGlyph.code, mGlyph.Length(),
                                    0, mUnscaledAscent);
     }
     else { // paint by parts
       if (NS_STRETCH_DIRECTION_VERTICAL == mDirection)
         PaintVertically(aPresContext, aRenderingContext, theFont, styleContext,
                         mGlyphTable, r);
       else if (NS_STRETCH_DIRECTION_HORIZONTAL == mDirection)
-        PaintHorizontally(aPresContext, aRenderingContext, theFont, styleContext,
-                          mGlyphTable, r);
+        PaintHorizontally(aPresContext, aRenderingContext, theFont,
+                          styleContext, mGlyphTable, r);
     }
   }
 
   aRenderingContext.PopState();
 }
 
-/* =================================================================================
-  And now the helper routines that actually do the job of painting the char by parts
+/* =============================================================================
+  Helper routines that actually do the job of painting the char by parts
  */
 
 class AutoPushClipRect {
   nsRenderingContext& mCtx;
 public:
   AutoPushClipRect(nsRenderingContext& aCtx, const nsRect& aRect)
     : mCtx(aCtx) {
     mCtx.PushState();
@@ -2236,17 +2271,18 @@ nsMathMLChar::PaintVertically(nsPresCont
       }
     }
   }
 
   ///////////////
   // fill the gap between top and middle, and between middle and bottom.
   if (!chGlue.Exists()) { // null glue : draw a rule
     // figure out the dimensions of the rule to be drawn :
-    // set lbearing to rightmost lbearing among the two current successive parts.
+    // set lbearing to rightmost lbearing among the two current successive
+    // parts.
     // set rbearing to leftmost rbearing among the two current successive parts.
     // this not only satisfies the convention used for over/underbraces
     // in TeX, but also takes care of broken fonts like the stretchy integral
     // in Symbol for small font sizes in unix.
     nscoord lbearing, rbearing;
     PRInt32 first = 0, last = 1;
     while (last <= bottom) {
       if (chdata[last].Exists()) {
--- a/layout/mathml/nsMathMLChar.h
+++ b/layout/mathml/nsMathMLChar.h
@@ -25,20 +25,21 @@ enum {
   NS_STRETCH_LARGEOP  = 0x10,
   NS_STRETCH_INTEGRAL  = 0x20,
 
   // Intended for internal use:
   // Find the widest metrics that might be returned from a vertical stretch
   NS_STRETCH_MAXWIDTH = 0x40
 };
 
-// A single glyph in our internal representation is characterized by a 'code@font' 
-// pair. The 'code' is interpreted as a Unicode point or as the direct glyph index
-// (depending on the type of nsGlyphTable where this comes from). The 'font' is a
-// numeric identifier given to the font to which the glyph belongs.
+// A single glyph in our internal representation is characterized by a
+// 'code@font' pair. The 'code' is interpreted as a Unicode point or as the
+// direct glyph index (depending on the type of nsGlyphTable where this comes
+// from). The 'font' is a numeric identifier given to the font to which the
+// glyph belongs.
 struct nsGlyphCode {
   PRUnichar code[2]; 
   PRInt32   font;
 
   PRInt32 Length() { return (code[1] == PRUnichar('\0') ? 1 : 2); }
   bool Exists() const
   {
     return (code[0] != 0);
@@ -49,42 +50,44 @@ struct nsGlyphCode {
             other.font == font);
   }
   bool operator!=(const nsGlyphCode& other) const
   {
     return ! operator==(other);
   }
 };
 
-// Class used to handle stretchy symbols (accent, delimiter and boundary symbols).
+// Class used to handle stretchy symbols (accent, delimiter and boundary
+// symbols).
 // There are composite characters that need to be built recursively from other
 // characters. Since these are rare we use a light-weight mechanism to handle
 // them. Specifically, as need arises we append a singly-linked list of child
 // chars with their mParent pointing to the first element in the list, except in
 // the originating first element itself where it points to null. mSibling points
 // to the next element in the list. Since the originating first element is the
-// parent of the others, we call it the "root" char of the list. Testing !mParent
-// tells whether you are that "root" during the recursion. The parent delegates
-// most of the tasks to the children.
+// parent of the others, we call it the "root" char of the list. Testing
+// !mParent tells whether you are that "root" during the recursion. The parent
+// delegates most of the tasks to the children.
 class nsMathMLChar
 {
 public:
   // constructor and destructor
   nsMathMLChar(nsMathMLChar* aParent = nullptr) {
     MOZ_COUNT_CTOR(nsMathMLChar);
     mStyleContext = nullptr;
     mSibling = nullptr;
     mParent = aParent;
     mUnscaledAscent = 0;
     mScaleX = mScaleY = 1.0;
     mDrawNormal = true;
     mMirrored = false;
   }
 
-  ~nsMathMLChar() { // not a virtual destructor: this class is not intended to be subclassed
+  // not a virtual destructor: this class is not intended to be subclassed
+  ~nsMathMLChar() {
     MOZ_COUNT_DTOR(nsMathMLChar);
     // there is only one style context owned by the "root" char
     // and it may be used by child chars as well
     if (!mParent && mStyleContext) { // only the "root" need to release it
       mStyleContext->Release();
     }
     if (mSibling) {
       delete mSibling;
@@ -145,17 +148,18 @@ public:
   GetRect(nsRect& aRect) {
     aRect = mRect;
   }
 
   void
   SetRect(const nsRect& aRect) {
     mRect = aRect;
     // shift the orgins of child chars if any 
-    if (!mParent && mSibling) { // only a "root" having child chars can enter here
+    if (!mParent && mSibling) { // only a "root" having child chars can
+                                // enter here
       for (nsMathMLChar* child = mSibling; child; child = child->mSibling) {
         nsRect rect; 
         child->GetRect(rect);
         rect.MoveBy(mRect.x, mRect.y);
         child->SetRect(rect);
       }
     }
   }