From 6840e86e82b723f15479c641f3f1b1494b39b004 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Mon, 10 Nov 2003 23:42:43 +0000 Subject: [PATCH] Don't do our "enlarge the control a bit to make it look better for small sizes" thing for fixed-width fonts -- it's unnecessary and just makes it look like "size" is broken. Bug 103293, r+sr=rbs --- layout/forms/nsTextControlFrame.cpp | 39 ++++++++++---------- layout/html/forms/src/nsTextControlFrame.cpp | 39 ++++++++++---------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index 74d34d557db..19ba6b57005 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1479,27 +1479,28 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext, fontMet->GetAveCharWidth(charWidth); fontMet->GetMaxAdvance(charMaxAdvance); - // calc the min width and pref width. Pref Width is calced by multiplying the size times avecharwidth - float p2t; - aPresContext->GetPixelsToTwips(&p2t); - - // To better match IE, take the maximum character width(in twips) and remove 4 pixels - // add this on as additional padding(internalPadding) - nscoord internalPadding = 0; - internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0); - // round to a multiple of p2t - nscoord t = NSToCoordRound(p2t); - nscoord rest = internalPadding % t; - if (rest < t - rest) { - internalPadding -= rest; - } else { - internalPadding += t - rest; - } - // Set the width equal to the width in characters aDesiredSize.width = GetCols() * charWidth; - // Now add the extra padding on (so that small input sizes work well) - aDesiredSize.width += internalPadding; + + // 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 + // this if charMaxAdvance != charWidth; if they are equal, this is almost + // certainly a fixed-width font. + if (charWidth != charMaxAdvance) { + float p2t; + aPresContext->GetPixelsToTwips(&p2t); + nscoord internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0); + // round to a multiple of p2t + nscoord t = NSToCoordRound(p2t); + nscoord rest = internalPadding % t; + if (rest < t - rest) { + internalPadding -= rest; + } else { + internalPadding += t - rest; + } + // Now add the extra padding on (so that small input sizes work well) + aDesiredSize.width += internalPadding; + } // Set the height equal to total number of rows (times the height of each // line, of course) diff --git a/layout/html/forms/src/nsTextControlFrame.cpp b/layout/html/forms/src/nsTextControlFrame.cpp index 74d34d557db..19ba6b57005 100644 --- a/layout/html/forms/src/nsTextControlFrame.cpp +++ b/layout/html/forms/src/nsTextControlFrame.cpp @@ -1479,27 +1479,28 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext, fontMet->GetAveCharWidth(charWidth); fontMet->GetMaxAdvance(charMaxAdvance); - // calc the min width and pref width. Pref Width is calced by multiplying the size times avecharwidth - float p2t; - aPresContext->GetPixelsToTwips(&p2t); - - // To better match IE, take the maximum character width(in twips) and remove 4 pixels - // add this on as additional padding(internalPadding) - nscoord internalPadding = 0; - internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0); - // round to a multiple of p2t - nscoord t = NSToCoordRound(p2t); - nscoord rest = internalPadding % t; - if (rest < t - rest) { - internalPadding -= rest; - } else { - internalPadding += t - rest; - } - // Set the width equal to the width in characters aDesiredSize.width = GetCols() * charWidth; - // Now add the extra padding on (so that small input sizes work well) - aDesiredSize.width += internalPadding; + + // 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 + // this if charMaxAdvance != charWidth; if they are equal, this is almost + // certainly a fixed-width font. + if (charWidth != charMaxAdvance) { + float p2t; + aPresContext->GetPixelsToTwips(&p2t); + nscoord internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0); + // round to a multiple of p2t + nscoord t = NSToCoordRound(p2t); + nscoord rest = internalPadding % t; + if (rest < t - rest) { + internalPadding -= rest; + } else { + internalPadding += t - rest; + } + // Now add the extra padding on (so that small input sizes work well) + aDesiredSize.width += internalPadding; + } // Set the height equal to total number of rows (times the height of each // line, of course)