Bug 174055, part 6: eliminate pointless nsresult return values.
authorZack Weinberg <zackw@panix.com>
Thu, 07 Apr 2011 21:18:43 -0700
changeset 68137 90a2c72237e21712e6a536a5e04d39032ee0fe03
parent 68136 b339ef823c297bd045f56e37caa9bd7f65d5461c
child 68138 ea77c716787080876c7213cb14c0d61eacaba8ec
push id19518
push userzackw@panix.com
push dateThu, 14 Apr 2011 17:49:38 +0000
treeherdermozilla-central@ee377a1a5e31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs174055
milestone6.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 174055, part 6: eliminate pointless nsresult return values.
content/events/src/nsEventStateManager.cpp
gfx/src/nsFontMetrics.cpp
gfx/src/nsFontMetrics.h
gfx/src/nsRenderingContext.cpp
gfx/src/nsRenderingContext.h
gfx/src/nsThebesDeviceContext.cpp
layout/base/nsCaret.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsPresShell.cpp
layout/forms/nsListControlFrame.cpp
layout/forms/nsTextControlFrame.cpp
layout/generic/nsBRFrame.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsHTMLReflowState.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsInlineFrame.cpp
layout/generic/nsLineLayout.cpp
layout/generic/nsPageFrame.cpp
layout/generic/nsTextFrameThebes.cpp
layout/mathml/nsMathMLContainerFrame.cpp
layout/mathml/nsMathMLFrame.cpp
layout/mathml/nsMathMLFrame.h
layout/mathml/nsMathMLTokenFrame.cpp
layout/mathml/nsMathMLmencloseFrame.cpp
layout/mathml/nsMathMLmfencedFrame.cpp
layout/mathml/nsMathMLmfracFrame.cpp
layout/mathml/nsMathMLmmultiscriptsFrame.cpp
layout/mathml/nsMathMLmoFrame.cpp
layout/mathml/nsMathMLmoverFrame.cpp
layout/mathml/nsMathMLmrootFrame.cpp
layout/mathml/nsMathMLmsubFrame.cpp
layout/mathml/nsMathMLmsubsupFrame.cpp
layout/mathml/nsMathMLmsupFrame.cpp
layout/mathml/nsMathMLmunderFrame.cpp
layout/mathml/nsMathMLmunderoverFrame.cpp
layout/style/nsRuleNode.cpp
layout/svg/base/src/nsSVGUtils.cpp
layout/xul/base/src/nsListBoxBodyFrame.cpp
layout/xul/base/src/nsTextBoxFrame.cpp
layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -2487,20 +2487,19 @@ GetScrollableLineHeight(nsIFrame* aTarge
       return sf->GetLineScrollAmount().height;
   }
 
   // Fall back to the font height of the target frame.
   const nsStyleFont* font = aTargetFrame->GetStyleFont();
   const nsFont& f = font->mFont;
   nsRefPtr<nsFontMetrics> fm = aTargetFrame->PresContext()->GetMetricsFor(f);
   NS_ASSERTION(fm, "FontMetrics is null!");
-  nscoord lineHeight = 0;
   if (fm)
-    fm->GetMaxHeight(lineHeight);
-  return lineHeight;
+    return fm->MaxHeight();
+  return 0;
 }
 
 void
 nsEventStateManager::SendLineScrollEvent(nsIFrame* aTargetFrame,
                                          nsMouseScrollEvent* aEvent,
                                          nsPresContext* aPresContext,
                                          nsEventStatus* aStatus,
                                          PRInt32 aNumLines)
--- a/gfx/src/nsFontMetrics.cpp
+++ b/gfx/src/nsFontMetrics.cpp
@@ -35,50 +35,68 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsFontMetrics.h"
 #include "nsBoundingMetrics.h"
 #include "nsRenderingContext.h"
 #include "nsThebesDeviceContext.h"
+#include "gfxTextRunCache.h"
 
-class AutoTextRun {
+namespace {
+
+class AutoTextRun : public gfxTextRunCache::AutoTextRun {
 public:
     AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
-                const char* aString, PRInt32 aLength) {
-        mTextRun = gfxTextRunCache::MakeTextRun(
+                const char* aString, PRInt32 aLength)
+        : gfxTextRunCache::AutoTextRun(gfxTextRunCache::MakeTextRun(
             reinterpret_cast<const PRUint8*>(aString), aLength,
             aMetrics->GetThebesFontGroup(), aRC->ThebesContext(),
             aMetrics->AppUnitsPerDevPixel(),
-            ComputeFlags(aMetrics));
-    }
+            ComputeFlags(aMetrics)))
+    {}
+
     AutoTextRun(nsFontMetrics* aMetrics, nsRenderingContext* aRC,
-                const PRUnichar* aString, PRInt32 aLength) {
-        mTextRun = gfxTextRunCache::MakeTextRun(
+                const PRUnichar* aString, PRInt32 aLength)
+        : gfxTextRunCache::AutoTextRun(gfxTextRunCache::MakeTextRun(
             aString, aLength, aMetrics->GetThebesFontGroup(),
             aRC->ThebesContext(),
             aMetrics->AppUnitsPerDevPixel(),
-            ComputeFlags(aMetrics));
-    }
-    gfxTextRun* operator->() { return mTextRun.get(); }
-    gfxTextRun* get() { return mTextRun.get(); }
+            ComputeFlags(aMetrics)))
+    {}
 
 private:
-    gfxTextRunCache::AutoTextRun mTextRun;
-
     static PRUint32 ComputeFlags(nsFontMetrics* aMetrics) {
         PRUint32 flags = 0;
         if (aMetrics->GetRightToLeftTextRunMode()) {
             flags |= gfxTextRunFactory::TEXT_IS_RTL;
         }
         return flags;
     }
 };
 
+class StubPropertyProvider : public gfxTextRun::PropertyProvider {
+public:
+    virtual void GetHyphenationBreaks(PRUint32 aStart, PRUint32 aLength,
+                                      PRPackedBool* aBreakBefore) {
+        NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
+    }
+    virtual gfxFloat GetHyphenWidth() {
+        NS_ERROR("This shouldn't be called because we never enable hyphens");
+        return 0;
+    }
+    virtual void GetSpacing(PRUint32 aStart, PRUint32 aLength,
+                            Spacing* aSpacing) {
+        NS_ERROR("This shouldn't be called because we never enable spacing");
+    }
+};
+
+} // anon namespace
+
 nsFontMetrics::nsFontMetrics()
 {
     mFontStyle = nsnull;
     mFontGroup = nsnull;
 }
 
 nsFontMetrics::~nsFontMetrics()
 {
@@ -113,68 +131,61 @@ nsFontMetrics::Init(const nsFont& aFont,
         gfxPlatform::GetPlatform()->CreateFontGroup(aFont.name, mFontStyle,
                                                     aUserFontSet);
     if (mFontGroup->FontListLength() < 1)
         return NS_ERROR_UNEXPECTED;
 
     return NS_OK;
 }
 
-nsresult
+void
 nsFontMetrics::Destroy()
 {
     mDeviceContext = nsnull;
-    return NS_OK;
 }
 
 // XXXTODO get rid of this macro
 #define ROUND_TO_TWIPS(x) (nscoord)floor(((x) * mP2A) + 0.5)
 #define CEIL_TO_TWIPS(x) (nscoord)NS_ceil((x) * mP2A)
 
 const gfxFont::Metrics& nsFontMetrics::GetMetrics() const
 {
     return mFontGroup->GetFontAt(0)->GetMetrics();
 }
 
-nsresult
-nsFontMetrics::GetXHeight(nscoord& aResult)
+nscoord
+nsFontMetrics::XHeight()
 {
-    aResult = ROUND_TO_TWIPS(GetMetrics().xHeight);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().xHeight);
 }
 
-nsresult
-nsFontMetrics::GetSuperscriptOffset(nscoord& aResult)
+nscoord
+nsFontMetrics::SuperscriptOffset()
 {
-    aResult = ROUND_TO_TWIPS(GetMetrics().superscriptOffset);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().superscriptOffset);
 }
 
-nsresult
-nsFontMetrics::GetSubscriptOffset(nscoord& aResult)
+nscoord
+nsFontMetrics::SubscriptOffset()
 {
-    aResult = ROUND_TO_TWIPS(GetMetrics().subscriptOffset);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().subscriptOffset);
 }
 
-nsresult
+void
 nsFontMetrics::GetStrikeout(nscoord& aOffset, nscoord& aSize)
 {
     aOffset = ROUND_TO_TWIPS(GetMetrics().strikeoutOffset);
     aSize = ROUND_TO_TWIPS(GetMetrics().strikeoutSize);
-    return NS_OK;
 }
 
-nsresult
+void
 nsFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize)
 {
     aOffset = ROUND_TO_TWIPS(mFontGroup->GetUnderlineOffset());
     aSize = ROUND_TO_TWIPS(GetMetrics().underlineSize);
-
-    return NS_OK;
 }
 
 // GetMaxAscent/GetMaxDescent/GetMaxHeight must contain the
 // text-decoration lines drawable area. See bug 421353.
 // BE CAREFUL for rounding each values. The logic MUST be same as
 // nsCSSRendering::GetTextDecorationRectInternal's.
 
 static gfxFloat ComputeMaxDescent(const gfxFont::Metrics& aMetrics,
@@ -186,246 +197,183 @@ static gfxFloat ComputeMaxDescent(const 
     return PR_MAX(minDescent, aMetrics.maxDescent);
 }
 
 static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics)
 {
     return NS_floor(aMetrics.maxAscent + 0.5);
 }
 
-nsresult
-nsFontMetrics::GetInternalLeading(nscoord &aLeading)
+nscoord
+nsFontMetrics::InternalLeading()
 {
-    aLeading = ROUND_TO_TWIPS(GetMetrics().internalLeading);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().internalLeading);
 }
 
-nsresult
-nsFontMetrics::GetExternalLeading(nscoord &aLeading)
+nscoord
+nsFontMetrics::ExternalLeading()
 {
-    aLeading = ROUND_TO_TWIPS(GetMetrics().externalLeading);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().externalLeading);
 }
 
-nsresult
-nsFontMetrics::GetEmHeight(nscoord &aHeight)
+nscoord
+nsFontMetrics::EmHeight()
 {
-    aHeight = ROUND_TO_TWIPS(GetMetrics().emHeight);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().emHeight);
 }
 
-nsresult
-nsFontMetrics::GetEmAscent(nscoord &aAscent)
+nscoord
+nsFontMetrics::EmAscent()
 {
-    aAscent = ROUND_TO_TWIPS(GetMetrics().emAscent);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().emAscent);
 }
 
-nsresult
-nsFontMetrics::GetEmDescent(nscoord &aDescent)
+nscoord
+nsFontMetrics::EmDescent()
 {
-    aDescent = ROUND_TO_TWIPS(GetMetrics().emDescent);
-    return NS_OK;
+    return ROUND_TO_TWIPS(GetMetrics().emDescent);
 }
 
-nsresult
-nsFontMetrics::GetMaxHeight(nscoord &aHeight)
+nscoord
+nsFontMetrics::MaxHeight()
 {
-    aHeight = CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) +
+    return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) +
         CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
-    return NS_OK;
 }
 
