Pass nsFontMetrics to the GetEllipsis function rather than computing them again. (Bug 627842, patch 14) r=matspal
☠☠ backed out by 7c7dc8193692 ☠ ☠
authorL. David Baron <dbaron@dbaron.org>
Tue, 15 Nov 2011 17:02:01 +1300
changeset 80262 03c2ea0eeba392924fdc150a4b64a7dd3ffc35c7
parent 80261 e24d196602bf7974675ad250850291ecea205fd7
child 80263 7aca4ef8e5389f416f228b85d312a011525a5880
push id21481
push userbmo@edmorley.co.uk
push dateTue, 15 Nov 2011 19:07:44 +0000
treeherdermozilla-central@fd478c02c29c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmatspal
bugs627842
milestone11.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
Pass nsFontMetrics to the GetEllipsis function rather than computing them again. (Bug 627842, patch 14) r=matspal
layout/generic/TextOverflow.cpp
--- a/layout/generic/TextOverflow.cpp
+++ b/layout/generic/TextOverflow.cpp
@@ -56,22 +56,20 @@
 namespace mozilla {
 namespace css {
 
 static const PRUnichar kEllipsisChar[] = { 0x2026, 0x0 };
 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<nsFontMetrics> 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,
                         ArrayLength(kEllipsisChar) - 1)
     : nsDependentString(kASCIIPeriodsChar,
                         ArrayLength(kASCIIPeriodsChar) - 1);
 }
 
@@ -658,16 +656,16 @@ TextOverflow::Marker::SetupString(nsIFra
   }
   nsRefPtr<nsRenderingContext> rc =
     aFrame->PresContext()->PresShell()->GetReferenceRenderingContext();
   nsRefPtr<nsFontMetrics> fm;
   nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm));
   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;
 }
 
 }  // namespace css
 }  // namespace mozilla