Bug 16789

Summary: Problem of using "size" attribute to determine width of text input field
Product: WebKit Reporter: Yuzhu Shen <yuzhu.shen>
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: zsurocking
Priority: P2    
Version: 523.x (Safari 3)   
Hardware: PC   
OS: Windows XP   
Attachments:
Description Flags
Snapshot
none
An example for the problem. none

Description Yuzhu Shen 2008-01-08 19:04:24 PST
When using "size" attribute to determine the width of text input field, "its value refers to the (integer) number of characters" (HTML 4.0.1). Webkit (Safari 3.0.4 / 523.15) multiplies character width with this "size" value to determine the width, while IE & FF seem to use a non-linear algorithm.

The html file in the attachment illustrates the difference between these browsers, please view it in various browsers and observe the width of the input fields.

This problem affects many popular Chinese websites. For example: (Please refer to the attachment for snapshot.)

http://vip.bokee.com/register.php
http://www.5show.com/
http://www.cnfol.com/
http://www.people.com.cn/
http://www.92wy.com/
http://www.uusee.com/
http://www.wangyou.com/index2.html
Comment 1 Yuzhu Shen 2008-01-08 19:05:29 PST
Created attachment 18338 [details]
Snapshot
Comment 2 Yuzhu Shen 2008-01-08 19:07:18 PST
Created attachment 18339 [details]
An example for the problem.
Comment 3 zsurocking 2008-03-10 02:41:02 PDT
I think this bug lies in RenderTextControl::calcPrefWidths().
It's better to use tmAveCharWidth rather than "using 0 as the nominal character"

Also, in order to match IE, Firefox use "tmAveCharWidth * size + tmMaxCharWidth - 4" as the actual pixel width of the input text filed.
The code is here:
http://lxr.mozilla.org/mozilla/source/layout/forms/nsTextControlFrame.cpp
in nsTextControlFrame::CalcIntrinsicSize
Comment 4 Ojan Vafai 2009-03-24 18:41:04 PDT

*** This bug has been marked as a duplicate of 15312 ***