-
ojan@chromium.org authored
Make textarea and text input metrics more closely match IEs. This involves: -set text input width to size*avgCharWidth + maxCharWidth - avgCharWidth -set textarea width to cols*avgCharWidth -Make default CSS match IEs -Correctly initializing m_avgCharWidth and m_maxCharWidth for each platform and SVG. Those values for textarea and inputs were derived by doing a ton of manual testing of IE's width values for various textareas and fonts. On Windows we match IE exactly except for a couple fonts of the ~12 tested. To get the average and max character width of a font, we do the following for each platform: -Win: TextMetrics expose avgCharWidth and maxCharWidth -SVG: avgCharWidth = width of an '0', fallback on width of a space glyph, then m_xHeight maxCharWidth = width of a 'W' for roman fonts, fallback on m_ascent -Linux: avgCharWidth = width of an '0', fallback on m_xHeight maxCharWidth = max of avgCharWidth and m_ascent -Mac: Calculate the avgCharWidth and grab the maxCharWidth off the font. If either one is non-positive, then calculate the value using the Linux approach. Tests: fast/forms/text-control-intrinsic-widths.html fast/forms/textarea-metrics.html svg/custom/svg-fonts-in-text-controls.html * css/html4.css: * css/themeWin.css: * platform/graphics/SimpleFontData.cpp: (WebCore::SimpleFontData::SimpleFontData): (WebCore::SimpleFontData::initCharWidths): * platform/graphics/SimpleFontData.h: (WebCore::SimpleFontData::maxCharWidth): (WebCore::SimpleFontData::avgCharWidth): * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/chromium/SimpleFontDataLinux.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/gtk/SimpleFontDataGtk.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/gtk/SimpleFontDataPango.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/mac/SimpleFontDataMac.mm: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/qt/SimpleFontDataQt.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/win/SimpleFontDataCGWin.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/win/SimpleFontDataCairoWin.cpp: (WebCore::SimpleFontData::platformInit): (WebCore::SimpleFontData::platformCharWidthInit): * platform/graphics/win/SimpleFontDataWin.cpp: (WebCore::SimpleFontData::initGDIFont): * platform/graphics/wx/SimpleFontDataWx.cpp: (WebCore::SimpleFontData::platformCharWidthInit): * rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::calcPrefWidths): * rendering/RenderTextControlMultiLine.cpp: (WebCore::RenderTextControlMultiLine::createInnerTextStyle): * rendering/RenderTextControlSingleLine.cpp: (WebCore::RenderTextControlSingleLine::preferredContentWidth): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43007 268f45cc-cd09-0410-ab3c-d52691b4dbfc
149606a8