Changeset 96484 in webkit


Ignore:
Timestamp:
Oct 2, 2011 11:59:23 PM (13 years ago)
Author:
tkent@chromium.org
Message:

method/enctype/formMethod/formEnctype properties should be limited to known values.
https://bugs.webkit.org/show_bug.cgi?id=68887

Reviewed by Hajime Morita.

Source/WebCore:

According to the standard and other browser behaviors, the
following IDL properties should be reflected to the corresponding
HTML attributes on setting, but should return normalized values on
getting.

  • HTMLFormElement::method
  • HTMLFormElement::enctype
  • HTMLInputElement::formMethod
  • HTMLInputElement::formEnctype
  • HTMLButtonElement::formMethod
  • HTMLButtonElement::formEnctype

Tests: fast/forms/enctype-attribute.html

fast/forms/method-attribute.html

  • html/HTMLButtonElement.idl:

Replace 'Reflect' with 'ConvertNullToNullString' in order to use a
getter function.

  • html/HTMLFormControlElement.cpp:

(WebCore::HTMLFormControlElement::formEnctype):
Normalizes the value by parseEncodingType().
(WebCore::HTMLFormControlElement::setFormEnctype):
Simply calls setAttribute()
(WebCore::HTMLFormControlElement::formMethod):
Normalizes the value by parseMethodType().
(WebCore::HTMLFormControlElement::setFormMethod):
Simply calls setAttribute()

  • html/HTMLFormControlElement.h:
  • html/HTMLFormElement.cpp:

(WebCore::HTMLFormElement::parseMappedAttribute):
Follow the Attributes function renaming.
(WebCore::HTMLFormElement::method):
Normalizes the value by parseMethodType().

  • html/HTMLFormElement.idl:

Replace 'Reflect' with 'ConvertNullToNullString' in order to use a
getter function.

  • html/HTMLInputElement.idl: ditto.
  • loader/FormSubmission.cpp:

(WebCore::FormSubmission::Attributes::parseEncodingType):
New function made from a part of old parseEncodingType().
(WebCore::FormSubmission::Attributes::updateEncodingType):
Renamed from parseEncodingType().
(WebCore::FormSubmission::Attributes::parseMethodType):
New function made from a part of old parseMethodType().
(WebCore::FormSubmission::Attributes::updateMethodType):
Renamed from parseMethodType().
(WebCore::FormSubmission::create):
Follow the Attributes function renaming.

  • loader/FormSubmission.h:

(WebCore::FormSubmission::Attributes::methodString):
A helper function to provide normalized strings for FormSubmission::Method.

LayoutTests:

  • fast/dom/element-attribute-js-null-expected.txt:
  • fast/dom/element-attribute-js-null.html: Correct an expectation for HTMLFormElement::method.
  • fast/forms/enctype-attribute-expected.txt: Added.
  • fast/forms/enctype-attribute.html: Added.
  • fast/forms/method-attribute-expected.txt: Added.
  • fast/forms/method-attribute.html: Added.
  • fast/forms/script-tests/submit-form-attributes.js: Correct expectations.
  • fast/forms/submit-form-attributes-expected.txt: ditto.
