From 46718a5759733c1118d8fe529e367294b00d4a9f Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 23 Nov 2011 18:48:23 -0800 Subject: [PATCH] Pass nsFontMetrics to the GetEllipsis function rather than computing them again. (Bug 627842, patch 14) r=matspal --- layout/generic/TextOverflow.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index d509f308148..8ed733c289e 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -61,12 +61,10 @@ static const PRUnichar kASCIIPeriodsChar[] = { '.', '.', '.', 0x0 }; // Return an ellipsis if the font supports it, // otherwise use three ASCII periods as fallback. -static nsDependentString GetEllipsis(nsIFrame* aFrame) +static nsDependentString GetEllipsis(nsFontMetrics *aFontMetrics) { // Check if the first font supports Unicode ellipsis. - nsRefPtr fm; - nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm)); - gfxFontGroup* fontGroup = fm->GetThebesFontGroup(); + gfxFontGroup* fontGroup = aFontMetrics->GetThebesFontGroup(); gfxFont* firstFont = fontGroup->GetFontAt(0); return firstFont && firstFont->HasCharacter(kEllipsisChar[0]) ? nsDependentString(kEllipsisChar, @@ -663,7 +661,7 @@ TextOverflow::Marker::SetupString(nsIFrame* aFrame) rc->SetFont(fm); mMarkerString = mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS ? - GetEllipsis(aFrame) : mStyle->mString; + GetEllipsis(fm) : mStyle->mString; mWidth = nsLayoutUtils::GetStringWidth(aFrame, rc, mMarkerString.get(), mMarkerString.Length()); mInitialized = true;