-nsresult
-nsFontMetrics::GetMaxAscent(nscoord &aAscent)
+nscoord
+nsFontMetrics::MaxAscent()
 {
-    aAscent = CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics()));
-    return NS_OK;
+    return CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics()));
 }
 
-nsresult
-nsFontMetrics::GetMaxDescent(nscoord &aDescent)
+nscoord
+nsFontMetrics::MaxDescent()
 {
-    aDescent = CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
-    return NS_OK;
+    return CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
 }
 
-nsresult
-nsFontMetrics::GetMaxAdvance(nscoord &aAdvance)
+nscoord
+nsFontMetrics::MaxAdvance()
 {
-    aAdvance = CEIL_TO_TWIPS(GetMetrics().maxAdvance);
-    return NS_OK;
+    return CEIL_TO_TWIPS(GetMetrics().maxAdvance);
 }
 
-nsresult
-nsFontMetrics::GetLanguage(nsIAtom** aLanguage)
+nscoord
+nsFontMetrics::AveCharWidth()
 {
-    *aLanguage = mLanguage;
-    NS_IF_ADDREF(*aLanguage);
-    return NS_OK;
+    // Use CEIL instead of ROUND for consistency with GetMaxAdvance
+    return CEIL_TO_TWIPS(GetMetrics().aveCharWidth);
 }
 
-nsresult
-nsFontMetrics::GetAveCharWidth(nscoord& aAveCharWidth)
+nscoord
+nsFontMetrics::SpaceWidth()
 {
-    // Use CEIL instead of ROUND for consistency with GetMaxAdvance
-    aAveCharWidth = CEIL_TO_TWIPS(GetMetrics().aveCharWidth);
-    return NS_OK;
+    return CEIL_TO_TWIPS(GetMetrics().spaceWidth);
 }
 
-nsresult
-nsFontMetrics::GetSpaceWidth(nscoord& aSpaceCharWidth)
+already_AddRefed<nsIAtom>
+nsFontMetrics::GetLanguage()
 {
-    aSpaceCharWidth = CEIL_TO_TWIPS(GetMetrics().spaceWidth);
-    return NS_OK;
+    nsIAtom* result = mLanguage.get();
+    NS_IF_ADDREF(result);
+    return result;
 }
 
 PRInt32
 nsFontMetrics::GetMaxStringLength()
 {
     const gfxFont::Metrics& m = GetMetrics();
     const double x = 32767.0 / m.maxAdvance;
     PRInt32 len = (PRInt32)floor(x);
     return PR_MAX(1, len);
 }
 
-class StubPropertyProvider : public gfxTextRun::PropertyProvider {
-public:
-    virtual void GetHyphenationBreaks(PRUint32 aStart, PRUint32 aLength,
-                                      PRPackedBool* aBreakBefore) {
-        NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
-    }
-    virtual gfxFloat GetHyphenWidth() {
-        NS_ERROR("This shouldn't be called because we never enable hyphens");
-        return 0;
-    }
-    virtual void GetSpacing(PRUint32 aStart, PRUint32 aLength,
-                            Spacing* aSpacing) {
-        NS_ERROR("This shouldn't be called because we never enable spacing");
-    }
-};
-
-nsresult
-nsFontMetrics::GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth,
+nscoord
+nsFontMetrics::GetWidth(const char* aString, PRUint32 aLength,
                         nsRenderingContext *aContext)
 {
-    if (aLength == 0) {
-        aWidth = 0;
-        return NS_OK;
-    }
+    if (aLength == 0)
+        return 0;
 
-    // callers that hit this should not be so stupid
-    if ((aLength == 1) && (aString[0] == ' '))
-        return GetSpaceWidth(aWidth);
+    if (aLength == 1 && aString[0] == ' ')
+        return SpaceWidth();
 
     StubPropertyProvider provider;
     AutoTextRun textRun(this, aContext, aString, aLength);
-    if (!textRun.get())
-        return NS_ERROR_FAILURE;
-
-    aWidth = NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
-
-    return NS_OK;
+    return NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
 }
 
-nsresult
+nscoord
 nsFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength,
-                        nscoord& aWidth, PRInt32 *aFontID,
                         nsRenderingContext *aContext)
 {
-    if (aLength == 0) {
-        aWidth = 0;
-        return NS_OK;
-    }
+    if (aLength == 0)
+        return 0;
 
-    // callers that hit this should not be so stupid
-    if ((aLength == 1) && (aString[0] == ' '))
-        return GetSpaceWidth(aWidth);
+    if (aLength == 1 && aString[0] == ' ')
+        return SpaceWidth();
 
     StubPropertyProvider provider;
     AutoTextRun textRun(this, aContext, aString, aLength);
-    if (!textRun.get())
-        return NS_ERROR_FAILURE;
-
-    aWidth = NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
-
-    return NS_OK;
+    return NSToCoordRound(textRun->GetAdvanceWidth(0, aLength, &provider));
 }
 
 // Draw a string using this font handle on the surface passed in.
-nsresult
+void
 nsFontMetrics::DrawString(const char *aString, PRUint32 aLength,
                           nscoord aX, nscoord aY,
-                          const nscoord* aSpacing,
                           nsRenderingContext *aContext)
 {
     if (aLength == 0)
-        return NS_OK;
+        return;
 
-    NS_ASSERTION(!aSpacing, "Spacing not supported here");
     StubPropertyProvider provider;
     AutoTextRun textRun(this, aContext, aString, aLength);
-    if (!textRun.get())
-        return NS_ERROR_FAILURE;
     gfxPoint pt(aX, aY);
     if (mTextRunRTL) {
         pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
     }
-    textRun->Draw(aContext->ThebesContext(), pt, 0, aLength,
-                  &provider, nsnull);
-    return NS_OK;
+    textRun->Draw(aContext->ThebesContext(), pt, 0, aLength, &provider, nsnull);
 }
 
-nsresult
+void
 nsFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
                           nscoord aX, nscoord aY,
                           nsRenderingContext *aContext,
                           nsRenderingContext *aTextRunConstructionContext)
 {
     if (aLength == 0)
-        return NS_OK;
+        return;
 
     StubPropertyProvider provider;
     AutoTextRun textRun(this, aTextRunConstructionContext, aString, aLength);
-    if (!textRun.get())
-        return NS_ERROR_FAILURE;
     gfxPoint pt(aX, aY);
     if (mTextRunRTL) {
         pt.x += textRun->GetAdvanceWidth(0, aLength, &provider);
     }
-    textRun->Draw(aContext->ThebesContext(), pt, 0, aLength,
-                  &provider, nsnull);
-    return NS_OK;
+    textRun->Draw(aContext->ThebesContext(), pt, 0, aLength, &provider, nsnull);
 }
 
 #ifdef MOZ_MATHML
-nsresult
+nsBoundingMetrics
 nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
-                                  nsRenderingContext *aContext,
-                                  nsBoundingMetrics &aBoundingMetrics)
+                                  nsRenderingContext *aContext)
 {
-    if (aLength == 0) {
-        aBoundingMetrics = nsBoundingMetrics();
-        return NS_OK;
-    }
+    if (aLength == 0)
+        return nsBoundingMetrics();
 
+    StubPropertyProvider provider;
     AutoTextRun textRun(this, aContext, aString, aLength);
-    if (!textRun.get())
-        return NS_ERROR_FAILURE;
-
-    // note that TIGHT_HINTED_OUTLINE_EXTENTS can be expensive (on Windows)
-    // but this is only used for MathML positioning so it's not critical
-    StubPropertyProvider provider;
     gfxTextRun::Metrics theMetrics =
         textRun->MeasureText(0, aLength,
                              gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
                              aContext->ThebesContext(), &provider);
 
-    aBoundingMetrics.leftBearing = NSToCoordFloor(theMetrics.mBoundingBox.X());
-    aBoundingMetrics.rightBearing
-        = NSToCoordCeil(theMetrics.mBoundingBox.XMost());
-    aBoundingMetrics.width = NSToCoordRound(theMetrics.mAdvanceWidth);
-    aBoundingMetrics.ascent = NSToCoordCeil(- theMetrics.mBoundingBox.Y());
-    aBoundingMetrics.descent = NSToCoordCeil(theMetrics.mBoundingBox.YMost());
-
-    return NS_OK;
+    nsBoundingMetrics m;
+    m.leftBearing  = NSToCoordFloor( theMetrics.mBoundingBox.X());
+    m.rightBearing = NSToCoordCeil(  theMetrics.mBoundingBox.XMost());
+    m.ascent       = NSToCoordCeil( -theMetrics.mBoundingBox.Y());
+    m.descent      = NSToCoordCeil(  theMetrics.mBoundingBox.YMost());
+    m.width        = NSToCoordRound( theMetrics.mAdvanceWidth);
+    return m;
 }
 #endif /* MOZ_MATHML */
--- a/gfx/src/nsFontMetrics.h
+++ b/gfx/src/nsFontMetrics.h
@@ -38,24 +38,20 @@
 
 #ifndef NSFONTMETRICS__H__
 #define NSFONTMETRICS__H__
 
 #include "nsCOMPtr.h"
 #include "nsCoord.h"
 #include "nsFont.h"
 #include "gfxFont.h"
-#include "gfxTextRunCache.h"
 
-class gfxFontGroup;
-class gfxUserFontSet;
 class nsIAtom;
 class nsIDeviceContext;
 class nsRenderingContext;
-class nsString;
 class nsThebesDeviceContext;
 struct nsBoundingMetrics;
 
 /**
  * Font metrics
  *
  * This class may be somewhat misnamed. A better name might be
  * nsFontList. The style system uses the nsFont struct for various
@@ -89,151 +85,148 @@ public:
     nsresult Init(const nsFont& aFont, nsIAtom* aLanguage,
                   nsIDeviceContext *aContext,
                   gfxUserFontSet *aUserFontSet = nsnull);
 
     /**
      * Destroy this font metrics. This breaks the association between
      * the font metrics and the device context.
      */
-    nsresult Destroy();
+    void Destroy();
 
     /**
      * Return the font's x-height.
      */
-    nsresult GetXHeight(nscoord& aResult);
+    nscoord XHeight();
 
     /**
      * Return the font's superscript offset (the distance from the
      * baseline to where a superscript's baseline should be placed).
      * The value returned will be positive.
      */
-    nsresult GetSuperscriptOffset(nscoord& aResult);
+    nscoord SuperscriptOffset();
 
     /**
      * Return the font's subscript offset (the distance from the
      * baseline to where a subscript's baseline should be placed).
      * The value returned will be positive.
      */
-    nsresult GetSubscriptOffset(nscoord& aResult);
+    nscoord SubscriptOffset();
 
     /**
      * Return the font's strikeout offset (the distance from the
      * baseline to where a strikeout should be placed) and size.
      * Positive values are above the baseline, negative below.
      */
-    nsresult GetStrikeout(nscoord& aOffset, nscoord& aSize);
+    void GetStrikeout(nscoord& aOffset, nscoord& aSize);
 
     /**
      * Return the font's underline offset (the distance from the
      * baseline to where a underline should be placed) and size.
      * Positive values are above the baseline, negative below.
      */
