зеркало из https://github.com/mozilla/pjs.git
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
This commit is contained in:
Родитель
81cb7bd2b1
Коммит
6840e86e82
|
@ -1479,14 +1479,17 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext,
|
||||||
fontMet->GetAveCharWidth(charWidth);
|
fontMet->GetAveCharWidth(charWidth);
|
||||||
fontMet->GetMaxAdvance(charMaxAdvance);
|
fontMet->GetMaxAdvance(charMaxAdvance);
|
||||||
|
|
||||||
// calc the min width and pref width. Pref Width is calced by multiplying the size times avecharwidth
|
// Set the width equal to the width in characters
|
||||||
|
aDesiredSize.width = GetCols() * 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
|
||||||
|
// this if charMaxAdvance != charWidth; if they are equal, this is almost
|
||||||
|
// certainly a fixed-width font.
|
||||||
|
if (charWidth != charMaxAdvance) {
|
||||||
float p2t;
|
float p2t;
|
||||||
aPresContext->GetPixelsToTwips(&p2t);
|
aPresContext->GetPixelsToTwips(&p2t);
|
||||||
|
nscoord internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0);
|
||||||
// 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
|
// round to a multiple of p2t
|
||||||
nscoord t = NSToCoordRound(p2t);
|
nscoord t = NSToCoordRound(p2t);
|
||||||
nscoord rest = internalPadding % t;
|
nscoord rest = internalPadding % t;
|
||||||
|
@ -1495,11 +1498,9 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext,
|
||||||
} else {
|
} else {
|
||||||
internalPadding += t - rest;
|
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)
|
// Now add the extra padding on (so that small input sizes work well)
|
||||||
aDesiredSize.width += internalPadding;
|
aDesiredSize.width += internalPadding;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the height equal to total number of rows (times the height of each
|
// Set the height equal to total number of rows (times the height of each
|
||||||
// line, of course)
|
// line, of course)
|
||||||
|
|
|
@ -1479,14 +1479,17 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext,
|
||||||
fontMet->GetAveCharWidth(charWidth);
|
fontMet->GetAveCharWidth(charWidth);
|
||||||
fontMet->GetMaxAdvance(charMaxAdvance);
|
fontMet->GetMaxAdvance(charMaxAdvance);
|
||||||
|
|
||||||
// calc the min width and pref width. Pref Width is calced by multiplying the size times avecharwidth
|
// Set the width equal to the width in characters
|
||||||
|
aDesiredSize.width = GetCols() * 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
|
||||||
|
// this if charMaxAdvance != charWidth; if they are equal, this is almost
|
||||||
|
// certainly a fixed-width font.
|
||||||
|
if (charWidth != charMaxAdvance) {
|
||||||
float p2t;
|
float p2t;
|
||||||
aPresContext->GetPixelsToTwips(&p2t);
|
aPresContext->GetPixelsToTwips(&p2t);
|
||||||
|
nscoord internalPadding = PR_MAX(charMaxAdvance - NSToCoordRound(4 * p2t), 0);
|
||||||
// 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
|
// round to a multiple of p2t
|
||||||
nscoord t = NSToCoordRound(p2t);
|
nscoord t = NSToCoordRound(p2t);
|
||||||
nscoord rest = internalPadding % t;
|
nscoord rest = internalPadding % t;
|
||||||
|
@ -1495,11 +1498,9 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext,
|
||||||
} else {
|
} else {
|
||||||
internalPadding += t - rest;
|
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)
|
// Now add the extra padding on (so that small input sizes work well)
|
||||||
aDesiredSize.width += internalPadding;
|
aDesiredSize.width += internalPadding;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the height equal to total number of rows (times the height of each
|
// Set the height equal to total number of rows (times the height of each
|
||||||
// line, of course)
|
// line, of course)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче