Apply font size inflation to 'line-height: normal' by using the metrics of the inflated font rather than multiplying the inflation by the result for the uninflated font. (Bug 706609, patch 7) r=roc

This matters primarily because it makes font inflation easier to test by
avoiding rounding differences.  It fixes two existing tests that were
disabled and also makes it possible to test font inflation of selects
(since options have line-height: normal ! important in the UA style
sheet).
This commit is contained in:
L. David Baron 2012-01-24 17:21:29 -08:00
Родитель f18119e87a
Коммит 0b6372c3aa
2 изменённых файлов: 14 добавлений и 20 удалений

Просмотреть файл

@ -26,13 +26,9 @@ var gTests = [
// file) has font inflation set to 15 em per line.
// FIXME (maybe): Commented out due to rounding differences between
// inflating the 'normal' line height of a smaller font and using the
// normal line height of the inflated font.
//"== text-1.html text-1-ref.html",
"== text-1.html text-1-ref.html",
"== text-2.html text-2-ref.html",
// FIXME (maybe): same as text-1.
//"== text-3.html text-3-ref.html",
"== text-3.html text-3-ref.html",
"== text-4.html text-4-ref.html",
"== decoration-1.html decoration-1-ref.html",
"== bullet-1.html bullet-1-ref.html",

Просмотреть файл

@ -2170,20 +2170,23 @@ GetNormalLineHeight(nsFontMetrics* aFontMetrics)
static inline nscoord
ComputeLineHeight(nsStyleContext* aStyleContext,
nscoord aBlockHeight,
bool* aIsBlockHeight)
float aFontSizeInflation)
{
*aIsBlockHeight = false;
const nsStyleCoord& lhCoord = aStyleContext->GetStyleText()->mLineHeight;
if (lhCoord.GetUnit() == eStyleUnit_Coord)
return lhCoord.GetCoordValue();
if (lhCoord.GetUnit() == eStyleUnit_Coord) {
nscoord result = lhCoord.GetCoordValue();
if (aFontSizeInflation != 1.0f) {
result = NSToCoordRound(result * aFontSizeInflation);
}
return result;
}
if (lhCoord.GetUnit() == eStyleUnit_Factor)
// For factor units the computed value of the line-height property
// is found by multiplying the factor by the font's computed size
// (adjusted for min-size prefs and text zoom).
return NSToCoordRound(lhCoord.GetFactorValue() *
return NSToCoordRound(lhCoord.GetFactorValue() * aFontSizeInflation *
aStyleContext->GetStyleFont()->mFont.size);
NS_ASSERTION(lhCoord.GetUnit() == eStyleUnit_Normal ||
@ -2194,14 +2197,14 @@ ComputeLineHeight(nsStyleContext* aStyleContext,
NS_ASSERTION(lhCoord.GetIntValue() == NS_STYLE_LINE_HEIGHT_BLOCK_HEIGHT,
"bad line-height value");
if (aBlockHeight != NS_AUTOHEIGHT) {
*aIsBlockHeight = true;
return aBlockHeight;
}
}
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForStyleContext(aStyleContext,
getter_AddRefs(fm));
getter_AddRefs(fm),
aFontSizeInflation);
return GetNormalLineHeight(fm);
}
@ -2224,16 +2227,11 @@ nsHTMLReflowState::CalcLineHeight(nsStyleContext* aStyleContext,
{
NS_PRECONDITION(aStyleContext, "Must have a style context");
bool isBlockHeight;
nscoord lineHeight =
ComputeLineHeight(aStyleContext, aBlockHeight, &isBlockHeight);
ComputeLineHeight(aStyleContext, aBlockHeight, aFontSizeInflation);
NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
if (aFontSizeInflation != 1.0f && !isBlockHeight) {
lineHeight = NSToCoordRound(lineHeight * aFontSizeInflation);
}
return lineHeight;
}