From 2be505f301c19eb630eeabdfb4064aa3b98cb373 Mon Sep 17 00:00:00 2001 From: "dbaron%dbaron.org" Date: Mon, 29 Aug 2005 19:30:06 +0000 Subject: [PATCH] Base factor line-height values on the same concept of font size as em-based line-height values. b=196270 r+sr=bzbarsky git-svn-id: svn://10.0.0.236/trunk@179226 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsHTMLReflowState.cpp | 36 +++++++------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/mozilla/layout/generic/nsHTMLReflowState.cpp b/mozilla/layout/generic/nsHTMLReflowState.cpp index 5f5f48ce012..6741eaf7e7d 100644 --- a/mozilla/layout/generic/nsHTMLReflowState.cpp +++ b/mozilla/layout/generic/nsHTMLReflowState.cpp @@ -2232,41 +2232,31 @@ ComputeLineHeight(nsPresContext* aPresContext, { NS_PRECONDITION(nsnull != aRenderingContext, "no rendering context"); - nscoord lineHeight = -1; + nscoord lineHeight; - const nsStyleText* text = aStyleContext->GetStyleText(); const nsStyleFont* font = aStyleContext->GetStyleFont(); - const nsStyleVisibility* vis = aStyleContext->GetStyleVisibility(); + const nsStyleCoord& lhCoord = aStyleContext->GetStyleText()->mLineHeight; - nsStyleUnit unit = text->mLineHeight.GetUnit(); + nsStyleUnit unit = lhCoord.GetUnit(); if (unit == eStyleUnit_Coord) { // For length values just use the pre-computed value - lineHeight = text->mLineHeight.GetCoordValue(); + lineHeight = lhCoord.GetCoordValue(); + } else if (unit == 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). + float factor = lhCoord.GetFactorValue(); + lineHeight = NSToCoordRound(factor * font->mFont.size); } else { + NS_ASSERTION(eStyleUnit_Normal == unit, "bad unit"); nsCOMPtr deviceContext; aRenderingContext->GetDeviceContext(*getter_AddRefs(deviceContext)); + const nsStyleVisibility* vis = aStyleContext->GetStyleVisibility(); nsCOMPtr fm; deviceContext->GetMetricsFor(font->mFont, vis->mLangGroup, *getter_AddRefs(fm)); - if (unit == eStyleUnit_Factor) { - // For factor units the computed value of the line-height property - // is found by multiplying the factor by the font's actual - // em height. - float factor; - factor = text->mLineHeight.GetFactorValue(); - // Note: we normally use the actual font height for computing the - // line-height raw value from the style context. On systems where - // they disagree the actual font height is more appropriate. This - // little hack lets us override that behavior to allow for more - // precise layout in the face of imprecise fonts. - nscoord emHeight = font->mFont.size; - fm->GetEmHeight(emHeight); - lineHeight = NSToCoordRound(factor * emHeight); - } else { - NS_ASSERTION(eStyleUnit_Normal == unit, "bad unit"); - lineHeight = GetNormalLineHeight(fm); - } + lineHeight = GetNormalLineHeight(fm); } return lineHeight; }