mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-08 20:28:42 +02:00
Bug 1038663 (part 3, attempt 2) - Factor out space width computation. r=heycam.
This commit is contained in:
parent
a34dc73523
commit
163196360e
1 changed files with 15 additions and 8 deletions
|
|
@ -1607,6 +1607,19 @@ GetFirstFontMetrics(gfxFontGroup* aFontGroup, bool aVerticalMetrics)
|
||||||
: gfxFont::eHorizontal);
|
: 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
|
static nscoord
|
||||||
LetterSpacing(nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr)
|
LetterSpacing(nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr)
|
||||||
{
|
{
|
||||||
|
|
@ -3226,13 +3239,7 @@ ComputeTabWidthAppUnits(nsIFrame* aFrame, gfxTextRun* aTextRun)
|
||||||
// Get the number of spaces from CSS -moz-tab-size
|
// Get the number of spaces from CSS -moz-tab-size
|
||||||
const nsStyleText* textStyle = aFrame->StyleText();
|
const nsStyleText* textStyle = aFrame->StyleText();
|
||||||
|
|
||||||
// Round the space width when converting to appunits the same way
|
return textStyle->mTabSize * GetSpaceWidthAppUnits(aTextRun);
|
||||||
// textruns do
|
|
||||||
gfxFloat spaceWidthAppUnits =
|
|
||||||
NS_round(GetFirstFontMetrics(aTextRun->GetFontGroup(),
|
|
||||||
aTextRun->UseCenterBaseline()).spaceWidth *
|
|
||||||
aTextRun->GetAppUnitsPerDevUnit());
|
|
||||||
return textStyle->mTabSize * spaceWidthAppUnits;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// aX and the result are in whole appunits.
|
// aX and the result are in whole appunits.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue