Changeset 175622 in webkit


Ignore:
Timestamp:
Nov 5, 2014 9:41:08 AM (9 years ago)
Author:
Chris Dumez
Message:

Stop special-casing the empty string in HTMLInputElement.type setter
https://bugs.webkit.org/show_bug.cgi?id=138403

Reviewed by Ryosuke Niwa.

Source/WebCore:

Stop special-casing the empty string in HTMLInputElement.type setter.
Previously, if input.type is set to "", we would remove the type
attribute. This is inconsistent with the specification and the behavior
of other browsers (tested Firefox 33 and Chrome 38). Instead, we should
set the attribute to the empty string.

Also stop treating null as a null string to align with the
specification and other browsers (tested Firefox 33 and Chrome 38).

Finally, update HTMLInputElement::setType() to take an AtomicString in
argument instead of a String as it ends up calling setAttribute(), and
thus needing an AtomicString.

Test: fast/dom/HTMLInputElement/input-type-attribute.html

  • html/FileInputType.cpp:

(WebCore::UploadButtonElement::UploadButtonElement):

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::setType):

  • html/HTMLInputElement.h:
  • html/HTMLInputElement.idl:

LayoutTests:

Add layout test to check the functionality of the HTMLInputElement.type
getter and setter.

  • fast/dom/HTMLInputElement/input-type-attribute-expected.txt: Added.
  • fast/dom/HTMLInputElement/input-type-attribute.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r175617 r175622  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Stop special-casing the empty string in HTMLInputElement.type setter
     4        https://bugs.webkit.org/show_bug.cgi?id=138403
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add layout test to check the functionality of the HTMLInputElement.type
     9        getter and setter.
     10
     11        * fast/dom/HTMLInputElement/input-type-attribute-expected.txt: Added.
     12        * fast/dom/HTMLInputElement/input-type-attribute.html: Added.
     13
    1142014-11-05  Andreas Kling  <akling@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r175621 r175622  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Stop special-casing the empty string in HTMLInputElement.type setter
     4        https://bugs.webkit.org/show_bug.cgi?id=138403
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Stop special-casing the empty string in HTMLInputElement.type setter.
     9        Previously, if input.type is set to "", we would remove the type
     10        attribute. This is inconsistent with the specification and the behavior
     11        of other browsers (tested Firefox 33 and Chrome 38). Instead, we should
     12        set the attribute to the empty string.
     13
     14        Also stop treating null as a null string to align with the
     15        specification and other browsers (tested Firefox 33 and Chrome 38).
     16
     17        Finally, update HTMLInputElement::setType() to take an AtomicString in
     18        argument instead of a String as it ends up calling setAttribute(), and
     19        thus needing an AtomicString.
     20
     21
     22        Test: fast/dom/HTMLInputElement/input-type-attribute.html
     23
     24        * html/FileInputType.cpp:
     25        (WebCore::UploadButtonElement::UploadButtonElement):
     26        * html/HTMLInputElement.cpp:
     27        (WebCore::HTMLInputElement::setType):
     28        * html/HTMLInputElement.h:
     29        * html/HTMLInputElement.idl:
     30
    1312014-11-05  peavo@outlook.com  <peavo@outlook.com>
    232
  • trunk/Source/WebCore/html/FileInputType.cpp

    r171833 r175622  
    7272    : HTMLInputElement(inputTag, document, 0, false)
    7373{
    74     setType(ASCIILiteral("button"));
     74    setType(AtomicString("button", AtomicString::ConstructFromLiteral));
    7575    setPseudo(AtomicString("-webkit-file-upload-button", AtomicString::ConstructFromLiteral));
    7676}
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r175212 r175622  
    426426}
    427427
    428 void HTMLInputElement::setType(const String& type)
    429 {
    430     // FIXME: This should just call setAttribute. No reason to handle the empty string specially.
    431     // We should write a test case to show that setting to the empty string does not remove the
    432     // attribute in other browsers and then fix this. Note that setting to null *does* remove
    433     // the attribute and setAttribute implements that.
    434     if (type.isEmpty())
    435         removeAttribute(typeAttr);
    436     else
    437         setAttribute(typeAttr, type);
     428void HTMLInputElement::setType(const AtomicString& type)
     429{
     430    setAttribute(typeAttr, type);
    438431}
    439432
  • trunk/Source/WebCore/html/HTMLInputElement.h

    r175328 r175622  
    168168    float decorationWidth() const;
    169169
    170     void setType(const String&);
     170    void setType(const AtomicString&);
    171171
    172172    virtual String value() const override;
  • trunk/Source/WebCore/html/HTMLInputElement.idl

    r172259 r175622  
    5555    [Reflect, URL] attribute DOMString src;
    5656    [Reflect] attribute DOMString step;
    57     [TreatNullAs=NullString] attribute DOMString type; // readonly dropped as part of DOM level 2
     57    attribute DOMString type; // readonly dropped as part of DOM level 2
    5858    [TreatNullAs=NullString] attribute DOMString defaultValue;
    5959    // See the discussion in https://bugs.webkit.org/show_bug.cgi?id=100085
Note: See TracChangeset for help on using the changeset viewer.