Add width for letter-spacing when calculating desired width of text input controls. b=252783 r=bzbarsky sr=dbaron

This commit is contained in:
mats.palmgren@bredband.net
2004-08-07 22:04:27 +00:00
parent 8c62253c36
commit c2028ec17e
2 changed files with 26 additions and 2 deletions

View File

@@ -1428,7 +1428,8 @@ nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext,
fontMet->GetMaxAdvance(charMaxAdvance);
// Set the width equal to the width in characters
aDesiredSize.width = GetCols() * charWidth;
PRInt32 cols = GetCols();
aDesiredSize.width = cols * charWidth;
// To better match IE, take the maximum character width(in twips) and remove
// 4 pixels add this on as additional padding(internalPadding). But only do
@@ -1456,6 +1457,17 @@ nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext,
}
}
// Increment width with cols * letter-spacing.
{
const nsStyleCoord& lsCoord = GetStyleText()->mLetterSpacing;
if (eStyleUnit_Coord == lsCoord.GetUnit()) {
nscoord letterSpacing = lsCoord.GetCoordValue();
if (letterSpacing != 0) {
aDesiredSize.width += cols * letterSpacing;
}
}
}
// Set the height equal to total number of rows (times the height of each
// line, of course)
aDesiredSize.height = fontHeight * GetRows();