Location:
trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r96479 r96484  
     12011-10-02  Kent Tamura  <tkent@chromium.org>
     2
     3        method/enctype/formMethod/formEnctype properties should be limited to known values.
     4        https://bugs.webkit.org/show_bug.cgi?id=68887
     5
     6        Reviewed by Hajime Morita.
     7
     8        * fast/dom/element-attribute-js-null-expected.txt:
     9        * fast/dom/element-attribute-js-null.html: Correct an expectation for HTMLFormElement::method.
     10        * fast/forms/enctype-attribute-expected.txt: Added.
     11        * fast/forms/enctype-attribute.html: Added.
     12        * fast/forms/method-attribute-expected.txt: Added.
     13        * fast/forms/method-attribute.html: Added.
     14        * fast/forms/script-tests/submit-form-attributes.js: Correct expectations.
     15        * fast/forms/submit-form-attributes-expected.txt: ditto.
     16
    1172011-10-02  Gavin Barraclough  <barraclough@apple.com>
    218
  • trunk/LayoutTests/fast/dom/element-attribute-js-null-expected.txt

    r76301 r96484  
    8282TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLFormElement.encoding]
    8383TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLFormElement.enctype]
    84 TEST SUCCEEDED: The value was the empty string. [tested HTMLFormElement.method]
     84TEST SUCCEEDED: The value was the string 'get'. [tested HTMLFormElement.method]
    8585TEST SUCCEEDED: The value was the empty string. [tested HTMLFormElement.target]
    8686
  • trunk/LayoutTests/fast/dom/element-attribute-js-null.html

    r76301 r96484  
    233233                        {name: 'encoding', expectedNull: 'application/x-www-form-urlencoded'},
    234234                        {name: 'enctype', expectedNull: 'application/x-www-form-urlencoded'},
    235                         {name: 'method', expectedNull: ''},
     235                        {name: 'method', expectedNull: 'get'},
    236236                        {name: 'target', expectedNull: ''}
    237237                    ]
  • trunk/LayoutTests/fast/forms/script-tests/submit-form-attributes.js

    r72003 r96484  
    66input.type = "submit";
    77shouldBe('input.formAction', '""');
    8 shouldBe('input.formEnctype', '""');
    9 shouldBe('input.formMethod', '""');
     8shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
     9shouldBe('input.formMethod', '"get"');
    1010shouldBe('input.formTarget', '""');
    1111
     
    1717shouldBe('input.formEnctype', '"text/plain"');
    1818input.setAttribute('formEnctype', 'na');
    19 shouldBe('input.formEnctype', '"na"');
     19shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    2020input.setAttribute('formMethod', 'GET');
    21 shouldBe('input.formMethod', '"GET"');
     21shouldBe('input.formMethod', '"get"');
    2222input.setAttribute('formMethod', 'ni');
    23 shouldBe('input.formMethod', '"ni"');
     23shouldBe('input.formMethod', '"get"');
    2424input.setAttribute('formTarget', '_blank');
    2525shouldBe('input.formTarget', '"_blank"');
     
    3434shouldBe('input.formEnctype', '"text/plain"');
    3535input.formEnctype = 'nota';
    36 shouldBe('input.formEnctype', '"nota"');
     36shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    3737input.formMethod = 'POST';
    38 shouldBe('input.formMethod', '"POST"');
     38shouldBe('input.formMethod', '"post"');
    3939input.formMethod = 'neta';
    40 shouldBe('input.formMethod', '"neta"');
     40shouldBe('input.formMethod', '"get"');
    4141input.formTarget = 'http://example.com';
    4242shouldBe('input.formTarget', '"http://example.com"');
     
    4444shouldBe('input.formTarget', '"nta"');
    4545
     46debug('');
    4647debug('Setting null for input:');
    4748input.formEnctype = null;
    48 shouldBe('input.formEnctype', '""');
     49shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    4950shouldBe('input.getAttribute("formEnctype")', 'null');
    5051input.setAttribute('formEnctype', null);
    51 shouldBe('input.formEnctype', '"null"');
     52shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    5253input.formMethod = null;
    53 shouldBe('input.formMethod', '""');
     54shouldBe('input.formMethod', '"get"');
    5455shouldBe('input.getAttribute("formMethod")', 'null');
    5556input.setAttribute('formMethod', null);
    56 shouldBe('input.formMethod', '"null"');
     57shouldBe('input.formMethod', '"get"');
    5758input.formTarget = null;
    5859shouldBe('input.formTarget', '""');
     
    6162shouldBe('input.formTarget', '"null"');
    6263
     64debug('');
    6365debug('Setting undefined for input:');
    6466input.formEnctype = undefined;
    65 shouldBe('input.formEnctype', '"undefined"');
     67shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    6668shouldBe('input.getAttribute("formEnctype")', '"undefined"');
    6769input.setAttribute('formEnctype', undefined);
    68 shouldBe('input.formEnctype', '"undefined"');
     70shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    6971input.formMethod = undefined;
    70 shouldBe('input.formMethod', '"undefined"');
     72shouldBe('input.formMethod', '"get"');
    7173shouldBe('input.getAttribute("formMethod")', '"undefined"');
    7274input.setAttribute('formMethod', undefined);
    73 shouldBe('input.formMethod', '"undefined"');
     75shouldBe('input.formMethod', '"get"');
    7476input.formTarget = undefined;
    7577shouldBe('input.formTarget', '"undefined"');
     
    7880shouldBe('input.formTarget', '"undefined"');
    7981
     82debug('');
    8083debug('Setting non-string for input:');
    8184input.formEnctype = 256;
    82 shouldBe('input.formEnctype', '"256"');
     85shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    8386shouldBe('input.getAttribute("formEnctype")', '"256"');
    8487input.setAttribute('formEnctype', 256);
    85 shouldBe('input.formEnctype', '"256"');
     88shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
    8689input.formMethod = 256;
    87 shouldBe('input.formMethod', '"256"');
     90shouldBe('input.formMethod', '"get"');
    8891shouldBe('input.getAttribute("formMethod")', '"256"');
    8992input.setAttribute('formMethod', 256);
    90 shouldBe('input.formMethod', '"256"');
     93shouldBe('input.formMethod', '"get"');
    9194input.formTarget = 256;
    9295shouldBe('input.formTarget', '"256"');
     
    9699
    97100var button = document.createElement('button');
    98 
     101debug('');
    99102debug('Ordinary values for button:');
    100103button.type = "submit";
    101104shouldBe('button.formAction', '""');
    102 shouldBe('button.formEnctype', '""');
    103 shouldBe('button.formMethod', '""');
     105shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
     106shouldBe('button.formMethod', '"get"');
    104107shouldBe('button.formTarget', '""');
    105108
     
    111114shouldBe('button.formEnctype', '"text/plain"');
    112115button.setAttribute('formEnctype', 'na');
    113 shouldBe('button.formEnctype', '"na"');
     116shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    114117button.setAttribute('formMethod', 'GET');
    115 shouldBe('button.formMethod', '"GET"');
     118shouldBe('button.formMethod', '"get"');
    116119button.setAttribute('formMethod', 'na');
    117 shouldBe('button.formMethod', '"na"');
     120shouldBe('button.formMethod', '"get"');
    118121button.setAttribute('formTarget', '_blank');
    119122shouldBe('button.formTarget', '"_blank"');
     
    128131shouldBe('button.formEnctype', '"text/plain"');
    129132button.formEnctype = 'nota';
    130 shouldBe('button.formEnctype', '"nota"');
     133shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    131134button.formMethod = 'POST';
    132 shouldBe('button.formMethod', '"POST"');
     135shouldBe('button.formMethod', '"post"');
    133136button.formMethod = 'nota';
    134 shouldBe('button.formMethod', '"nota"');
     137shouldBe('button.formMethod', '"get"');
    135138button.formTarget = 'http://example.com';
    136139shouldBe('button.formTarget', '"http://example.com"');
     
    138141shouldBe('button.formTarget', '"nota"');
    139142
     143debug('');
    140144debug('Setting null for button:');
    141145button.formEnctype = null;
    142 shouldBe('button.formEnctype', '""');
     146shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    143147shouldBe('button.getAttribute("formEnctype")', 'null');
    144148button.setAttribute('formEnctype', null);
    145 shouldBe('button.formEnctype', '"null"');
     149shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    146150button.formMethod = null;
    147 shouldBe('button.formMethod', '""');
     151shouldBe('button.formMethod', '"get"');
    148152shouldBe('button.getAttribute("formMethod")', 'null');
    149153button.setAttribute('formMethod', null);
    150 shouldBe('button.formMethod', '"null"');
     154shouldBe('button.formMethod', '"get"');
    151155button.formTarget = null;
    152156shouldBe('button.formTarget', '""');
     
    155159shouldBe('button.formTarget', '"null"');
    156160
     161debug('');
    157162debug('Setting undefined for button:');
    158163button.formEnctype = undefined;
    159 shouldBe('button.formEnctype', '"undefined"');
     164shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    160165shouldBe('button.getAttribute("formEnctype")', '"undefined"');
    161166button.setAttribute('formEnctype', undefined);
    162 shouldBe('button.formEnctype', '"undefined"');
     167shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    163168button.formMethod = undefined;
    164 shouldBe('button.formMethod', '"undefined"');
     169shouldBe('button.formMethod', '"get"');
    165170shouldBe('button.getAttribute("formMethod")', '"undefined"');
    166171button.setAttribute('formMethod', undefined);
    167 shouldBe('button.formMethod', '"undefined"');
     172shouldBe('button.formMethod', '"get"');
    168173button.formTarget = undefined;
    169174shouldBe('button.formTarget', '"undefined"');
     
    172177shouldBe('button.formTarget', '"undefined"');
    173178
     179debug('');
    174180debug('Setting non-string for button:');
    175181button.formEnctype = 256;
    176 shouldBe('button.formEnctype', '"256"');
     182shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    177183shouldBe('button.getAttribute("formEnctype")', '"256"');
    178184button.setAttribute('formEnctype', 512);
    179 shouldBe('button.formEnctype', '"512"');
     185shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
    180186button.formMethod = 128;
    181 shouldBe('button.formMethod', '"128"');
     187shouldBe('button.formMethod', '"get"');
    182188shouldBe('button.getAttribute("formMethod")', '"128"');
    183189button.setAttribute('formMethod', 17);
    184 shouldBe('button.formMethod', '"17"');
     190shouldBe('button.formMethod', '"get"');
    185191button.formTarget = 100;
    186192shouldBe('button.formTarget', '"100"');
  • trunk/LayoutTests/fast/forms/submit-form-attributes-expected.txt

    r72003 r96484  
    66Ordinary values for input:
    77PASS input.formAction is ""
    8 PASS input.formEnctype is ""
    9 PASS input.formMethod is ""
     8PASS input.formEnctype is "application/x-www-form-urlencoded"
     9PASS input.formMethod is "get"
    1010PASS input.formTarget is ""
    1111PASS input.formAction is "http://localhost/"
    1212PASS input.formAction is "http://localhost/"
    1313PASS input.formEnctype is "text/plain"
    14 PASS input.formEnctype is "na"
    15 PASS input.formMethod is "GET"
    16 PASS input.formMethod is "ni"
     14PASS input.formEnctype is "application/x-www-form-urlencoded"
     15PASS input.formMethod is "get"
     16PASS input.formMethod is "get"
    1717PASS input.formTarget is "_blank"
    1818PASS input.formTarget is "nu"
     
    2020PASS input.formAction is "http://example.com/"
    2121PASS input.formEnctype is "text/plain"
    22 PASS input.formEnctype is "nota"
    23 PASS input.formMethod is "POST"
    24 PASS input.formMethod is "neta"
     22PASS input.formEnctype is "application/x-www-form-urlencoded"
     23PASS input.formMethod is "post"
     24PASS input.formMethod is "get"
    2525PASS input.formTarget is "http://example.com"
    2626PASS input.formTarget is "nta"
     27
    2728Setting null for input:
    28 PASS input.formEnctype is ""
     29PASS input.formEnctype is "application/x-www-form-urlencoded"
    2930PASS input.getAttribute("formEnctype") is null
    30 PASS input.formEnctype is "null"
    31 PASS input.formMethod is ""
     31PASS input.formEnctype is "application/x-www-form-urlencoded"
     32PASS input.formMethod is "get"
    3233PASS input.getAttribute("formMethod") is null
    33 PASS input.formMethod is "null"
     34PASS input.formMethod is "get"
    3435PASS input.formTarget is ""
    3536PASS input.getAttribute("formTarget") is null
    3637PASS input.formTarget is "null"
     38
    3739Setting undefined for input:
    38 PASS input.formEnctype is "undefined"
     40PASS input.formEnctype is "application/x-www-form-urlencoded"
    3941PASS input.getAttribute("formEnctype") is "undefined"
    40 PASS input.formEnctype is "undefined"
    41 PASS input.formMethod is "undefined"
     42PASS input.formEnctype is "application/x-www-form-urlencoded"
     43PASS input.formMethod is "get"
    4244PASS input.getAttribute("formMethod") is "undefined"
    43 PASS input.formMethod is "undefined"
     45PASS input.formMethod is "get"
    4446PASS input.formTarget is "undefined"
    4547PASS input.getAttribute("formTarget") is "undefined"
    4648PASS input.formTarget is "undefined"
     49
    4750Setting non-string for input:
    48 PASS input.formEnctype is "256"
     51PASS input.formEnctype is "application/x-www-form-urlencoded"
    4952PASS input.getAttribute("formEnctype") is "256"
    50 PASS input.formEnctype is "256"
    51 PASS input.formMethod is "256"
     53PASS input.formEnctype is "application/x-www-form-urlencoded"
     54PASS input.formMethod is "get"
    5255PASS input.getAttribute("formMethod") is "256"
    53 PASS input.formMethod is "256"
     56PASS input.formMethod is "get"
    5457PASS input.formTarget is "256"
    5558PASS input.getAttribute("formTarget") is "256"
    5659PASS input.formTarget is "256"
     60
    5761Ordinary values for button:
    5862PASS button.formAction is ""
    59 PASS button.formEnctype is ""
    60 PASS button.formMethod is ""
     63PASS button.formEnctype is "application/x-www-form-urlencoded"
     64PASS button.formMethod is "get"
    6165PASS button.formTarget is ""
    6266PASS button.formAction is "http://localhost/"
    6367PASS button.formAction is "http://localhost/"
    6468PASS button.formEnctype is "text/plain"
    65 PASS button.formEnctype is "na"
    66 PASS button.formMethod is "GET"
    67 PASS button.formMethod is "na"
     69PASS button.formEnctype is "application/x-www-form-urlencoded"
     70PASS button.formMethod is "get"
     71PASS button.formMethod is "get"
    6872PASS button.formTarget is "_blank"
    6973PASS button.formTarget is "na"
     
    7175PASS button.formAction is "http://example.com/"
    7276PASS button.formEnctype is "text/plain"
    73 PASS button.formEnctype is "nota"
    74 PASS button.formMethod is "POST"
    75 PASS button.formMethod is "nota"
     77PASS button.formEnctype is "application/x-www-form-urlencoded"
     78PASS button.formMethod is "post"
     79PASS button.formMethod is "get"
    7680PASS button.formTarget is "http://example.com"
    7781PASS button.formTarget is "nota"
     82
    7883Setting null for button:
    79 PASS button.formEnctype is ""
     84PASS button.formEnctype is "application/x-www-form-urlencoded"
    8085PASS button.getAttribute("formEnctype") is null
    81 PASS button.formEnctype is "null"
    82 PASS button.formMethod is ""
     86PASS button.formEnctype is "application/x-www-form-urlencoded"
     87PASS button.formMethod is "get"
    8388PASS button.getAttribute("formMethod") is null
    84 PASS button.formMethod is "null"
     89PASS button.formMethod is "get"
    8590PASS button.formTarget is ""
    8691PASS button.getAttribute("formTarget") is null
    8792PASS button.formTarget is "null"
     93
    8894Setting undefined for button:
    89 PASS button.formEnctype is "undefined"
     95PASS button.formEnctype is "application/x-www-form-urlencoded"
    9096PASS button.getAttribute("formEnctype") is "undefined"
    91 PASS button.formEnctype is "undefined"
    92 PASS button.formMethod is "undefined"
     97PASS button.formEnctype is "application/x-www-form-urlencoded"
     98PASS button.formMethod is "get"
    9399PASS button.getAttribute("formMethod") is "undefined"
    94 PASS button.formMethod is "undefined"
     100PASS button.formMethod is "get"
    95101PASS button.formTarget is "undefined"
    96102PASS button.getAttribute("formTarget") is "undefined"
    97103PASS button.formTarget is "undefined"
     104
    98105Setting non-string for button:
    99 PASS button.formEnctype is "256"
     106PASS button.formEnctype is "application/x-www-form-urlencoded"
    100107PASS button.getAttribute("formEnctype") is "256"
    101 PASS button.formEnctype is "512"
    102 PASS button.formMethod is "128"
     108PASS button.formEnctype is "application/x-www-form-urlencoded"
     109PASS button.formMethod is "get"
    103110PASS button.getAttribute("formMethod") is "128"
    104 PASS button.formMethod is "17"
     111PASS button.formMethod is "get"
    105112PASS button.formTarget is "100"
    106113PASS button.getAttribute("formTarget") is "100"
  • trunk/Source/WebCore/ChangeLog

    r96480 r96484  
     12011-10-02  Kent Tamura  <tkent@chromium.org>
     2
     3        method/enctype/formMethod/formEnctype properties should be limited to known values.
     4        https://bugs.webkit.org/show_bug.cgi?id=68887
     5
     6        Reviewed by Hajime Morita.
     7
     8        According to the standard and other browser behaviors, the
     9        following IDL properties should be reflected to the corresponding
     10        HTML attributes on setting, but should return normalized values on
     11        getting.
     12        - HTMLFormElement::method
     13        - HTMLFormElement::enctype
     14        - HTMLInputElement::formMethod
     15        - HTMLInputElement::formEnctype
     16        - HTMLButtonElement::formMethod
     17        - HTMLButtonElement::formEnctype
     18
     19        Tests: fast/forms/enctype-attribute.html
     20               fast/forms/method-attribute.html
     21
     22        * html/HTMLButtonElement.idl:
     23        Replace 'Reflect' with 'ConvertNullToNullString' in order to use a
     24        getter function.
     25        * html/HTMLFormControlElement.cpp:
     26        (WebCore::HTMLFormControlElement::formEnctype):
     27        Normalizes the value by parseEncodingType().
     28        (WebCore::HTMLFormControlElement::setFormEnctype):
     29        Simply calls setAttribute()
     30        (WebCore::HTMLFormControlElement::formMethod):
     31        Normalizes the value by parseMethodType().
     32        (WebCore::HTMLFormControlElement::setFormMethod):
     33        Simply calls setAttribute()
     34        * html/HTMLFormControlElement.h:
     35        * html/HTMLFormElement.cpp:
     36        (WebCore::HTMLFormElement::parseMappedAttribute):
     37        Follow the Attributes function renaming.
     38        (WebCore::HTMLFormElement::method):
     39        Normalizes the value by parseMethodType().
     40        * html/HTMLFormElement.idl:
     41        Replace 'Reflect' with 'ConvertNullToNullString' in order to use a
     42        getter function.
     43        * html/HTMLInputElement.idl: ditto.
     44        * loader/FormSubmission.cpp:
     45        (WebCore::FormSubmission::Attributes::parseEncodingType):
     46        New function made from a part of old parseEncodingType().
     47        (WebCore::FormSubmission::Attributes::updateEncodingType):
     48        Renamed from parseEncodingType().
     49        (WebCore::FormSubmission::Attributes::parseMethodType):
     50        New function made from a part of old parseMethodType().
     51        (WebCore::FormSubmission::Attributes::updateMethodType):
     52        Renamed from parseMethodType().
     53        (WebCore::FormSubmission::create):
     54        Follow the Attributes function renaming.
     55        * loader/FormSubmission.h:
     56        (WebCore::FormSubmission::Attributes::methodString):
     57        A helper function to provide normalized strings for FormSubmission::Method.
     58
    1592011-10-02  Sam Weinig  <sam@webkit.org>
    260
  • trunk/Source/WebCore/html/HTMLButtonElement.idl

    r92327 r96484  
    2525
    2626        attribute [Reflect, URL] DOMString formAction;
    27         attribute [Reflect] DOMString formEnctype;
    28         attribute [Reflect] DOMString formMethod;
     27        attribute [ConvertNullToNullString] DOMString formEnctype;
     28        attribute [ConvertNullToNullString] DOMString formMethod;
    2929        attribute [Reflect] boolean formNoValidate;
    3030        attribute [Reflect] DOMString formTarget;
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r96134 r96484  
    8080    m_validationMessage = nullptr;
    8181    HTMLElement::detach();
     82}
     83
     84String HTMLFormControlElement::formEnctype() const
     85{
     86    return FormSubmission::Attributes::parseEncodingType(fastGetAttribute(formenctypeAttr));
     87}
     88
     89void HTMLFormControlElement::setFormEnctype(const String& value)
     90{
     91    setAttribute(formenctypeAttr, value);
     92}
     93
     94String HTMLFormControlElement::formMethod() const
     95{
     96    return FormSubmission::Attributes::methodString(FormSubmission::Attributes::parseMethodType(fastGetAttribute(formmethodAttr)));
     97}
     98
     99void HTMLFormControlElement::setFormMethod(const String& value)
     100{
     101    setAttribute(formmethodAttr, value);
    82102}
    83103
  • trunk/Source/WebCore/html/HTMLFormControlElement.h

    r96078 r96484  
    4444    HTMLFormElement* form() const { return FormAssociatedElement::form(); }
    4545
     46    String formEnctype() const;
     47    void setFormEnctype(const String&);
     48    String formMethod() const;
     49    void setFormMethod(const String&);
    4650    bool formNoValidate() const;
    4751
  • trunk/Source/WebCore/html/HTMLFormElement.cpp

    r94427 r96484  
    371371        m_attributes.setTarget(attr->value());
    372372    else if (attr->name() == methodAttr)
    373         m_attributes.parseMethodType(attr->value());
     373        m_attributes.updateMethodType(attr->value());
    374374    else if (attr->name() == enctypeAttr)
    375         m_attributes.parseEncodingType(attr->value());
     375        m_attributes.updateEncodingType(attr->value());
    376376    else if (attr->name() == accept_charsetAttr)
    377377        m_attributes.setAcceptCharset(attr->value());
     
    548548String HTMLFormElement::method() const
    549549{
    550     return getAttribute(methodAttr);
     550    return FormSubmission::Attributes::methodString(m_attributes.method());
    551551}
    552552
  • trunk/Source/WebCore/html/HTMLFormElement.idl

    r89991 r96484  
    3434        attribute [ConvertNullToNullString] DOMString encoding;
    3535        attribute [ConvertNullToNullString] DOMString enctype;
    36         attribute [Reflect] DOMString method;
     36        attribute [ConvertNullToNullString] DOMString method;
    3737        attribute [Reflect] DOMString target;
    3838        attribute [Reflect] DOMString autocomplete;
  • trunk/Source/WebCore/html/HTMLInputElement.idl

    r92327 r96484  
    2626        readonly attribute HTMLFormElement form;
    2727        attribute [Reflect, URL] DOMString formAction;
    28         attribute [Reflect] DOMString formEnctype;
    29         attribute [Reflect] DOMString formMethod;
     28        attribute [ConvertNullToNullString] DOMString formEnctype;
     29        attribute [ConvertNullToNullString] DOMString formMethod;
    3030        attribute [Reflect] boolean formNoValidate;
    3131        attribute [Reflect] DOMString formTarget;
  • trunk/Source/WebCore/loader/FormSubmission.cpp

    r95901 r96484  
    8989}
    9090
    91 void FormSubmission::Attributes::parseEncodingType(const String& type)
    92 {
    93     if (type.contains("multipart", false) || type.contains("form-data", false)) {
    94         m_encodingType = "multipart/form-data";
    95         m_isMultiPartForm = true;
    96     } else if (type.contains("text", false) || type.contains("plain", false)) {
    97         m_encodingType = "text/plain";
    98         m_isMultiPartForm = false;
    99     } else {
    100         m_encodingType = "application/x-www-form-urlencoded";
    101         m_isMultiPartForm = false;
    102     }
    103 }
    104 
    105 void FormSubmission::Attributes::parseMethodType(const String& type)
    106 {
    107     if (equalIgnoringCase(type, "post"))
    108         m_method = FormSubmission::PostMethod;
    109     else if (equalIgnoringCase(type, "get"))
    110         m_method = FormSubmission::GetMethod;
     91String FormSubmission::Attributes::parseEncodingType(const String& type)
     92{
     93    if (type.contains("multipart", false) || type.contains("form-data", false))
     94        return "multipart/form-data";
     95    if (type.contains("text", false) || type.contains("plain", false))
     96        return "text/plain";
     97    return "application/x-www-form-urlencoded";
     98}
     99
     100void FormSubmission::Attributes::updateEncodingType(const String& type)
     101{
     102    m_encodingType = parseEncodingType(type);
     103    m_isMultiPartForm = (m_encodingType == "multipart/form-data");
     104}
     105
     106FormSubmission::Method FormSubmission::Attributes::parseMethodType(const String& type)
     107{
     108    return equalIgnoringCase(type, "post") ? FormSubmission::PostMethod : FormSubmission::GetMethod;
     109}
     110
     111void FormSubmission::Attributes::updateMethodType(const String& type)
     112{
     113    m_method = parseMethodType(type);
    111114}
    112115
     
    150153            copiedAttributes.parseAction(attributeValue);
    151154        if (!(attributeValue = submitButton->getAttribute(formenctypeAttr)).isNull())
    152             copiedAttributes.parseEncodingType(attributeValue);
     155            copiedAttributes.updateEncodingType(attributeValue);
    153156        if (!(attributeValue = submitButton->getAttribute(formmethodAttr)).isNull())
    154             copiedAttributes.parseMethodType(attributeValue);
     157            copiedAttributes.updateMethodType(attributeValue);
    155158        if (!(attributeValue = submitButton->getAttribute(formtargetAttr)).isNull())
    156159            copiedAttributes.setTarget(attributeValue);
  • trunk/Source/WebCore/loader/FormSubmission.h

    r95901 r96484  
    5959
    6060        Method method() const { return m_method; }
    61         void parseMethodType(const String&);
     61        static Method parseMethodType(const String&);
     62        void updateMethodType(const String&);
     63        static String methodString(Method method) { return method == PostMethod ? "post" : "get"; }
    6264
    6365        const String& action() const { return m_action; }
     
    6870
    6971        const String& encodingType() const { return m_encodingType; }
    70         void parseEncodingType(const String&);
     72        static String parseEncodingType(const String&);
     73        void updateEncodingType(const String&);
    7174        bool isMultiPartForm() const { return m_isMultiPartForm; }
    7275
Note: See TracChangeset for help on using the changeset viewer.