Closed Bug 188872 Opened 22 years ago Closed 22 years ago

Switching between type of HTMLInputElement incorrectly reset size from Int to pixel

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: croo, Assigned: peterv)

Details

Attachments

(2 files)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3b) Gecko/20030112

Well, it is easy: if <input> type was text or password, and new type would be
text or password, size should not change it's value form int to pixels. But it do.

To reproduce bug, run testcase and press on buttons. You could see, that each
odd click press size of input become default size, and each even click it become
size=12 again (no difference betwen order of buttons usage).

Source of this behaviour is in file
source/content/html/content/src/nsHTMLInputElement.cpp, on line 537:

526     // If the type of the input has changed we might need to change the type
527     // of the size attribute.
528     nsHTMLValue value;
529     if (NS_CONTENT_ATTR_HAS_VALUE ==
530         GetHTMLAttribute(nsHTMLAtoms::size, value)) {
531       if (value.GetUnit() == eHTMLUnit_Pixel &&
532           (mType == NS_FORM_INPUT_TEXT ||
533            mType == NS_FORM_INPUT_PASSWORD)) {
534         nsHTMLValue newValue(value.GetPixelValue(), eHTMLUnit_Integer);
535         SetHTMLAttribute(nsHTMLAtoms::size, newValue, PR_FALSE);
536       }
537       else if (value.GetUnit() == eHTMLUnit_Integer) {
538         nsHTMLValue newValue(value.GetIntValue(), eHTMLUnit_Pixel);
539         SetHTMLAttribute(nsHTMLAtoms::size, newValue, PR_FALSE);
540       }
541     }

As you see, if we switch from pixels, this code check that new value is integer,
but if we switching from ineger, if in line 537 don't check, that new type is
not password or int.

So I suggest to chahnge it to:

if (value.GetUnit() == eHTMLUnit_Integer &&
    mType != NS_FORM_INPUT_TEXT && mType != NS_FORM_INPUT_PASSWORD )

(according with
http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-type-INPUT
When the type attribute has the value "text" or "password", this attribute
specifies the maximum number of characters the user may enter. This number may
exceed the specified size, in which case the user agent should offer a scrolling
mechanism. The default value for this attribute is an unlimited number.)
Summary: Switching between type of HTML type incorrectly reset size from Int to pixel → Switching between type of HTMLInputElement incorrectly reset size from Int to pixel
Attachment #111387 - Flags: superreview+
Attachment #111387 - Flags: review?(bugmail)
To peterv so he remembers to check this in
Assignee: jst → peterv
Flags: blocking1.3b?
Checked in.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Flags: blocking1.3b?
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: