Bug 983019 - Fix a typo in the aMetrics->maxDescent initialization when we failed to create the Cairo font. Also fix a typo so that aSpaceGlyph out-param is assigned as intended. And make the code easier to read. r=jfkthame
authorMats Palmgren <matspal@gmail.com>
Fri, 14 Mar 2014 10:37:41 -0400
changeset 191896 4832153571bc9547a70cfbeb4cf288e21b1f9e03
parent 191895 b7761b7514f73fac04de664f8db546f400f2bd6e
child 191897 6da2b893be686242751693f903aea922347f4114
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs983019
milestone30.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 983019 - Fix a typo in the aMetrics->maxDescent initialization when we failed to create the Cairo font. Also fix a typo so that aSpaceGlyph out-param is assigned as intended. And make the code easier to read. r=jfkthame
gfx/thebes/gfxFT2Utils.cpp
--- a/gfx/thebes/gfxFT2Utils.cpp
+++ b/gfx/thebes/gfxFT2Utils.cpp
@@ -48,37 +48,39 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Me
                              uint32_t* aSpaceGlyph)
 {
     NS_PRECONDITION(aMetrics != nullptr, "aMetrics must not be NULL");
     NS_PRECONDITION(aSpaceGlyph != nullptr, "aSpaceGlyph must not be NULL");
 
     if (MOZ_UNLIKELY(!mFace)) {
         // No face.  This unfortunate situation might happen if the font
         // file is (re)moved at the wrong time.
-        aMetrics->emHeight = mGfxFont->GetStyle()->size;
-        aMetrics->emAscent = 0.8 * aMetrics->emHeight;
-        aMetrics->emDescent = 0.2 * aMetrics->emHeight;
-        aMetrics->maxAscent = aMetrics->emAscent;
-        aMetrics->maxDescent = aMetrics->maxDescent;
-        aMetrics->maxHeight = aMetrics->emHeight;
+        const gfxFloat emHeight = mGfxFont->GetStyle()->size;
+        aMetrics->emHeight = emHeight;
+        aMetrics->maxAscent = aMetrics->emAscent = 0.8 * emHeight;
+        aMetrics->maxDescent = aMetrics->emDescent = 0.2 * emHeight;
+        aMetrics->maxHeight = emHeight;
         aMetrics->internalLeading = 0.0;
-        aMetrics->externalLeading = 0.2 * aMetrics->emHeight;
-        aSpaceGlyph = 0;
-        aMetrics->spaceWidth = 0.5 * aMetrics->emHeight;
-        aMetrics->maxAdvance = aMetrics->spaceWidth;
-        aMetrics->aveCharWidth = aMetrics->spaceWidth;
-        aMetrics->zeroOrAveCharWidth = aMetrics->spaceWidth;
-        aMetrics->xHeight = 0.5 * aMetrics->emHeight;
-        aMetrics->underlineSize = aMetrics->emHeight / 14.0;
-        aMetrics->underlineOffset = -aMetrics->underlineSize;
-        aMetrics->strikeoutOffset = 0.25 * aMetrics->emHeight;
-        aMetrics->strikeoutSize = aMetrics->underlineSize;
-        aMetrics->superscriptOffset = aMetrics->xHeight;
-        aMetrics->subscriptOffset = aMetrics->xHeight;
+        aMetrics->externalLeading = 0.2 * emHeight;
+        const gfxFloat spaceWidth = 0.5 * emHeight;
+        aMetrics->spaceWidth = spaceWidth;
+        aMetrics->maxAdvance = spaceWidth;
+        aMetrics->aveCharWidth = spaceWidth;
+        aMetrics->zeroOrAveCharWidth = spaceWidth;
+        const gfxFloat xHeight = 0.5 * emHeight;
+        aMetrics->xHeight = xHeight;
+        aMetrics->superscriptOffset = xHeight;
+        aMetrics->subscriptOffset = xHeight;
+        const gfxFloat underlineSize = emHeight / 14.0;
+        aMetrics->underlineSize = underlineSize;
+        aMetrics->underlineOffset = -underlineSize;
+        aMetrics->strikeoutOffset = 0.25 * emHeight;
+        aMetrics->strikeoutSize = underlineSize;
 
+        *aSpaceGlyph = 0;
         return;
     }
 
     const FT_Size_Metrics& ftMetrics = mFace->size->metrics;
 
     gfxFloat emHeight;
     // Scale for vertical design metric conversion: pixels per design unit.
     // If this remains at 0.0, we can't use metrics from OS/2 etc.