-    nsresult GetUnderline(nscoord& aOffset, nscoord& aSize);
+    void GetUnderline(nscoord& aOffset, nscoord& aSize);
 
     /**
      * Returns the amount of internal leading for the font.
      * This is normally the difference between the max ascent
      * and the em ascent.
      */
-    nsresult GetInternalLeading(nscoord &aLeading);
+    nscoord InternalLeading();
 
     /**
      * Returns the amount of external leading for the font.
      * em ascent(?) plus external leading is the font designer's
      * recommended line-height for this font.
      */
-    nsresult GetExternalLeading(nscoord &aLeading);
+    nscoord ExternalLeading();
 
     /**
      * Returns the height of the em square.
      * This is em ascent plus em descent.
      */
-    nsresult GetEmHeight(nscoord &aHeight);
+    nscoord EmHeight();
 
     /**
      * Returns the ascent part of the em square.
      */
-    nsresult GetEmAscent(nscoord &aAscent);
+    nscoord EmAscent();
 
     /**
      * Returns the descent part of the em square.
      */
-    nsresult GetEmDescent(nscoord &aDescent);
+    nscoord EmDescent();
 
     /**
      * Returns the height of the bounding box.
      * This is max ascent plus max descent.
      */
-    nsresult GetMaxHeight(nscoord &aHeight);
+    nscoord MaxHeight();
 
     /**
      * Returns the maximum distance characters in this font extend
      * above the base line.
      */
-    nsresult GetMaxAscent(nscoord &aAscent);
+    nscoord MaxAscent();
 
     /**
      * Returns the maximum distance characters in this font extend
      * below the base line.
      */
-    nsresult GetMaxDescent(nscoord &aDescent);
+    nscoord MaxDescent();
 
     /**
      * Returns the maximum character advance for the font.
      */
-    nsresult GetMaxAdvance(nscoord &aAdvance);
+    nscoord MaxAdvance();
+
+    /**
+     * Returns the average character width
+     */
+    nscoord AveCharWidth();
+
+    /**
+     * Returns the often needed width of the space character
+     */
+    nscoord SpaceWidth();
 
     /**
      * Returns the font associated with these metrics. The return value
      * is only defined after Init() has been called.
      */
     const nsFont &Font() { return mFont; }
 
     /**
      * Returns the language associated with these metrics
      */
-    nsresult GetLanguage(nsIAtom** aLanguage);
-
-    /**
-     * Returns the average character width
-     */
-    nsresult GetAveCharWidth(nscoord& aAveCharWidth);
-
-    /**
-     * Returns the often needed width of the space character
-     */
-    nsresult GetSpaceWidth(nscoord& aSpaceCharWidth);
+    already_AddRefed<nsIAtom> GetLanguage();
 
     PRInt32 GetMaxStringLength();
 
     // Get the width for this string.  aWidth will be updated with the
     // width in points, not twips.  Callers must convert it if they
     // want it in another format.
-    nsresult GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth,
-                      nsRenderingContext *aContext);
-    nsresult GetWidth(const PRUnichar* aString, PRUint32 aLength,
-                      nscoord& aWidth, PRInt32 *aFontID,
-                      nsRenderingContext *aContext);
+    nscoord GetWidth(const char* aString, PRUint32 aLength,
+                     nsRenderingContext *aContext);
+    nscoord GetWidth(const PRUnichar* aString, PRUint32 aLength,
+                     nsRenderingContext *aContext);
 
     // Draw a string using this font handle on the surface passed in.
-    nsresult DrawString(const char *aString, PRUint32 aLength,
-                        nscoord aX, nscoord aY,
-                        const nscoord* aSpacing,
-                        nsRenderingContext *aContext);
-    nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
-                        nscoord aX, nscoord aY,
-                        nsRenderingContext *aContext,
-                        nsRenderingContext *aTextRunConstructionContext);
+    void DrawString(const char *aString, PRUint32 aLength,
+                    nscoord aX, nscoord aY,
+                    nsRenderingContext *aContext);
+    void DrawString(const PRUnichar* aString, PRUint32 aLength,
+                    nscoord aX, nscoord aY,
+                    nsRenderingContext *aContext,
+                    nsRenderingContext *aTextRunConstructionContext);
 
 #ifdef MOZ_MATHML
-    nsresult GetBoundingMetrics(const PRUnichar *aString,
-                                PRUint32 aLength,
-                                nsRenderingContext *aContext,
-                                nsBoundingMetrics &aBoundingMetrics);
+    nsBoundingMetrics GetBoundingMetrics(const PRUnichar *aString,
+                                         PRUint32 aLength,
+                                         nsRenderingContext *aContext);
 #endif /* MOZ_MATHML */
 
     // Set the direction of the text rendering
     void SetRightToLeftText(PRBool aIsRTL) { mIsRightToLeft = aIsRTL; }
     PRBool GetRightToLeftText() { return mIsRightToLeft; }
 
     void SetTextRunRTL(PRBool aIsRTL) { mTextRunRTL = aIsRTL; }
     PRBool GetRightToLeftTextRunMode() { return mTextRunRTL; }
