Remove nsPresContext::GetMetricsFor, which was always a bad idea since it uses the generally-incorrect language-from-charset. (Bug 678671, patch 4) r=roc
authorL. David Baron <dbaron@dbaron.org>
Sun, 14 Aug 2011 10:08:04 -0700
changeset 75281 83291ec2e28e44e466a819422c9850af8320b48b
parent 75280 3a378e08192f9fcca5af00951674ee85898b0f90
child 75282 f982f2186319139edc49b9ea360cce5f6a25998a
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersroc
bugs678671
milestone8.0a1
Remove nsPresContext::GetMetricsFor, which was always a bad idea since it uses the generally-incorrect language-from-charset. (Bug 678671, patch 4) r=roc This fixes the one remaining caller (the debugging code to visually display reflow counts!) to just pass a null language, since it's just debugging code.
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1274,26 +1274,16 @@ nsPresContext::SetImageAnimationModeInte
 }
 
 void
 nsPresContext::SetImageAnimationModeExternal(PRUint16 aMode)
 {
   SetImageAnimationModeInternal(aMode);
 }
 
-already_AddRefed<nsFontMetrics>
-nsPresContext::GetMetricsFor(const nsFont& aFont, PRBool aUseUserFontSet)
-{
-  nsFontMetrics* metrics = nsnull;
-  mDeviceContext->GetMetricsFor(aFont, mLanguage,
-                                aUseUserFontSet ? GetUserFontSet() : nsnull,
-                                metrics);
-  return metrics;
-}
-
 const nsFont*
 nsPresContext::GetDefaultFont(PRUint8 aFontID) const
 {
   const nsFont *font;
   switch (aFontID) {
     // Special (our default variable width font and fixed width font)
     case kPresContext_DefaultVariableFont_ID:
       font = &mDefaultVariableFont;
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -319,27 +319,16 @@ public:
   void FreeToShell(size_t aSize, void* aFreeChunk)
   {
     NS_ASSERTION(mShell, "freeing after shutdown");
     if (mShell)
       mShell->FreeMisc(aSize, aFreeChunk);
   }
 
   /**
-   * Get the font metrics for a given font.
-   *
-   * If aUseUserFontSet is false, don't build or use the user font set.
-   * This is intended only for nsRuleNode::CalcLengthWithInitialFont
-   * (which is used from media query matching, which is in turn called
-   * when building the user font set).
-   */
-  NS_HIDDEN_(already_AddRefed<nsFontMetrics>)
-  GetMetricsFor(const nsFont& aFont, PRBool aUseUserFontSet = PR_TRUE);
-
-  /**
    * Get the default font corresponding to the given ID.  This object is
    * read-only, you must copy the font to modify it.
    * 
    * When aFontID is kPresContext_DefaultVariableFontID or
    * kPresContext_DefaultFixedFontID (which equals
    * kGenericFont_moz_fixed, which is used for the -moz-fixed generic),
    * the nsFont returned has its name as a CSS generic family (serif or
    * sans-serif for the former, monospace for the latter), and its size
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -8994,17 +8994,23 @@ void ReflowCountMgr::PaintCount(const ch
       (IndiReflowCounter *)PL_HashTableLookup(mIndiFrameCounts, key);
     if (counter != nsnull && counter->mName.EqualsASCII(aName)) {
       aRenderingContext->PushState();
       aRenderingContext->Translate(aOffset);
       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);
+      nsRefPtr<nsFontMetrics> fm;
+      aPresContext->DeviceContext()->GetMetricsFor(font,
+        // We have one frame, therefore we must have a root...
+        aPresContext->FrameManager()->GetRootFrame()->
+          GetStyleVisibility()->mLanguage,
+        aPresContext->GetUserFontSet(), *getter_AddRefs(fm));
+
       aRenderingContext->SetFont(fm);
       char buf[16];
       sprintf(buf, "%d", counter->mCount);
       nscoord x = 0, y = fm->MaxAscent();
       nscoord width, height = fm->MaxHeight();
       aRenderingContext->SetTextRunRTL(PR_FALSE);
       width = aRenderingContext->GetWidth(buf);