From 163196360efde10281e5c0492fd6cb2e9318eec0 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Sun, 8 Nov 2015 14:48:58 -0800 Subject: [PATCH] Bug 1038663 (part 3, attempt 2) - Factor out space width computation. r=heycam. --- layout/generic/nsTextFrame.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 21a62b7f4405..59edf75dab95 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -1607,6 +1607,19 @@ GetFirstFontMetrics(gfxFontGroup* aFontGroup, bool aVerticalMetrics) : gfxFont::eHorizontal); } +static gfxFloat +GetSpaceWidthAppUnits(gfxTextRun* aTextRun) +{ + // Round the space width when converting to appunits the same way textruns + // do. + gfxFloat spaceWidthAppUnits = + NS_round(GetFirstFontMetrics(aTextRun->GetFontGroup(), + aTextRun->UseCenterBaseline()).spaceWidth * + aTextRun->GetAppUnitsPerDevUnit()); + + return spaceWidthAppUnits; +} + static nscoord LetterSpacing(nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr) { @@ -3225,14 +3238,8 @@ ComputeTabWidthAppUnits(nsIFrame* aFrame, gfxTextRun* aTextRun) { // Get the number of spaces from CSS -moz-tab-size const nsStyleText* textStyle = aFrame->StyleText(); - - // Round the space width when converting to appunits the same way - // textruns do - gfxFloat spaceWidthAppUnits = - NS_round(GetFirstFontMetrics(aTextRun->GetFontGroup(), - aTextRun->UseCenterBaseline()).spaceWidth * - aTextRun->GetAppUnitsPerDevUnit()); - return textStyle->mTabSize * spaceWidthAppUnits; + + return textStyle->mTabSize * GetSpaceWidthAppUnits(aTextRun); } // aX and the result are in whole appunits.