--- a/gfx/src/nsRenderingContext.cpp
+++ b/gfx/src/nsRenderingContext.cpp
@@ -489,19 +489,17 @@ nsRenderingContext::GetMaxChunkLength()
         return 1;
     return PR_MIN(mFontMetrics->GetMaxStringLength(), MAX_GFX_TEXT_BUF_SIZE);
 }
 
 nscoord
 nsRenderingContext::GetWidth(char aC)
 {
     if (aC == ' ' && mFontMetrics) {
-        nscoord width;
-        mFontMetrics->GetSpaceWidth(width);
-        return width;
+        return mFontMetrics->SpaceWidth();
     }
 
     return GetWidth(&aC, 1);
 }
 
 nscoord
 nsRenderingContext::GetWidth(PRUnichar aC)
 {
@@ -522,76 +520,76 @@ nsRenderingContext::GetWidth(const char*
 
 nscoord
 nsRenderingContext::GetWidth(const char* aString, PRUint32 aLength)
 {
     PRUint32 maxChunkLength = GetMaxChunkLength();
     nscoord width = 0;
     while (aLength > 0) {
         PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
-        width += GetWidthInternal(aString, len);
+        width += mFontMetrics->GetWidth(aString, len, this);
         aLength -= len;
         aString += len;
     }
     return width;
 }
 
 nscoord
 nsRenderingContext::GetWidth(const PRUnichar *aString, PRUint32 aLength)
 {
     PRUint32 maxChunkLength = GetMaxChunkLength();
     nscoord width = 0;
     while (aLength > 0) {
         PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
-        width += GetWidthInternal(aString, len);
+        width += mFontMetrics->GetWidth(aString, len, this);
         aLength -= len;
         aString += len;
     }
     return width;
 }
 
 #ifdef MOZ_MATHML
 nsBoundingMetrics
 nsRenderingContext::GetBoundingMetrics(const PRUnichar* aString,
                                        PRUint32 aLength)
 {
     PRUint32 maxChunkLength = GetMaxChunkLength();
     PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
     // Assign directly in the first iteration. This ensures that
     // negative ascent/descent can be returned and the left bearing
     // is properly initialized.
-    nsBoundingMetrics totalMetrics;
-    mFontMetrics->GetBoundingMetrics(aString, len, this, totalMetrics);
+    nsBoundingMetrics totalMetrics
+        = mFontMetrics->GetBoundingMetrics(aString, len, this);
     aLength -= len;
     aString += len;
 
     while (aLength > 0) {
         len = FindSafeLength(aString, aLength, maxChunkLength);
-        nsBoundingMetrics metrics;
-        mFontMetrics->GetBoundingMetrics(aString, len, this, metrics);
+        nsBoundingMetrics metrics
+            = mFontMetrics->GetBoundingMetrics(aString, len, this);
         totalMetrics += metrics;
         aLength -= len;
         aString += len;
     }
     return totalMetrics;
 }
 #endif
 
 void
 nsRenderingContext::DrawString(const char *aString, PRUint32 aLength,
                                nscoord aX, nscoord aY)
 {
     PRUint32 maxChunkLength = GetMaxChunkLength();
     while (aLength > 0) {
         PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
-        mFontMetrics->DrawString(aString, len, aX, aY, nsnull, this);
+        mFontMetrics->DrawString(aString, len, aX, aY, this);
         aLength -= len;
 
         if (aLength > 0) {
-            nscoord width = GetWidthInternal(aString, len);
+            nscoord width = mFontMetrics->GetWidth(aString, len, this);
             aX += width;
             aString += len;
         }
     }
 }
 
 void
 nsRenderingContext::DrawString(const nsString& aString, nscoord aX, nscoord aY)
@@ -613,44 +611,20 @@ nsRenderingContext::DrawString(const PRU
 
     // If we're drawing right to left, we must start at the end.
     if (isRTL) {
         aX += GetWidth(aString, aLength);
     }
 
     while (aLength > 0) {
         PRInt32 len = FindSafeLength(aString, aLength, maxChunkLength);
-        nscoord width = GetWidthInternal(aString, len);
+        nscoord width = mFontMetrics->GetWidth(aString, len, this);
         if (isRTL) {
             aX -= width;
         }
         mFontMetrics->DrawString(aString, len, aX, aY, this, this);
         if (!isRTL) {
             aX += width;
         }
         aLength -= len;
         aString += len;
     }
 }
-
-nscoord
-nsRenderingContext::GetWidthInternal(const char* aString, PRUint32 aLength)
-{
-    if (aLength == 0) {
-        return 0;
-    }
-
-    nscoord width;
-    mFontMetrics->GetWidth(aString, aLength, width, this);
-    return width;
-}
-
-nscoord
-nsRenderingContext::GetWidthInternal(const PRUnichar *aString, PRUint32 aLength)
-{
-    if (aLength == 0) {
-        return 0;
-    }
-
-    nscoord width;
-    mFontMetrics->GetWidth(aString, aLength, width, nsnull, this);
-    return width;
-}
--- a/gfx/src/nsRenderingContext.h
+++ b/gfx/src/nsRenderingContext.h
@@ -141,18 +141,16 @@ public:
     void DrawString(const nsString& aString, nscoord aX, nscoord aY);
     void DrawString(const char *aString, PRUint32 aLength,
                     nscoord aX, nscoord aY);
     void DrawString(const PRUnichar *aString, PRUint32 aLength,
                     nscoord aX, nscoord aY);
 
 protected:
     PRInt32 GetMaxChunkLength();
-    nscoord GetWidthInternal(const char *aString, PRUint32 aLength);
-    nscoord GetWidthInternal(const PRUnichar *aString, PRUint32 aLength);
 
     nsRefPtr<gfxContext> mThebes;
     nsCOMPtr<nsIDeviceContext> mDeviceContext;
     nsRefPtr<nsFontMetrics> mFontMetrics;
 
     double mP2A; // cached app units per device pixel value
 };
 
--- a/gfx/src/nsThebesDeviceContext.cpp
+++ b/gfx/src/nsThebesDeviceContext.cpp
@@ -146,18 +146,17 @@ nsFontCache::GetMetricsFor(const nsFont&
     // First check our cache
     // start from the end, which is where we put the most-recent-used element
 
     nsFontMetrics* fm;
     PRInt32 n = mFontMetrics.Length() - 1;
     for (PRInt32 i = n; i >= 0; --i) {
         fm = mFontMetrics[i];
         if (fm->Font().Equals(aFont) && fm->GetUserFontSet() == aUserFontSet) {
-            nsCOMPtr<nsIAtom> language;
-            fm->GetLanguage(getter_AddRefs(language));
+            nsCOMPtr<nsIAtom> language = fm->GetLanguage();
             if (aLanguage == language.get()) {
                 if (i != n) {
                     // promote it to the end of the cache
                     mFontMetrics.RemoveElementAt(i);
                     mFontMetrics.AppendElement(fm);
                 }
                 fm->GetThebesFontGroup()->UpdateFontList();
                 NS_ADDREF(aMetrics = fm);
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -355,18 +355,18 @@ nsCaret::GetGeometryForFrame(nsIFrame* a
   nsIFrame *frame = aFrame->GetContentInsertionFrame();
   NS_ASSERTION(frame, "We should not be in the middle of reflow");
   nscoord baseline = frame->GetCaretBaseline();
   nscoord ascent = 0, descent = 0;
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
   NS_ASSERTION(fm, "We should be able to get the font metrics");
   if (fm) {
-    fm->GetMaxAscent(ascent);
-    fm->GetMaxDescent(descent);
+    ascent = fm->MaxAscent();
+    descent = fm->MaxDescent();
   }
   nscoord height = ascent + descent;
   framePos.y = baseline - ascent;
   Metrics caretMetrics = ComputeMetrics(aFrame, aFrameOffset, height);
   *aRect = nsRect(framePos, nsSize(caretMetrics.mCaretWidth, height));
 
   // Clamp the x-position to be within our scroll frame. If we don't, then it
   // clips us, and we don't appear at all. See bug 335560.
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1639,17 +1639,17 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
   // Update the widget's transparent region information. This sets
   // glass boundaries on Windows.
   if ((aFlags & PAINT_WIDGET_LAYERS) &&
       !willFlushRetainedLayers &&
       !(aFlags & PAINT_DOCUMENT_RELATIVE)) {
     nsIWidget *widget = aFrame->GetNearestWidget();
     if (widget) {
       PRInt32 pixelRatio = presContext->AppUnitsPerDevPixel();
-      nsIntRegion visibleWindowRegion(visibleRegion.ToOutsidePixels(presContext->AppUnitsPerDevPixel()));
+      nsIntRegion visibleWindowRegion(visibleRegion.ToOutsidePixels(pixelRatio));
       widget->UpdateTransparentRegion(visibleWindowRegion);
     }
   }
 
 #ifdef DEBUG
   if (gDumpPaintList) {
     fprintf(stderr, "Painting --- after optimization:\n");
     nsFrame::PrintDisplayList(&builder, list);
@@ -2840,19 +2840,18 @@ nsLayoutUtils::GetStringWidth(const nsIF
   aContext->SetTextRunRTL(PR_FALSE);
   return aContext->GetWidth(aString, aLength);
 }
 
 /* static */ nscoord
 nsLayoutUtils::GetCenteredFontBaseline(nsFontMetrics* aFontMetrics,
                                        nscoord         aLineHeight)
 {
-  nscoord fontAscent, fontHeight;
-  aFontMetrics->GetMaxAscent(fontAscent);
-  aFontMetrics->GetMaxHeight(fontHeight);
+  nscoord fontAscent = aFontMetrics->MaxAscent();
+  nscoord fontHeight = aFontMetrics->MaxHeight();
 
   nscoord leading = aLineHeight - fontHeight;
   return fontAscent + leading/2;
 }
 
 
 /* static */ PRBool
 nsLayoutUtils::GetFirstLineBaseline(const nsIFrame* aFrame, nscoord* aResult)
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -8804,22 +8804,20 @@ void ReflowCountMgr::PaintCount(const ch
       nsFont font("Times", NS_FONT_STYLE_NORMAL, NS_FONT_VARIANT_NORMAL,
                   NS_FONT_WEIGHT_NORMAL, NS_FONT_STRETCH_NORMAL, 0,
                   nsPresContext::CSSPixelsToAppUnits(11));
 
       nsRefPtr<nsFontMetrics> fm = aPresContext->GetMetricsFor(font);
       aRenderingContext->SetFont(fm);
       char buf[16];
       sprintf(buf, "%d", counter->mCount);
-      nscoord x = 0, y;
-      nscoord width, height;
+      nscoord x = 0, y = fm->MaxAscent();
+      nscoord width, height = fm->MaxHeight();
       aRenderingContext->SetTextRunRTL(PR_FALSE);
       aRenderingContext->GetWidth((char*)buf, width);
-      fm->GetMaxHeight(height);
-      fm->GetMaxAscent(y);
 
       PRUint32 color;
       PRUint32 color2;
       if (aColor != 0) {
         color  = aColor;
         color2 = NS_RGB(0,0,0);
       } else {
         PRUint8 rc = 0, gc = 0, bc = 0;
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -1873,21 +1873,21 @@ nsListControlFrame::IsLeftButton(nsIDOME
   }
   return PR_FALSE;
 }
 
 nscoord
 nsListControlFrame::CalcFallbackRowHeight()
 {
   nscoord rowHeight = 0;
-  
+
   nsRefPtr<nsFontMetrics> fontMet;
   nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
   if (fontMet) {
-    fontMet->GetMaxHeight(rowHeight);
+    rowHeight = fontMet->MaxHeight();
   }
 
   return rowHeight;
 }
 
 nscoord
 nsListControlFrame::CalcIntrinsicHeight(nscoord aHeightOfARow,
                                         PRInt32 aNumberOfOptions)
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -232,18 +232,18 @@ nsTextControlFrame::CalcIntrinsicSize(ns
   nsRefPtr<nsFontMetrics> fontMet;
   nsresult rv =
     nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
   NS_ENSURE_SUCCESS(rv, rv);
   aRenderingContext->SetFont(fontMet);
 
   lineHeight =
     nsHTMLReflowState::CalcLineHeight(GetStyleContext(), NS_AUTOHEIGHT);
-  fontMet->GetAveCharWidth(charWidth);
-  fontMet->GetMaxAdvance(charMaxAdvance);
+  charWidth = fontMet->AveCharWidth();
+  charMaxAdvance = fontMet->MaxAdvance();
 
   // Set the width equal to the width in characters
   PRInt32 cols = GetCols();
   aIntrinsicSize.width = cols * charWidth;
 
   // To better match IE, take the maximum character width(in twips) and remove
   // 4 pixels add this on as additional padding(internalPadding). But only do
   // this if charMaxAdvance != charWidth; if they are equal, this is almost
--- a/layout/generic/nsBRFrame.cpp
+++ b/layout/generic/nsBRFrame.cpp
@@ -234,18 +234,17 @@ BRFrame::GetBaseline() const
   nscoord ascent = 0;
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
   if (fm) {
     nscoord logicalHeight = GetRect().height;
     if (GetStateBits() & BR_USING_CENTERED_FONT_BASELINE) {
       ascent = nsLayoutUtils::GetCenteredFontBaseline(fm, logicalHeight);
     } else {
-      fm->GetMaxAscent(ascent);
-      ascent += GetUsedBorderAndPadding().top;
+      ascent = fm->MaxAscent() + GetUsedBorderAndPadding().top;
     }
   }
   return NS_MIN(mRect.height, ascent);
 }
 
 nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(nsPoint aPoint)
 {
   ContentOffsets offsets;
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -383,18 +383,17 @@ nsBulletFrame::PaintBullet(nsRenderingCo
   case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
   case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
   case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
   case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
   case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
     nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
     GetListItemText(*myList, text);
     aRenderingContext.SetFont(fm);
-    nscoord ascent;
-    fm->GetMaxAscent(ascent);
+    nscoord ascent = fm->MaxAscent();
     aRenderingContext.SetTextRunRTL(mTextIsRTL);
     aRenderingContext.DrawString(text, mPadding.left + aPt.x,
                                  mPadding.top + aPt.y + ascent);
     break;
   }
 }
 
 PRInt32
@@ -1356,17 +1355,17 @@ nsBulletFrame::GetDesiredSize(nsPresCont
     case NS_STYLE_LIST_STYLE_NONE:
       aMetrics.width = 0;
       aMetrics.ascent = aMetrics.height = 0;
       break;
 
     case NS_STYLE_LIST_STYLE_DISC:
     case NS_STYLE_LIST_STYLE_CIRCLE:
     case NS_STYLE_LIST_STYLE_SQUARE:
-      fm->GetMaxAscent(ascent);
+      ascent = fm->MaxAscent();
       bulletSize = NS_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
                           NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
       mPadding.bottom = NSToCoordRound(float(ascent) / 8.0f);
       aMetrics.width = mPadding.right + bulletSize;
       aMetrics.ascent = aMetrics.height = mPadding.bottom + bulletSize;
       break;
 
     default:
@@ -1417,21 +1416,23 @@ nsBulletFrame::GetDesiredSize(nsPresCont
     case NS_STYLE_LIST_STYLE_MOZ_HANGUL:
     case NS_STYLE_LIST_STYLE_MOZ_HANGUL_CONSONANT:
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME:
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_NUMERIC:
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_AM:
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
     case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
       GetListItemText(*myList, text);
-      fm->GetMaxHeight(aMetrics.height);
+      aMetrics.height = fm->MaxHeight();
       aRenderingContext->SetFont(fm);
-      aMetrics.width = nsLayoutUtils::GetStringWidth(this, aRenderingContext, text.get(), text.Length());
+      aMetrics.width =
+        nsLayoutUtils::GetStringWidth(this, aRenderingContext,
+                                      text.get(), text.Length());
       aMetrics.width += mPadding.right;
-      fm->GetMaxAscent(aMetrics.ascent);
+      aMetrics.ascent = fm->MaxAscent();
       break;
   }
 }
 
 NS_IMETHODIMP
 nsBulletFrame::Reflow(nsPresContext* aPresContext,
                       nsHTMLReflowMetrics& aMetrics,
                       const nsHTMLReflowState& aReflowState,
@@ -1596,25 +1597,25 @@ nsBulletFrame::GetBaseline() const
     const nsStyleList* myList = GetStyleList();
     switch (myList->mListStyleType) {
       case NS_STYLE_LIST_STYLE_NONE:
         break;
 
       case NS_STYLE_LIST_STYLE_DISC:
       case NS_STYLE_LIST_STYLE_CIRCLE:
       case NS_STYLE_LIST_STYLE_SQUARE:
-        fm->GetMaxAscent(ascent);
+        ascent = fm->MaxAscent();
         bottomPadding = NSToCoordRound(float(ascent) / 8.0f);
         ascent = NS_MAX(nsPresContext::CSSPixelsToAppUnits(MIN_BULLET_SIZE),
                         NSToCoordRound(0.8f * (float(ascent) / 2.0f)));
         ascent += bottomPadding;
         break;
 
       default:
-        fm->GetMaxAscent(ascent);
+        ascent = fm->MaxAscent();
         break;
     }
   }
   return ascent + GetUsedBorderAndPadding().top;
 }
 
 
 
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -2201,17 +2201,17 @@ nsSize
 nsGfxScrollFrameInner::GetLineScrollAmount() const
 {
   const nsStyleFont* font = mOuter->GetStyleFont();
   const nsFont& f = font->mFont;
   nsRefPtr<nsFontMetrics> fm = mOuter->PresContext()->GetMetricsFor(f);
   NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
   nscoord fontHeight = 1;
   if (fm) {
-    fm->GetMaxHeight(fontHeight);
+    fontHeight = fm->MaxHeight();
   }
 
   return nsSize(fontHeight, fontHeight);
 }
 
 nsSize
 nsGfxScrollFrameInner::GetPageScrollAmount() const
 {
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -2107,20 +2107,19 @@ nsHTMLReflowState::CalculateBlockSideMar
 // eNoExternalLeading is the old behavior.
 static nscoord
 GetNormalLineHeight(nsFontMetrics* aFontMetrics)
 {
   NS_PRECONDITION(nsnull != aFontMetrics, "no font metrics");
 
   nscoord normalLineHeight;
 
-  nscoord externalLeading, internalLeading, emHeight;
-  aFontMetrics->GetExternalLeading(externalLeading);
-  aFontMetrics->GetInternalLeading(internalLeading);
-  aFontMetrics->GetEmHeight(emHeight);
+  nscoord externalLeading = aFontMetrics->ExternalLeading();
+  nscoord internalLeading = aFontMetrics->InternalLeading();
+  nscoord emHeight = aFontMetrics->EmHeight();
   switch (GetNormalLineHeightCalcControl()) {
   case eIncludeExternalLeading:
     normalLineHeight = emHeight+ internalLeading + externalLeading;
     break;
   case eCompensateLeading:
     if (!internalLeading && !externalLeading)
       normalLineHeight = NSToCoordRound(emHeight * NORMAL_LINE_HEIGHT_FACTOR);
     else
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -971,20 +971,19 @@ nsImageFrame::DisplayAltText(nsPresConte
 {
   // Set font and color
   aRenderingContext.SetColor(GetStyleColor()->mColor);
   nsLayoutUtils::SetFontFromStyle(&aRenderingContext, mStyleContext);
 
   // Format the text to display within the formatting rect
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
 
-  nscoord maxAscent, maxDescent, height;
-  fm->GetMaxAscent(maxAscent);
-  fm->GetMaxDescent(maxDescent);
-  fm->GetMaxHeight(height);
+  nscoord maxAscent = fm->MaxAscent();
+  nscoord maxDescent = fm->MaxDescent();
+  nscoord height = fm->MaxHeight();
 
   // XXX It would be nice if there was a way to have the font metrics tell
   // use where to break the text given a maximum width. At a minimum we need
   // to be able to get the break character...
   const PRUnichar* str = aAltText.get();
   PRInt32          strLen = aAltText.Length();
   nscoord          y = aRect.y;
 
--- a/layout/generic/nsInlineFrame.cpp
+++ b/layout/generic/nsInlineFrame.cpp
@@ -651,18 +651,18 @@ nsInlineFrame::ReflowFrames(nsPresContex
     // Do things the standard css2 way -- though it's hard to find it
     // in the css2 spec! It's actually found in the css1 spec section
     // 4.4 (you will have to read between the lines to really see
     // it).
     //
     // The height of our box is the sum of our font size plus the top
     // and bottom border and padding. The height of children do not
     // affect our height.
-    fm->GetMaxAscent(aMetrics.ascent);
-    fm->GetMaxHeight(aMetrics.height);
+    aMetrics.ascent = fm->MaxAscent();
+    aMetrics.height = fm->MaxHeight();
   } else {
     NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
     aMetrics.ascent = aMetrics.height = 0;
   }
   aMetrics.ascent += aReflowState.mComputedBorderPadding.top;
   aMetrics.height += aReflowState.mComputedBorderPadding.top +
     aReflowState.mComputedBorderPadding.bottom;
 
@@ -909,18 +909,19 @@ nsInlineFrame::GetSkipSides() const
   return skip;
 }
 
 nscoord
 nsInlineFrame::GetBaseline() const
 {
   nscoord ascent = 0;
   nsRefPtr<nsFontMetrics> fm;
-  if (NS_SUCCEEDED(nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm)))) {
-    fm->GetMaxAscent(ascent);
+  nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
+  if (fm) {
+    ascent = fm->MaxAscent();
   }
   return NS_MIN(mRect.height, ascent + GetUsedBorderAndPadding().top);
 }
 
 #ifdef ACCESSIBILITY
 already_AddRefed<nsAccessible>
 nsInlineFrame::CreateAccessible()
 {
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -1805,32 +1805,30 @@ nsLineLayout::VerticalAlignFrames(PerSpa
         }
 
         case NS_STYLE_VERTICAL_ALIGN_SUB:
         {
           // Lower the baseline of the box to the subscript offset
           // of the parent's box. This is identical to the baseline
           // alignment except for the addition of the subscript
           // offset to the baseline Y.
-          nscoord parentSubscript;
-          fm->GetSubscriptOffset(parentSubscript);
+          nscoord parentSubscript = fm->SubscriptOffset();
           nscoord revisedBaselineY = baselineY + parentSubscript;
           pfd->mBounds.y = revisedBaselineY - pfd->mAscent;
           pfd->mVerticalAlign = VALIGN_OTHER;
           break;
         }
 
         case NS_STYLE_VERTICAL_ALIGN_SUPER:
         {
           // Raise the baseline of the box to the superscript offset
           // of the parent's box. This is identical to the baseline
           // alignment except for the subtraction of the superscript
           // offset to the baseline Y.
-          nscoord parentSuperscript;
-          fm->GetSuperscriptOffset(parentSuperscript);
+          nscoord parentSuperscript = fm->SuperscriptOffset();
           nscoord revisedBaselineY = baselineY - parentSuperscript;
           pfd->mBounds.y = revisedBaselineY - pfd->mAscent;
           pfd->mVerticalAlign = VALIGN_OTHER;
           break;
         }
 
         case NS_STYLE_VERTICAL_ALIGN_TOP:
         {
@@ -1861,53 +1859,50 @@ nsLineLayout::VerticalAlignFrames(PerSpa
           }
           break;
         }
 
         case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
         {
           // Align the midpoint of the frame with 1/2 the parents
           // x-height above the baseline.
-          nscoord parentXHeight;
-          fm->GetXHeight(parentXHeight);
+          nscoord parentXHeight = fm->XHeight();
           if (frameSpan) {
             pfd->mBounds.y = baselineY -
               (parentXHeight + pfd->mBounds.height)/2;
           }
           else {
             pfd->mBounds.y = baselineY - (parentXHeight + logicalHeight)/2 +
               pfd->mMargin.top;
           }
           pfd->mVerticalAlign = VALIGN_OTHER;
           break;
         }
 
         case NS_STYLE_VERTICAL_ALIGN_TEXT_TOP:
         {
           // The top of the logical box is aligned with the top of
           // the parent element's text.
-          nscoord parentAscent;
-          fm->GetMaxAscent(parentAscent);
+          nscoord parentAscent = fm->MaxAscent();
           if (frameSpan) {
             pfd->mBounds.y = baselineY - parentAscent -
               pfd->mBorderPadding.top + frameSpan->mTopLeading;
           }
           else {
             pfd->mBounds.y = baselineY - parentAscent + pfd->mMargin.top;
           }
           pfd->mVerticalAlign = VALIGN_OTHER;
           break;
         }
 
         case NS_STYLE_VERTICAL_ALIGN_TEXT_BOTTOM:
         {
           // The bottom of the logical box is aligned with the
           // bottom of the parent elements text.
-          nscoord parentDescent;
-          fm->GetMaxDescent(parentDescent);
+          nscoord parentDescent = fm->MaxDescent();
           if (frameSpan) {
             pfd->mBounds.y = baselineY + parentDescent -
               pfd->mBounds.height + pfd->mBorderPadding.bottom -
               frameSpan->mBottomLeading;
           }
           else {
             pfd->mBounds.y = baselineY + parentDescent -
               pfd->mBounds.height - pfd->mMargin.bottom;
--- a/layout/generic/nsPageFrame.cpp
+++ b/layout/generic/nsPageFrame.cpp
@@ -515,18 +515,18 @@ nsPageFrame::PaintHeaderFooter(nsRenderi
                                      pc->GetUserFontSet(),
                                      *getter_AddRefs(fontMet));
 
   aRenderingContext.SetFont(fontMet);
 
   nscoord ascent = 0;
   nscoord visibleHeight = 0;
   if (fontMet) {
-    fontMet->GetMaxHeight(visibleHeight);
-    fontMet->GetMaxAscent(ascent);
+    visibleHeight = fontMet->MaxHeight();
+    ascent = fontMet->MaxAscent();
   }
 
   // print document headers and footers
   nsXPIDLString headerLeft, headerCenter, headerRight;
   mPD->mPrintSettings->GetHeaderStrLeft(getter_Copies(headerLeft));
   mPD->mPrintSettings->GetHeaderStrCenter(getter_Copies(headerCenter));
   mPD->mPrintSettings->GetHeaderStrRight(getter_Copies(headerRight));
   DrawHeaderFooter(aRenderingContext, eHeader,
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -4333,20 +4333,19 @@ nsTextFrame::UnionTextDecorationOverflow
   // Text-shadow overflows
   nsRect shadowRect =
     nsLayoutUtils::GetTextShadowRectsUnion(*aVisualOverflowRect, this);
   aVisualOverflowRect->UnionRect(*aVisualOverflowRect, shadowRect);
 
   if (IsFloatingFirstLetterChild()) {
     // The underline/overline drawable area must be contained in the overflow
     // rect when this is in floating first letter frame at *both* modes.
-    nscoord fontAscent, fontHeight;
     nsFontMetrics* fm = aProvider.GetFontMetrics();
-    fm->GetMaxAscent(fontAscent);
-    fm->GetMaxHeight(fontHeight);
+    nscoord fontAscent = fm->MaxAscent();
+    nscoord fontHeight = fm->MaxHeight();
     nsRect fontRect(0, mAscent - fontAscent, GetSize().width, fontHeight);
     aVisualOverflowRect->UnionRect(*aVisualOverflowRect, fontRect);
   }
 
   // When this frame is not selected, the text-decoration area must be in
   // frame bounds.
   nsRect decorationRect;
   if (!(GetStateBits() & NS_FRAME_SELECTED_CONTENT) ||
@@ -6781,21 +6780,18 @@ nsTextFrame::ReflowText(nsLineLayout& aL
                                   &textMetrics, boundingBoxType, ctx,
                                   &usedHyphenation, &transformedLastBreak,
                                   textStyle->WordCanWrap(), &breakPriority);
   if (!length && !textMetrics.mAscent && !textMetrics.mDescent) {
     // If we're measuring a zero-length piece of text, update
     // the height manually.
     nsFontMetrics* fm = provider.GetFontMetrics();
     if (fm) {
-      nscoord ascent, descent;
-      fm->GetMaxAscent(ascent);
-      fm->GetMaxDescent(descent);
-      textMetrics.mAscent = gfxFloat(ascent);
-      textMetrics.mDescent = gfxFloat(descent);
+      textMetrics.mAscent = gfxFloat(fm->MaxAscent());
+      textMetrics.mDescent = gfxFloat(fm->MaxDescent());
     }
   }
   // The "end" iterator points to the first character after the string mapped
   // by this frame. Basically, its original-string offset is offset+charsFit
   // after we've computed charsFit.
   gfxSkipCharsIterator end(provider.GetEndHint());
   end.SetSkippedOffset(transformedOffset + transformedCharsFit);
   PRInt32 charsFit = end.GetOriginalOffset() - offset;
@@ -6890,20 +6886,19 @@ nsTextFrame::ReflowText(nsLineLayout& aL
   } else if (boundingBoxType != gfxFont::LOOSE_INK_EXTENTS) {
     // Use actual text metrics for floating first letter frame.
     aMetrics.ascent = NSToCoordCeil(textMetrics.mAscent);
     aMetrics.height = aMetrics.ascent + NSToCoordCeil(textMetrics.mDescent);
   } else {
     // Otherwise, ascent should contain the overline drawable area.
     // And also descent should contain the underline drawable area.
     // nsFontMetrics::GetMaxAscent/GetMaxDescent contains them.
-    nscoord fontAscent, fontDescent;
     nsFontMetrics* fm = provider.GetFontMetrics();
-    fm->GetMaxAscent(fontAscent);
-    fm->GetMaxDescent(fontDescent);
+    nscoord fontAscent = fm->MaxAscent();
+    nscoord fontDescent = fm->MaxDescent();
     aMetrics.ascent = NS_MAX(NSToCoordCeil(textMetrics.mAscent), fontAscent);
     nscoord descent = NS_MAX(NSToCoordCeil(textMetrics.mDescent), fontDescent);
     aMetrics.height = aMetrics.ascent + descent;
   }
 
   NS_ASSERTION(aMetrics.ascent >= 0, "Negative ascent???");
   NS_ASSERTION(aMetrics.height - aMetrics.ascent >= 0, "Negative descent???");
 
--- a/layout/mathml/nsMathMLContainerFrame.cpp
+++ b/layout/mathml/nsMathMLContainerFrame.cpp
@@ -95,19 +95,18 @@ nsMathMLContainerFrame::ReflowError(nsRe
 
   // bounding metrics
   nsAutoString errorMsg; errorMsg.AssignLiteral("invalid-markup");
   mBoundingMetrics =
     aRenderingContext.GetBoundingMetrics(errorMsg.get(), errorMsg.Length());
 
   // reflow metrics
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
-  fm->GetMaxAscent(aDesiredSize.ascent);
-  nscoord descent;
-  fm->GetMaxDescent(descent);
+  aDesiredSize.ascent = fm->MaxAscent();
+  nscoord descent = fm->MaxDescent();
   aDesiredSize.height = aDesiredSize.ascent + descent;
   aDesiredSize.width = mBoundingMetrics.width;
 
   // Also return our bounding metrics
   aDesiredSize.mBoundingMetrics = mBoundingMetrics;
 
   return NS_OK;
 }
@@ -135,21 +134,21 @@ void nsDisplayMathMLError::Paint(nsDispl
   // Set color and font ...
   nsLayoutUtils::SetFontFromStyle(aCtx, mFrame->GetStyleContext());
 
   nsPoint pt = ToReferenceFrame();
   aCtx->SetColor(NS_RGB(255,0,0));
   aCtx->FillRect(nsRect(pt, mFrame->GetSize()));
   aCtx->SetColor(NS_RGB(255,255,255));
 
-  nscoord ascent;
-  aCtx->FontMetrics()->GetMaxAscent(ascent);
+  nscoord ascent = aCtx->FontMetrics()->MaxAscent();
 
-  nsAutoString errorMsg; errorMsg.AssignLiteral("invalid-markup");
-  aCtx->DrawString(errorMsg.get(), PRUint32(errorMsg.Length()), pt.x, pt.y+ascent);
+  NS_NAMED_LITERAL_STRING(errorMsg, "invalid-markup");
+  aCtx->DrawString(errorMsg.get(), PRUint32(errorMsg.Length()),
+                   pt.x, pt.y+ascent);
 }
 
 /* /////////////
  * nsIMathMLFrame - support methods for stretchy elements
  * =============================================================================
  */
 
 static PRBool
--- a/layout/mathml/nsMathMLFrame.cpp
+++ b/layout/mathml/nsMathMLFrame.cpp
@@ -281,18 +281,17 @@ nsMathMLFrame::GetRuleThickness(nsRender
                                 nscoord&             aRuleThickness)
 {
   // get the bounding metrics of the overbar char, the rendering context
   // is assumed to have been set with the font of the current style context
   NS_ASSERTION(aRenderingContext.FontMetrics()->Font().
                Equals(aFontMetrics->Font()),
                "unexpected state");
 
-  nscoord xHeight;
-  aFontMetrics->GetXHeight(xHeight);
+  nscoord xHeight = aFontMetrics->XHeight();
   PRUnichar overBar = 0x00AF;
   nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&overBar, 1);
   aRuleThickness = bm.ascent + bm.descent;
   if (aRuleThickness <= 0 || aRuleThickness >= xHeight) {
     // fall-back to the other version
     GetRuleThickness(aFontMetrics, aRuleThickness);
   }
 }
@@ -303,18 +302,17 @@ nsMathMLFrame::GetAxisHeight(nsRendering
                              nscoord&             aAxisHeight)
 {
   // get the bounding metrics of the minus sign, the rendering context
   // is assumed to have been set with the font of the current style context
   NS_ASSERTION(aRenderingContext.FontMetrics()->Font().
                Equals(aFontMetrics->Font()),
                "unexpected state");
 
-  nscoord xHeight;
-  aFontMetrics->GetXHeight(xHeight);
+  nscoord xHeight = aFontMetrics->XHeight();
   PRUnichar minus = 0x2212; // not '-', but official Unicode minus sign
   nsBoundingMetrics bm = aRenderingContext.GetBoundingMetrics(&minus, 1);
   aAxisHeight = bm.ascent - (bm.ascent + bm.descent)/2;
   if (aAxisHeight <= 0 || aAxisHeight >= xHeight) {
     // fall-back to the other version
     GetAxisHeight(aFontMetrics, aAxisHeight);
   }
 }
@@ -335,20 +333,19 @@ nsMathMLFrame::CalcLength(nsPresContext*
 
   nsCSSUnit unit = aCSSValue.GetUnit();
 
   if (eCSSUnit_EM == unit) {
     const nsStyleFont* font = aStyleContext->GetStyleFont();
     return NSToCoordRound(aCSSValue.GetFloatValue() * (float)font->mFont.size);
   }
   else if (eCSSUnit_XHeight == unit) {
-    nscoord xHeight;
     const nsStyleFont* font = aStyleContext->GetStyleFont();
     nsRefPtr<nsFontMetrics> fm = aPresContext->GetMetricsFor(font->mFont);
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     return NSToCoordRound(aCSSValue.GetFloatValue() * (float)xHeight);
   }
 
   // MathML doesn't specify other CSS units such as rem or ch
   NS_ERROR("Unsupported unit");
   return 0;
 }
 
--- a/layout/mathml/nsMathMLFrame.h
+++ b/layout/mathml/nsMathMLFrame.h
@@ -265,123 +265,114 @@ public:
   }
 
   // 2 levels of subscript shifts
   static void
   GetSubScriptShifts(nsFontMetrics* fm, 
                      nscoord&        aSubScriptShift1, 
                      nscoord&        aSubScriptShift2)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     aSubScriptShift1 = NSToCoordRound(150.000f/430.556f * xHeight);
     aSubScriptShift2 = NSToCoordRound(247.217f/430.556f * xHeight);
   }
 
   // 3 levels of superscript shifts
   static void
   GetSupScriptShifts(nsFontMetrics* fm, 
                      nscoord&        aSupScriptShift1, 
                      nscoord&        aSupScriptShift2, 
                      nscoord&        aSupScriptShift3)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     aSupScriptShift1 = NSToCoordRound(412.892f/430.556f * xHeight);
     aSupScriptShift2 = NSToCoordRound(362.892f/430.556f * xHeight);
     aSupScriptShift3 = NSToCoordRound(288.889f/430.556f * xHeight);
   }
 
   // these are TeX specific params not found in ordinary fonts
 
   static void
   GetSubDrop(nsFontMetrics* fm,
              nscoord&        aSubDrop)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     aSubDrop = NSToCoordRound(50.000f/430.556f * xHeight);
   }
 
   static void
   GetSupDrop(nsFontMetrics* fm,
              nscoord&        aSupDrop)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     aSupDrop = NSToCoordRound(386.108f/430.556f * xHeight);
   }
 
   static void
   GetNumeratorShifts(nsFontMetrics* fm, 
                      nscoord&        numShift1, 
                      nscoord&        numShift2, 
                      nscoord&        numShift3)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     numShift1 = NSToCoordRound(676.508f/430.556f * xHeight);
     numShift2 = NSToCoordRound(393.732f/430.556f * xHeight);
     numShift3 = NSToCoordRound(443.731f/430.556f * xHeight);
   }
 
   static void
   GetDenominatorShifts(nsFontMetrics* fm, 
                        nscoord&        denShift1, 
                        nscoord&        denShift2)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     denShift1 = NSToCoordRound(685.951f/430.556f * xHeight);
     denShift2 = NSToCoordRound(344.841f/430.556f * xHeight);
   }
 
   static void
   GetEmHeight(nsFontMetrics* fm,
               nscoord&        emHeight)
   {
-#if 0 
+#if 0
     // should switch to this API in order to scale with changes of TextZoom
-    fm->GetEmHeight(emHeight);
+    emHeight = fm->EmHeight();
 #else
     emHeight = NSToCoordRound(float(fm->Font().size));
 #endif
   }
 
   static void
   GetAxisHeight (nsFontMetrics* fm,
                  nscoord&        axisHeight)
   {
-    fm->GetXHeight (axisHeight);
-    axisHeight = NSToCoordRound(250.000f/430.556f * axisHeight);
+    axisHeight = NSToCoordRound(250.000f/430.556f * fm->XHeight());
   }
 
   static void
   GetBigOpSpacings(nsFontMetrics* fm, 
                    nscoord&        bigOpSpacing1,
                    nscoord&        bigOpSpacing2,
                    nscoord&        bigOpSpacing3,
                    nscoord&        bigOpSpacing4,
                    nscoord&        bigOpSpacing5)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     bigOpSpacing1 = NSToCoordRound(111.111f/430.556f * xHeight);
     bigOpSpacing2 = NSToCoordRound(166.667f/430.556f * xHeight);
     bigOpSpacing3 = NSToCoordRound(200.000f/430.556f * xHeight);
     bigOpSpacing4 = NSToCoordRound(600.000f/430.556f * xHeight);
     bigOpSpacing5 = NSToCoordRound(100.000f/430.556f * xHeight);
   }
 
   static void
   GetRuleThickness(nsFontMetrics* fm,
                    nscoord&        ruleThickness)
   {
-    nscoord xHeight;
-    fm->GetXHeight(xHeight);
+    nscoord xHeight = fm->XHeight();
     ruleThickness = NSToCoordRound(40.000f/430.556f * xHeight);
   }
 
   // Some parameters are not accurately obtained using the x-height.
   // Here are some slower variants to obtain the desired metrics
   // by actually measuring some characters
   static void
   GetRuleThickness(nsRenderingContext& aRenderingContext, 
--- a/layout/mathml/nsMathMLTokenFrame.cpp
+++ b/layout/mathml/nsMathMLTokenFrame.cpp
@@ -206,19 +206,18 @@ nsMathMLTokenFrame::Place(nsRenderingCon
     GetReflowAndBoundingMetricsFor(childFrame, childSize,
                                    childSize.mBoundingMetrics, nsnull);
     // compute and cache the bounding metrics
     mBoundingMetrics += childSize.mBoundingMetrics;
   }
 
   nsRefPtr<nsFontMetrics> fm =
     PresContext()->GetMetricsFor(GetStyleFont()->mFont);
-  nscoord ascent, descent;
-  fm->GetMaxAscent(ascent);
-  fm->GetMaxDescent(descent);
+  nscoord ascent = fm->MaxAscent();
+  nscoord descent = fm->MaxDescent();
 
   aDesiredSize.mBoundingMetrics = mBoundingMetrics;
   aDesiredSize.width = mBoundingMetrics.width;
   aDesiredSize.ascent = NS_MAX(mBoundingMetrics.ascent, ascent);
   aDesiredSize.height = aDesiredSize.ascent +
                         NS_MAX(mBoundingMetrics.descent, descent);
 
   if (aPlaceOrigin) {
--- a/layout/mathml/nsMathMLmencloseFrame.cpp
+++ b/layout/mathml/nsMathMLmencloseFrame.cpp
@@ -394,17 +394,17 @@ nsMathMLmencloseFrame::PlaceInternal(nsR
   if (delta)
     padding += onePixel - delta; // round up
 
   if (IsToDraw(NOTATION_LONGDIV) || IsToDraw(NOTATION_RADICAL)) {
       nscoord phi;
       // Rule 11, App. G, TeXbook
       // psi = clearance between rule and content
       if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
-        fm->GetXHeight(phi);
+        phi = fm->XHeight();
       else
         phi = mRuleThickness;
       psi = mRuleThickness + phi / 4;
 
       delta = psi % onePixel;
       if (delta)
         psi += onePixel - delta; // round up
     }
--- a/layout/mathml/nsMathMLmfencedFrame.cpp
+++ b/layout/mathml/nsMathMLmfencedFrame.cpp
@@ -264,20 +264,21 @@ nsMathMLmfencedFrame::Reflow(nsPresConte
   // refactored to use nsMathMLContainerFrame::Reflow() at some stage.
 
   nsReflowStatus childStatus;
   nsSize availSize(aReflowState.ComputedWidth(), NS_UNCONSTRAINEDSIZE);
   nsIFrame* firstChild = GetFirstChild(nsnull);
   nsIFrame* childFrame = firstChild;
   nscoord ascent = 0, descent = 0;
   if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
-    // We use the ASCII metrics to get our minimum height. This way, if we have
-    // borders or a background, they will fit better with other elements on the line
-    fm->GetMaxAscent(ascent);
-    fm->GetMaxDescent(descent);
+    // We use the ASCII metrics to get our minimum height. This way,
+    // if we have borders or a background, they will fit better with
+    // other elements on the line.
+    ascent = fm->MaxAscent();
+    descent = fm->MaxDescent();
   }
   while (childFrame) {
     nsHTMLReflowMetrics childDesiredSize(aDesiredSize.mFlags
                                          | NS_REFLOW_CALC_BOUNDING_METRICS);
     nsHTMLReflowState childReflowState(aPresContext, aReflowState,
                                        childFrame, availSize);
     rv = ReflowChild(childFrame, aPresContext, childDesiredSize,
                      childReflowState, childStatus);
--- a/layout/mathml/nsMathMLmfracFrame.cpp
+++ b/layout/mathml/nsMathMLmfracFrame.cpp
@@ -431,18 +431,17 @@ nsMathMLmfracFrame::PlaceInternal(nsRend
     }
   } else {
     nscoord numShift = 0.0;
     nscoord denShift = 0.0;
     nscoord padding = 3 * defaultRuleThickness;
     nscoord slashRatio = 3;
 
     // Define the constant used in the expression of the maximum width
-    nscoord em;
-    fm->GetEmHeight(em);
+    nscoord em = fm->EmHeight();
     nscoord slashMaxWidthConstant = 2 * em;
 
     // For large line thicknesses the minimum slash height is limited to the
     // largest expected height of a fraction
     nscoord slashMinHeight = slashRatio *
       NS_MIN(2 * mLineThickness, slashMaxWidthConstant);
 
     nscoord leftSpace = NS_MAX(padding, coreData.leftSpace);
@@ -472,18 +471,17 @@ nsMathMLmfracFrame::PlaceInternal(nsRend
     }
 
     if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags)) {
       delta = NS_MIN(bmDen.ascent + bmDen.descent,
                      bmNum.ascent + bmNum.descent) / 2;
       numShift += delta;
       denShift += delta;
     } else {
-      nscoord xHeight = 0;
-      fm->GetXHeight (xHeight);
+      nscoord xHeight = fm->XHeight();
       numShift += xHeight / 2;
       denShift += xHeight / 4;
     }
    
     // Set the ascent/descent of our BoundingMetrics.
     mBoundingMetrics.ascent = bmNum.ascent + numShift;
     mBoundingMetrics.descent = bmDen.descent + denShift;
 
--- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp
+++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp
@@ -159,18 +159,17 @@ nsMathMLmmultiscriptsFrame::Place(nsRend
   ProcessAttributes();
 
   // get x-height (an ex)
   const nsStyleFont* font = GetStyleFont();
   aRenderingContext.SetFont(font->mFont,
                             PresContext()->GetUserFontSet());
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
 
-  nscoord xHeight;
-  fm->GetXHeight (xHeight);
+  nscoord xHeight = fm->XHeight();
 
   nscoord ruleSize;
   GetRuleThickness (aRenderingContext, fm, ruleSize);
 
   // scriptspace from TeX for extra spacing after sup/subscript (0.5pt in plain TeX)
   // forced to be at least 1 pixel here
   nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
   nscoord scriptSpace = NS_MAX(nsPresContext::CSSPointsToAppUnits(0.5f), onePixel);
--- a/layout/mathml/nsMathMLmoFrame.cpp
+++ b/layout/mathml/nsMathMLmoFrame.cpp
@@ -849,19 +849,18 @@ nsMathMLmoFrame::Stretch(nsRenderingCont
     // see bug 188467 for what is going on here
     nscoord dy = aDesiredStretchSize.ascent - (mBoundingMetrics.ascent + leading);
     aDesiredStretchSize.ascent = mBoundingMetrics.ascent + leading;
     aDesiredStretchSize.height = aDesiredStretchSize.ascent + mBoundingMetrics.descent;
 
     firstChild->SetPosition(firstChild->GetPosition() - nsPoint(0, dy));
   }
   else if (useMathMLChar) {
-    nscoord ascent, descent;
-    fm->GetMaxAscent(ascent);
-    fm->GetMaxDescent(descent);
+    nscoord ascent = fm->MaxAscent();
+    nscoord descent = fm->MaxDescent();
     aDesiredStretchSize.ascent = NS_MAX(mBoundingMetrics.ascent + leading, ascent);
     aDesiredStretchSize.height = aDesiredStretchSize.ascent +
                                  NS_MAX(mBoundingMetrics.descent + leading, descent);
   }
   aDesiredStretchSize.width = mBoundingMetrics.width;
   aDesiredStretchSize.mBoundingMetrics = mBoundingMetrics;
   mReference.x = 0;
   mReference.y = aDesiredStretchSize.ascent;
--- a/layout/mathml/nsMathMLmoverFrame.cpp
+++ b/layout/mathml/nsMathMLmoverFrame.cpp
@@ -280,18 +280,17 @@ nsMathMLmoverFrame::Place(nsRenderingCon
 
   ////////////////////
   // Place Children
 
   aRenderingContext.SetFont(GetStyleFont()->mFont,
                             PresContext()->GetUserFontSet());
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
 
-  nscoord xHeight = 0;
-  fm->GetXHeight (xHeight);
+  nscoord xHeight = fm->XHeight();
 
   nscoord ruleThickness;
   GetRuleThickness (aRenderingContext, fm, ruleThickness);
 
   // there are 2 different types of placement depending on 
   // whether we want an accented overscript or not
 
   nscoord correction = 0;
--- a/layout/mathml/nsMathMLmrootFrame.cpp
+++ b/layout/mathml/nsMathMLmrootFrame.cpp
@@ -156,18 +156,17 @@ nsMathMLmrootFrame::BuildDisplayList(nsD
 static void
 GetRadicalXOffsets(nscoord aIndexWidth, nscoord aSqrWidth,
                    nsFontMetrics* aFontMetrics,
                    nscoord* aIndexOffset, nscoord* aSqrOffset)
 {
   // The index is tucked in closer to the radical while making sure
   // that the kern does not make the index and radical collide
   nscoord dxIndex, dxSqr;
-  nscoord xHeight = 0;
-  aFontMetrics->GetXHeight(xHeight);
+  nscoord xHeight = aFontMetrics->XHeight();
   nscoord indexRadicalKern = NSToCoordRound(1.35f * xHeight);
   if (indexRadicalKern > aIndexWidth) {
     dxIndex = indexRadicalKern - aIndexWidth;
     dxSqr = 0;
   }
   else {
     dxIndex = 0;
     dxSqr = aIndexWidth - indexRadicalKern;
@@ -276,17 +275,17 @@ nsMathMLmrootFrame::Reflow(nsPresContext
   // this seems more reliable than using fm->GetLeading() on suspicious fonts
   GetEmHeight(fm, em);
   leading = nscoord(0.2f * em); 
 
   // Rule 11, App. G, TeXbook
   // psi = clearance between rule and content
   nscoord phi = 0, psi = 0;
   if (NS_MATHML_IS_DISPLAYSTYLE(mPresentationData.flags))
-    fm->GetXHeight(phi);
+    phi = fm->XHeight();
   else
     phi = ruleThickness;
   psi = ruleThickness + phi/4;
 
   // built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, p.131)
   if (bmOne.ascent > bmBase.ascent)
     psi += bmOne.ascent - bmBase.ascent;
 
--- a/layout/mathml/nsMathMLmsubFrame.cpp
+++ b/layout/mathml/nsMathMLmsubFrame.cpp
@@ -151,17 +151,17 @@ nsMathMLmsubFrame::PlaceSubScript (nsPre
   // Place Children
   
   // get min subscript shift limit from x-height
   // = h(x) - 4/5 * sigma_5, Rule 18b, App. G, TeXbook
   nscoord xHeight = 0;
   nsRefPtr<nsFontMetrics> fm =
     aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
 
-  fm->GetXHeight (xHeight);
+  xHeight = fm->XHeight();
   nscoord minShiftFromXHeight = (nscoord) 
     (bmSubScript.ascent - (4.0f/5.0f) * xHeight);
 
   // subScriptShift
   // = minimum amount to shift the subscript down set by user or from the font
   // = sub1 in TeX
   // = subscriptshift attribute * x-height
   nscoord subScriptShift, dummy;
--- a/layout/mathml/nsMathMLmsubsupFrame.cpp
+++ b/layout/mathml/nsMathMLmsubsupFrame.cpp
@@ -193,18 +193,17 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(
   // subScriptShift1 = subscriptshift attribute * x-height
   nscoord subScriptShift1, subScriptShift2;
 
   aRenderingContext.SetFont(baseFrame->GetStyleFont()->mFont,
                             aPresContext->GetUserFontSet());
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
 
   // get x-height (an ex)
-  nscoord xHeight;
-  fm->GetXHeight (xHeight);
+  nscoord xHeight = fm->XHeight();
 
   nscoord ruleSize;
   GetRuleThickness (aRenderingContext, fm, ruleSize);
 
   // Get subScriptShift{1,2} default from font
   GetSubScriptShifts (fm, subScriptShift1, subScriptShift2);
 
   if (0 < aUserSubScriptShift) {
--- a/layout/mathml/nsMathMLmsupFrame.cpp
+++ b/layout/mathml/nsMathMLmsupFrame.cpp
@@ -152,17 +152,17 @@ nsMathMLmsupFrame::PlaceSuperScript(nsPr
   // Place Children 
   
   // get min supscript shift limit from x-height
   // = d(x) + 1/4 * sigma_5, Rule 18c, App. G, TeXbook
   nscoord xHeight = 0;
   nsRefPtr<nsFontMetrics> fm =
     aPresContext->GetMetricsFor(baseFrame->GetStyleFont()->mFont);
 
-  fm->GetXHeight (xHeight);
+  xHeight = fm->XHeight();
   nscoord minShiftFromXHeight = (nscoord) 
     (bmSupScript.descent + (1.0f/4.0f) * xHeight);
   nscoord italicCorrection;
   GetItalicCorrection(bmBase, italicCorrection);
 
   // supScriptShift{1,2,3}
   // = minimum amount to shift the supscript up
   // = sup{1,2,3} in TeX
--- a/layout/mathml/nsMathMLmunderFrame.cpp
+++ b/layout/mathml/nsMathMLmunderFrame.cpp
@@ -277,18 +277,17 @@ nsMathMLmunderFrame::Place(nsRenderingCo
 
   ////////////////////
   // Place Children
 
   aRenderingContext.SetFont(GetStyleFont()->mFont,
                             PresContext()->GetUserFontSet());
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
 
-  nscoord xHeight = 0;
-  fm->GetXHeight (xHeight);
+  nscoord xHeight = fm->XHeight();
 
   nscoord ruleThickness;
   GetRuleThickness (aRenderingContext, fm, ruleThickness);
 
   // there are 2 different types of placement depending on 
   // whether we want an accented under or not
 
   nscoord correction = 0;
--- a/layout/mathml/nsMathMLmunderoverFrame.cpp
+++ b/layout/mathml/nsMathMLmunderoverFrame.cpp
@@ -319,18 +319,17 @@ nsMathMLmunderoverFrame::Place(nsRenderi
 
   ////////////////////
   // Place Children
 
   aRenderingContext.SetFont(GetStyleFont()->mFont,
                             PresContext()->GetUserFontSet());
   nsFontMetrics* fm = aRenderingContext.FontMetrics();
 
-  nscoord xHeight = 0;
-  fm->GetXHeight (xHeight);
+  nscoord xHeight = fm->XHeight();
 
   nscoord ruleThickness;
   GetRuleThickness (aRenderingContext, fm, ruleThickness);
 
   nscoord correction = 0;
   GetItalicCorrection (bmBase, correction);
 
   // there are 2 different types of placement depending on 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -305,19 +305,17 @@ static nscoord CalcLengthWith(const nsCS
       return ScaleCoord(aValue, float(aFontSize));
       // XXX scale against font metrics height instead?
     }
     case eCSSUnit_XHeight: {
       nsFont font = styleFont->mFont;
       font.size = aFontSize;
       nsRefPtr<nsFontMetrics> fm =
         aPresContext->GetMetricsFor(font, aUseUserFontSet);
-      nscoord xHeight;
-      fm->GetXHeight(xHeight);
-      return ScaleCoord(aValue, float(xHeight));
+      return ScaleCoord(aValue, float(fm->XHeight()));
     }
     case eCSSUnit_Char: {
       nsFont font = styleFont->mFont;
       font.size = aFontSize;
       nsRefPtr<nsFontMetrics> fm =
         aPresContext->GetMetricsFor(font, aUseUserFontSet);
       gfxFloat zeroWidth = (fm->GetThebesFontGroup()->GetFontAt(0)
                             ->GetMetrics().zeroOrAveCharWidth);
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -292,18 +292,17 @@ nsSVGUtils::GetFontXHeight(nsStyleContex
                                                getter_AddRefs(fontMetrics));
 
   if (!fontMetrics) {
     // ReportToConsole
     NS_WARNING("no FontMetrics in GetFontXHeight()");
     return 1.0f;
   }
 
-  nscoord xHeight;
-  fontMetrics->GetXHeight(xHeight);
+  nscoord xHeight = fontMetrics->XHeight();
   return nsPresContext::AppUnitsToFloatCSSPixels(xHeight) /
          presContext->TextZoom();
 }
 
 void
 nsSVGUtils::UnPremultiplyImageDataAlpha(PRUint8 *data, 
                                         PRInt32 stride,
                                         const nsIntRect &rect)
--- a/layout/xul/base/src/nsListBoxBodyFrame.cpp
+++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp
@@ -222,17 +222,17 @@ nsListBoxBodyFrame::Init(nsIContent*    
     nsIBox* verticalScrollbar = scrollFrame->GetScrollbarBox(PR_TRUE);
     if (verticalScrollbar) {
       nsIScrollbarFrame* scrollbarFrame = do_QueryFrame(verticalScrollbar);
       scrollbarFrame->SetScrollbarMediatorContent(GetContent());
     }
   }
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
-  fm->GetMaxHeight(mRowHeight);
+  mRowHeight = fm->MaxHeight();
 
   return rv;
 }
 
 void
 nsListBoxBodyFrame::DestroyFrom(nsIFrame* aDestructRoot)
 {
   // make sure we cancel any posted callbacks.
--- a/layout/xul/base/src/nsTextBoxFrame.cpp
+++ b/layout/xul/base/src/nsTextBoxFrame.cpp
@@ -476,18 +476,17 @@ nsTextBoxFrame::DrawText(nsRenderingCont
       }
     } while (context && hasDecorations && (0 != decorMask));
 
     nsRefPtr<nsFontMetrics> fontMet;
     nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
 
     nscoord offset;
     nscoord size;
-    nscoord ascent;
-    fontMet->GetMaxAscent(ascent);
+    nscoord ascent = fontMet->MaxAscent();
 
     nscoord baseline =
       presContext->RoundAppUnitsToNearestDevPixels(aTextRect.y + ascent);
     nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
     gfxPoint pt(presContext->AppUnitsToGfxUnits(aTextRect.x),
                 presContext->AppUnitsToGfxUnits(aTextRect.y));
     gfxFloat width = presContext->AppUnitsToGfxUnits(aTextRect.width);
     gfxFloat ascentPixel = presContext->AppUnitsToGfxUnits(ascent);
@@ -652,17 +651,17 @@ nsTextBoxFrame::CalculateUnderline(nsRen
          aRenderingContext.SetTextRunRTL(PR_FALSE);
          mAccessKeyInfo->mAccessWidth =
              aRenderingContext.GetWidth(titleString[mAccessKeyInfo->
                                                     mAccesskeyIndex]);
 
          nscoord offset, baseline;
          nsFontMetrics* metrics = aRenderingContext.FontMetrics();
          metrics->GetUnderline(offset, mAccessKeyInfo->mAccessUnderlineSize);
-         metrics->GetMaxAscent(baseline);
+         baseline = metrics->MaxAscent();
          mAccessKeyInfo->mAccessOffset = baseline - offset;
     }
 }
 
 nscoord
 nsTextBoxFrame::CalculateTitleForWidth(nsPresContext*      aPresContext,
                                        nsRenderingContext& aRenderingContext,
                                        nscoord              aWidth)
@@ -991,26 +990,29 @@ nsTextBoxFrame::ComputesOwnOverflowArea(
 /* virtual */ void
 nsTextBoxFrame::MarkIntrinsicWidthsDirty()
 {
     mNeedsRecalc = PR_TRUE;
     nsTextBoxFrameSuper::MarkIntrinsicWidthsDirty();
 }
 
 void
-nsTextBoxFrame::GetTextSize(nsPresContext* aPresContext, nsRenderingContext& aRenderingContext,
-                                const nsString& aString, nsSize& aSize, nscoord& aAscent)
+nsTextBoxFrame::GetTextSize(nsPresContext* aPresContext,
+                            nsRenderingContext& aRenderingContext,
+                            const nsString& aString,
+                            nsSize& aSize, nscoord& aAscent)
 {
     nsRefPtr<nsFontMetrics> fontMet;
     nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
-    fontMet->GetMaxHeight(aSize.height);
+    aSize.height = fontMet->MaxHeight();
     aRenderingContext.SetFont(fontMet);
     aSize.width =
-      nsLayoutUtils::GetStringWidth(this, &aRenderingContext, aString.get(), aString.Length());
-    fontMet->GetMaxAscent(aAscent);
+      nsLayoutUtils::GetStringWidth(this, &aRenderingContext,
+                                    aString.get(), aString.Length());
+    aAscent = fontMet->MaxAscent();
 }
 
 void
 nsTextBoxFrame::CalcTextSize(nsBoxLayoutState& aBoxLayoutState)
 {
     if (mNeedsRecalc)
     {
         nsSize size;
--- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp
@@ -1259,18 +1259,17 @@ nsTreeBodyFrame::GetCoordsForCellItem(PR
     // the remaining width available, then we just assume that the text has 
     // been cropped and use the remaining rect as the text Rect. Otherwise,
     // we add in borders and padding to the text dimension and give that back. 
     nsStyleContext* textContext = GetPseudoStyleContext(nsCSSAnonBoxes::moztreecelltext);
 
     nsRefPtr<nsFontMetrics> fm;
     nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
                                                  getter_AddRefs(fm));
-    nscoord height;
-    fm->GetMaxHeight(height);
+    nscoord height = fm->MaxHeight();
 
     nsMargin textMargin;
     textContext->GetStyleMargin()->GetMargin(textMargin);
     textRect.Deflate(textMargin);
 
     // Center the text. XXX Obey vertical-align style prop?
     if (height < textRect.height) {
       textRect.y += (textRect.height - height) / 2;
@@ -3567,19 +3566,18 @@ nsTreeBodyFrame::PaintText(PRInt32      
   GetBorderPadding(textContext, bp);
   textRect.Deflate(bp);
 
   // Compute our text size.
   nsRefPtr<nsFontMetrics> fontMet;
   nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
                                                getter_AddRefs(fontMet));
 
-  nscoord height, baseline;
-  fontMet->GetMaxHeight(height);
-  fontMet->GetMaxAscent(baseline);
+  nscoord height = fontMet->MaxHeight();
+  nscoord baseline = fontMet->MaxAscent();
 
   // Center the text. XXX Obey vertical-align style prop?
   if (height < textRect.height) {
     textRect.y += (textRect.height - height)/2;
     textRect.height = height;
   }
 
   // Set our font.