Bug 157846. Part 0.2: Relax heuristic used to detect 'monospace' font for <input> sizing so that it at least includes 'monospace' font-family in Windows 7. r=mats

--HG--
extra : rebase_source : 70bfb8df0c582433ea786b7092536806186ca3d3
This commit is contained in:
Robert O'Callahan 2014-01-16 14:37:41 +13:00
parent 9fee26b161
commit e5939669c9

View File

@ -45,6 +45,7 @@
#include "nsTextNode.h"
#include "nsStyleSet.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/MathAlgorithms.h"
#define DEFAULT_COLUMN_WIDTH 20
@ -169,11 +170,10 @@ nsTextControlFrame::CalcIntrinsicSize(nsRenderingContext* aRenderingContext,
// 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) {
nscoord internalPadding = std::max(0, charMaxAdvance -
nsPresContext::CSSPixelsToAppUnits(4));
// this if we think we have a fixed-width font.
if (std::abs(charWidth - charMaxAdvance) > nsPresContext::CSSPixelsToAppUnits(1)) {
nscoord internalPadding =
std::max(0, charMaxAdvance - nsPresContext::CSSPixelsToAppUnits(4));
nscoord t = nsPresContext::CSSPixelsToAppUnits(1);
// Round to a multiple of t
nscoord rest = internalPadding % t;