Add inflation parameter to nsLayoutUtils::GetFontMetricsFor* methods. (Bug 627842, patch 6) r=roc

This commit is contained in:
L. David Baron 2011-11-23 18:48:23 -08:00
parent 63185e44d3
commit 1d37b2b7c1
2 changed files with 20 additions and 7 deletions

View File

@ -1926,22 +1926,31 @@ nsLayoutUtils::GetTextShadowRectsUnion(const nsRect& aTextAndDecorationsRect,
nsresult
nsLayoutUtils::GetFontMetricsForFrame(const nsIFrame* aFrame,
nsFontMetrics** aFontMetrics)
nsFontMetrics** aFontMetrics,
float aInflation)
{
return nsLayoutUtils::GetFontMetricsForStyleContext(aFrame->GetStyleContext(),
aFontMetrics);
aFontMetrics,
aInflation);
}
nsresult
nsLayoutUtils::GetFontMetricsForStyleContext(nsStyleContext* aStyleContext,
nsFontMetrics** aFontMetrics)
nsFontMetrics** aFontMetrics,
float aInflation)
{
// pass the user font set object into the device context to pass along to CreateFontGroup
gfxUserFontSet* fs = aStyleContext->PresContext()->GetUserFontSet();
nsFont font = aStyleContext->GetStyleFont()->mFont;
// We need to not run font.size through floats when it's large since
// doing so would be lossy. Fortunately, in such cases, aInflation is
// guaranteed to be 1.0f.
if (aInflation != 1.0f) {
font.size = NSToCoordRound(font.size * aInflation);
}
return aStyleContext->PresContext()->DeviceContext()->GetMetricsFor(
aStyleContext->GetStyleFont()->mFont,
aStyleContext->GetStyleVisibility()->mLanguage,
font, aStyleContext->GetStyleVisibility()->mLanguage,
fs, *aFontMetrics);
}

View File

@ -741,19 +741,23 @@ public:
* Get the font metrics corresponding to the frame's style data.
* @param aFrame the frame
* @param aFontMetrics the font metrics result
* @param aSizeInflation number to multiply font size by
* @return success or failure code
*/
static nsresult GetFontMetricsForFrame(const nsIFrame* aFrame,
nsFontMetrics** aFontMetrics);
nsFontMetrics** aFontMetrics,
float aSizeInflation = 1.0f);
/**
* Get the font metrics corresponding to the given style data.
* @param aStyleContext the style data
* @param aFontMetrics the font metrics result
* @param aSizeInflation number to multiply font size by
* @return success or failure code
*/
static nsresult GetFontMetricsForStyleContext(nsStyleContext* aStyleContext,
nsFontMetrics** aFontMetrics);
nsFontMetrics** aFontMetrics,
float aSizeInflation = 1.0f);
/**
* Find the immediate child of aParent whose frame subtree contains