+2011-10-02 Kent Tamura <tkent@chromium.org>
+
+ method/enctype/formMethod/formEnctype properties should be limited to known values.
+ https://bugs.webkit.org/show_bug.cgi?id=68887
+
+ Reviewed by Hajime Morita.
+
+ * 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.
+
2011-10-02 Gavin Barraclough <barraclough@apple.com>
Bug 67455 - Different regular expression result
TEST SUCCEEDED: The value was the empty string. [tested HTMLFormElement.action]
TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLFormElement.encoding]
TEST SUCCEEDED: The value was the string 'application/x-www-form-urlencoded'. [tested HTMLFormElement.enctype]
-TEST SUCCEEDED: The value was the empty string. [tested HTMLFormElement.method]
+TEST SUCCEEDED: The value was the string 'get'. [tested HTMLFormElement.method]
TEST SUCCEEDED: The value was the empty string. [tested HTMLFormElement.target]
TEST SUCCEEDED: The value was the empty string. [tested HTMLFrameElement.frameBorder]
{name: 'action', expectedNull: ''},
{name: 'encoding', expectedNull: 'application/x-www-form-urlencoded'},
{name: 'enctype', expectedNull: 'application/x-www-form-urlencoded'},
- {name: 'method', expectedNull: ''},
+ {name: 'method', expectedNull: 'get'},
{name: 'target', expectedNull: ''}
]
},
--- /dev/null
+Test enctype and formenctype attributes
+
+Missing value default:
+PASS form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.getAttribute("enctype") is null
+
+Invalid value default:
+PASS form1.enctype = "foobar"; form1.enctype is "application/x-www-form-urlencoded"
+PASS form1.getAttribute("enctype") is "foobar"
+PASS form1.setAttribute("enctype", "baz"); form1.enctype is "application/x-www-form-urlencoded"
+
+Valid values:
+PASS form1.enctype = "Text/Plain"; form1.enctype is "text/plain"
+PASS form1.getAttribute("enctype") is "Text/Plain"
+PASS form1.setAttribute("enctype", "Text/Plain"); form1.enctype is "text/plain"
+
+Valid values with whitespace:
+PASS form1.enctype = " multipart/form-data"; form1.enctype is "multipart/form-data"
+PASS form1.getAttribute("enctype") is " multipart/form-data"
+PASS form1.enctype = "application/x-www-form-urlencoded "; form1.enctype is "application/x-www-form-urlencoded"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<link rel=stylesheet href="../js/resources/js-test-style.css">
+<body>
+<script src="../js/resources/js-test-pre.js"></script>
+
+<p>Test enctype and formenctype attributes</p>
+
+<form id=f1></form>
+
+<div id=console></div>
+<script>
+var form1 = document.getElementById('f1');
+
+debug('Missing value default:');
+shouldBe('form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBeNull('form1.getAttribute("enctype")');
+
+debug('');
+debug('Invalid value default:');
+shouldBe('form1.enctype = "foobar"; form1.enctype', '"application/x-www-form-urlencoded"');
+shouldBe('form1.getAttribute("enctype")', '"foobar"');
+shouldBe('form1.setAttribute("enctype", "baz"); form1.enctype', '"application/x-www-form-urlencoded"');
+
+debug('');
+debug('Valid values:');
+shouldBe('form1.enctype = "Text/Plain"; form1.enctype', '"text/plain"');
+shouldBe('form1.getAttribute("enctype")', '"Text/Plain"');
+shouldBe('form1.setAttribute("enctype", "Text/Plain"); form1.enctype', '"text/plain"');
+
+debug('');
+debug('Valid values with whitespace:');
+// Note: IE9 thorws "Invalid argument.", Firefox 6 doesn't allow leading whitespace.
+// Firefox matches to the specification.
+shouldBe('form1.enctype = " multipart/form-data"; form1.enctype', '"multipart/form-data"');
+shouldBe('form1.getAttribute("enctype")', '" multipart/form-data"');
+
+shouldBe('form1.enctype = "application/x-www-form-urlencoded "; form1.enctype', '"application/x-www-form-urlencoded"');
+
+debug('');
+var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
--- /dev/null
+Test method and formmethod attributes
+
+Missing value default:
+PASS form1.method is "get"
+PASS form1.getAttribute("method") is null
+
+Invalid value default:
+PASS form1.method = " post "; form1.method is "get"
+PASS form1.getAttribute("method") is " post "
+PASS form1.setAttribute("method", "put"); form1.method is "get"
+
+Valid values:
+PASS form1.method = "Post"; form1.method is "post"
+PASS form1.getAttribute("method") is "Post"
+PASS form1.method = "Get"; form1.method is "get"
+PASS form1.getAttribute("method") is "Get"
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<link rel=stylesheet href="../js/resources/js-test-style.css">
+<body>
+<script src="../js/resources/js-test-pre.js"></script>
+
+<p>Test method and formmethod attributes</p>
+
+<form id=f1></form>
+
+<div id=console></div>
+<script>
+var form1 = document.getElementById('f1');
+
+debug('Missing value default:');
+shouldBe('form1.method', '"get"');
+shouldBeNull('form1.getAttribute("method")');
+
+debug('');
+debug('Invalid value default:');
+shouldBe('form1.method = " post "; form1.method', '"get"');
+shouldBe('form1.getAttribute("method")', '" post "');
+shouldBe('form1.setAttribute("method", "put"); form1.method', '"get"');
+
+debug('');
+debug('Valid values:');
+shouldBe('form1.method = "Post"; form1.method', '"post"');
+shouldBe('form1.getAttribute("method")', '"Post"');
+
+shouldBe('form1.method = "Get"; form1.method', '"get"');
+shouldBe('form1.getAttribute("method")', '"Get"');
+
+debug('');
+var successfullyParsed = true;
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
debug('Ordinary values for input:');
input.type = "submit";
shouldBe('input.formAction', '""');
-shouldBe('input.formEnctype', '""');
-shouldBe('input.formMethod', '""');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
+shouldBe('input.formMethod', '"get"');
shouldBe('input.formTarget', '""');
input.setAttribute('formAction', 'http://localhost');
input.setAttribute('formEnctype', 'text/plain');
shouldBe('input.formEnctype', '"text/plain"');
input.setAttribute('formEnctype', 'na');
-shouldBe('input.formEnctype', '"na"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
input.setAttribute('formMethod', 'GET');
-shouldBe('input.formMethod', '"GET"');
+shouldBe('input.formMethod', '"get"');
input.setAttribute('formMethod', 'ni');
-shouldBe('input.formMethod', '"ni"');
+shouldBe('input.formMethod', '"get"');
input.setAttribute('formTarget', '_blank');
shouldBe('input.formTarget', '"_blank"');
input.setAttribute('formTarget', 'nu');
input.formEnctype = 'text/plain';
shouldBe('input.formEnctype', '"text/plain"');
input.formEnctype = 'nota';
-shouldBe('input.formEnctype', '"nota"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
input.formMethod = 'POST';
-shouldBe('input.formMethod', '"POST"');
+shouldBe('input.formMethod', '"post"');
input.formMethod = 'neta';
-shouldBe('input.formMethod', '"neta"');
+shouldBe('input.formMethod', '"get"');
input.formTarget = 'http://example.com';
shouldBe('input.formTarget', '"http://example.com"');
input.formTarget = 'nta';
shouldBe('input.formTarget', '"nta"');
+debug('');
debug('Setting null for input:');
input.formEnctype = null;
-shouldBe('input.formEnctype', '""');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
shouldBe('input.getAttribute("formEnctype")', 'null');
input.setAttribute('formEnctype', null);
-shouldBe('input.formEnctype', '"null"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
input.formMethod = null;
-shouldBe('input.formMethod', '""');
+shouldBe('input.formMethod', '"get"');
shouldBe('input.getAttribute("formMethod")', 'null');
input.setAttribute('formMethod', null);
-shouldBe('input.formMethod', '"null"');
+shouldBe('input.formMethod', '"get"');
input.formTarget = null;
shouldBe('input.formTarget', '""');
shouldBe('input.getAttribute("formTarget")', 'null');
input.setAttribute('formTarget', null);
shouldBe('input.formTarget', '"null"');
+debug('');
debug('Setting undefined for input:');
input.formEnctype = undefined;
-shouldBe('input.formEnctype', '"undefined"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
shouldBe('input.getAttribute("formEnctype")', '"undefined"');
input.setAttribute('formEnctype', undefined);
-shouldBe('input.formEnctype', '"undefined"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
input.formMethod = undefined;
-shouldBe('input.formMethod', '"undefined"');
+shouldBe('input.formMethod', '"get"');
shouldBe('input.getAttribute("formMethod")', '"undefined"');
input.setAttribute('formMethod', undefined);
-shouldBe('input.formMethod', '"undefined"');
+shouldBe('input.formMethod', '"get"');
input.formTarget = undefined;
shouldBe('input.formTarget', '"undefined"');
shouldBe('input.getAttribute("formTarget")', '"undefined"');
input.setAttribute('formTarget', undefined);
shouldBe('input.formTarget', '"undefined"');
+debug('');
debug('Setting non-string for input:');
input.formEnctype = 256;
-shouldBe('input.formEnctype', '"256"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
shouldBe('input.getAttribute("formEnctype")', '"256"');
input.setAttribute('formEnctype', 256);
-shouldBe('input.formEnctype', '"256"');
+shouldBe('input.formEnctype', '"application/x-www-form-urlencoded"');
input.formMethod = 256;
-shouldBe('input.formMethod', '"256"');
+shouldBe('input.formMethod', '"get"');
shouldBe('input.getAttribute("formMethod")', '"256"');
input.setAttribute('formMethod', 256);
-shouldBe('input.formMethod', '"256"');
+shouldBe('input.formMethod', '"get"');
input.formTarget = 256;
shouldBe('input.formTarget', '"256"');
shouldBe('input.getAttribute("formTarget")', '"256"');
shouldBe('input.formTarget', '"256"');
var button = document.createElement('button');
-
+debug('');
debug('Ordinary values for button:');
button.type = "submit";
shouldBe('button.formAction', '""');
-shouldBe('button.formEnctype', '""');
-shouldBe('button.formMethod', '""');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
+shouldBe('button.formMethod', '"get"');
shouldBe('button.formTarget', '""');
button.setAttribute('formAction', 'http://localhost');
button.setAttribute('formEnctype', 'text/plain');
shouldBe('button.formEnctype', '"text/plain"');
button.setAttribute('formEnctype', 'na');
-shouldBe('button.formEnctype', '"na"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
button.setAttribute('formMethod', 'GET');
-shouldBe('button.formMethod', '"GET"');
+shouldBe('button.formMethod', '"get"');
button.setAttribute('formMethod', 'na');
-shouldBe('button.formMethod', '"na"');
+shouldBe('button.formMethod', '"get"');
button.setAttribute('formTarget', '_blank');
shouldBe('button.formTarget', '"_blank"');
button.setAttribute('formTarget', 'na');
button.formEnctype = 'text/plain';
shouldBe('button.formEnctype', '"text/plain"');
button.formEnctype = 'nota';
-shouldBe('button.formEnctype', '"nota"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
button.formMethod = 'POST';
-shouldBe('button.formMethod', '"POST"');
+shouldBe('button.formMethod', '"post"');
button.formMethod = 'nota';
-shouldBe('button.formMethod', '"nota"');
+shouldBe('button.formMethod', '"get"');
button.formTarget = 'http://example.com';
shouldBe('button.formTarget', '"http://example.com"');
button.formTarget = 'nota';
shouldBe('button.formTarget', '"nota"');
+debug('');
debug('Setting null for button:');
button.formEnctype = null;
-shouldBe('button.formEnctype', '""');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
shouldBe('button.getAttribute("formEnctype")', 'null');
button.setAttribute('formEnctype', null);
-shouldBe('button.formEnctype', '"null"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
button.formMethod = null;
-shouldBe('button.formMethod', '""');
+shouldBe('button.formMethod', '"get"');
shouldBe('button.getAttribute("formMethod")', 'null');
button.setAttribute('formMethod', null);
-shouldBe('button.formMethod', '"null"');
+shouldBe('button.formMethod', '"get"');
button.formTarget = null;
shouldBe('button.formTarget', '""');
shouldBe('button.getAttribute("formTarget")', 'null');
button.setAttribute('formTarget', null);
shouldBe('button.formTarget', '"null"');
+debug('');
debug('Setting undefined for button:');
button.formEnctype = undefined;
-shouldBe('button.formEnctype', '"undefined"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
shouldBe('button.getAttribute("formEnctype")', '"undefined"');
button.setAttribute('formEnctype', undefined);
-shouldBe('button.formEnctype', '"undefined"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
button.formMethod = undefined;
-shouldBe('button.formMethod', '"undefined"');
+shouldBe('button.formMethod', '"get"');
shouldBe('button.getAttribute("formMethod")', '"undefined"');
button.setAttribute('formMethod', undefined);
-shouldBe('button.formMethod', '"undefined"');
+shouldBe('button.formMethod', '"get"');
button.formTarget = undefined;
shouldBe('button.formTarget', '"undefined"');
shouldBe('button.getAttribute("formTarget")', '"undefined"');
button.setAttribute('formTarget', undefined);
shouldBe('button.formTarget', '"undefined"');
+debug('');
debug('Setting non-string for button:');
button.formEnctype = 256;
-shouldBe('button.formEnctype', '"256"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
shouldBe('button.getAttribute("formEnctype")', '"256"');
button.setAttribute('formEnctype', 512);
-shouldBe('button.formEnctype', '"512"');
+shouldBe('button.formEnctype', '"application/x-www-form-urlencoded"');
button.formMethod = 128;
-shouldBe('button.formMethod', '"128"');
+shouldBe('button.formMethod', '"get"');
shouldBe('button.getAttribute("formMethod")', '"128"');
button.setAttribute('formMethod', 17);
-shouldBe('button.formMethod', '"17"');
+shouldBe('button.formMethod', '"get"');
button.formTarget = 100;
shouldBe('button.formTarget', '"100"');
shouldBe('button.getAttribute("formTarget")', '"100"');
Ordinary values for input:
PASS input.formAction is ""
-PASS input.formEnctype is ""
-PASS input.formMethod is ""
+PASS input.formEnctype is "application/x-www-form-urlencoded"
+PASS input.formMethod is "get"
PASS input.formTarget is ""
PASS input.formAction is "http://localhost/"
PASS input.formAction is "http://localhost/"
PASS input.formEnctype is "text/plain"
-PASS input.formEnctype is "na"
-PASS input.formMethod is "GET"
-PASS input.formMethod is "ni"
+PASS input.formEnctype is "application/x-www-form-urlencoded"
+PASS input.formMethod is "get"
+PASS input.formMethod is "get"
PASS input.formTarget is "_blank"
PASS input.formTarget is "nu"
PASS input.formAction is "http://example.com/"
PASS input.formAction is "http://example.com/"
PASS input.formEnctype is "text/plain"
-PASS input.formEnctype is "nota"
-PASS input.formMethod is "POST"
-PASS input.formMethod is "neta"
+PASS input.formEnctype is "application/x-www-form-urlencoded"
+PASS input.formMethod is "post"
+PASS input.formMethod is "get"
PASS input.formTarget is "http://example.com"
PASS input.formTarget is "nta"
+
Setting null for input:
-PASS input.formEnctype is ""
+PASS input.formEnctype is "application/x-www-form-urlencoded"
PASS input.getAttribute("formEnctype") is null
-PASS input.formEnctype is "null"
-PASS input.formMethod is ""
+PASS input.formEnctype is "application/x-www-form-urlencoded"
+PASS input.formMethod is "get"
PASS input.getAttribute("formMethod") is null
-PASS input.formMethod is "null"
+PASS input.formMethod is "get"
PASS input.formTarget is ""
PASS input.getAttribute("formTarget") is null
PASS input.formTarget is "null"
+
Setting undefined for input:
-PASS input.formEnctype is "undefined"
+PASS input.formEnctype is "application/x-www-form-urlencoded"
PASS input.getAttribute("formEnctype") is "undefined"
-PASS input.formEnctype is "undefined"
-PASS input.formMethod is "undefined"
+PASS input.formEnctype is "application/x-www-form-urlencoded"
+PASS input.formMethod is "get"
PASS input.getAttribute("formMethod") is "undefined"
-PASS input.formMethod is "undefined"
+PASS input.formMethod is "get"
PASS input.formTarget is "undefined"
PASS input.getAttribute("formTarget") is "undefined"
PASS input.formTarget is "undefined"
+
Setting non-string for input:
-PASS input.formEnctype is "256"
+PASS input.formEnctype is "application/x-www-form-urlencoded"
PASS input.getAttribute("formEnctype") is "256"
-PASS input.formEnctype is "256"
-PASS input.formMethod is "256"
+PASS input.formEnctype is "application/x-www-form-urlencoded"
+PASS input.formMethod is "get"
PASS input.getAttribute("formMethod") is "256"
-PASS input.formMethod is "256"
+PASS input.formMethod is "get"
PASS input.formTarget is "256"
PASS input.getAttribute("formTarget") is "256"
PASS input.formTarget is "256"
+
Ordinary values for button:
PASS button.formAction is ""
-PASS button.formEnctype is ""
-PASS button.formMethod is ""
+PASS button.formEnctype is "application/x-www-form-urlencoded"
+PASS button.formMethod is "get"
PASS button.formTarget is ""
PASS button.formAction is "http://localhost/"
PASS button.formAction is "http://localhost/"
PASS button.formEnctype is "text/plain"
-PASS button.formEnctype is "na"
-PASS button.formMethod is "GET"
-PASS button.formMethod is "na"
+PASS button.formEnctype is "application/x-www-form-urlencoded"
+PASS button.formMethod is "get"
+PASS button.formMethod is "get"
PASS button.formTarget is "_blank"
PASS button.formTarget is "na"
PASS button.formAction is "http://example.com/"
PASS button.formAction is "http://example.com/"
PASS button.formEnctype is "text/plain"
-PASS button.formEnctype is "nota"
-PASS button.formMethod is "POST"
-PASS button.formMethod is "nota"
+PASS button.formEnctype is "application/x-www-form-urlencoded"
+PASS button.formMethod is "post"
+PASS button.formMethod is "get"
PASS button.formTarget is "http://example.com"
PASS button.formTarget is "nota"
+
Setting null for button:
-PASS button.formEnctype is ""
+PASS button.formEnctype is "application/x-www-form-urlencoded"
PASS button.getAttribute("formEnctype") is null
-PASS button.formEnctype is "null"
-PASS button.formMethod is ""
+PASS button.formEnctype is "application/x-www-form-urlencoded"
+PASS button.formMethod is "get"
PASS button.getAttribute("formMethod") is null
-PASS button.formMethod is "null"
+PASS button.formMethod is "get"
PASS button.formTarget is ""
PASS button.getAttribute("formTarget") is null
PASS button.formTarget is "null"
+
Setting undefined for button:
-PASS button.formEnctype is "undefined"
+PASS button.formEnctype is "application/x-www-form-urlencoded"
PASS button.getAttribute("formEnctype") is "undefined"
-PASS button.formEnctype is "undefined"
-PASS button.formMethod is "undefined"
+PASS button.formEnctype is "application/x-www-form-urlencoded"
+PASS button.formMethod is "get"
PASS button.getAttribute("formMethod") is "undefined"
-PASS button.formMethod is "undefined"
+PASS button.formMethod is "get"
PASS button.formTarget is "undefined"
PASS button.getAttribute("formTarget") is "undefined"
PASS button.formTarget is "undefined"
+
Setting non-string for button:
-PASS button.formEnctype is "256"
+PASS button.formEnctype is "application/x-www-form-urlencoded"
PASS button.getAttribute("formEnctype") is "256"
-PASS button.formEnctype is "512"
-PASS button.formMethod is "128"
+PASS button.formEnctype is "application/x-www-form-urlencoded"
+PASS button.formMethod is "get"
PASS button.getAttribute("formMethod") is "128"
-PASS button.formMethod is "17"
+PASS button.formMethod is "get"
PASS button.formTarget is "100"
PASS button.getAttribute("formTarget") is "100"
PASS button.formTarget is "281"
+2011-10-02 Kent Tamura <tkent@chromium.org>
+
+ method/enctype/formMethod/formEnctype properties should be limited to known values.
+ https://bugs.webkit.org/show_bug.cgi?id=68887
+
+ Reviewed by Hajime Morita.
+
+ 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.
+
2011-10-02 Sam Weinig <sam@webkit.org>
Strength reduce Mac only Frame::searchForLabelsBeforeElement and Frame::matchLabelsAgainstElement into callers
readonly attribute HTMLFormElement form;
attribute [Reflect, URL] DOMString formAction;
- attribute [Reflect] DOMString formEnctype;
- attribute [Reflect] DOMString formMethod;
+ attribute [ConvertNullToNullString] DOMString formEnctype;
+ attribute [ConvertNullToNullString] DOMString formMethod;
attribute [Reflect] boolean formNoValidate;
attribute [Reflect] DOMString formTarget;
readonly attribute ValidityState validity;
HTMLElement::detach();
}
+String HTMLFormControlElement::formEnctype() const
+{
+ return FormSubmission::Attributes::parseEncodingType(fastGetAttribute(formenctypeAttr));
+}
+
+void HTMLFormControlElement::setFormEnctype(const String& value)
+{
+ setAttribute(formenctypeAttr, value);
+}
+
+String HTMLFormControlElement::formMethod() const
+{
+ return FormSubmission::Attributes::methodString(FormSubmission::Attributes::parseMethodType(fastGetAttribute(formmethodAttr)));
+}
+
+void HTMLFormControlElement::setFormMethod(const String& value)
+{
+ setAttribute(formmethodAttr, value);
+}
+
bool HTMLFormControlElement::formNoValidate() const
{
return fastHasAttribute(formnovalidateAttr);
HTMLFormElement* form() const { return FormAssociatedElement::form(); }
+ String formEnctype() const;
+ void setFormEnctype(const String&);
+ String formMethod() const;
+ void setFormMethod(const String&);
bool formNoValidate() const;
virtual void reset() { }
else if (attr->name() == targetAttr)
m_attributes.setTarget(attr->value());
else if (attr->name() == methodAttr)
- m_attributes.parseMethodType(attr->value());
+ m_attributes.updateMethodType(attr->value());
else if (attr->name() == enctypeAttr)
- m_attributes.parseEncodingType(attr->value());
+ m_attributes.updateEncodingType(attr->value());
else if (attr->name() == accept_charsetAttr)
m_attributes.setAcceptCharset(attr->value());
else if (attr->name() == autocompleteAttr) {
String HTMLFormElement::method() const
{
- return getAttribute(methodAttr);
+ return FormSubmission::Attributes::methodString(m_attributes.method());
}
void HTMLFormElement::setMethod(const String &value)
attribute [Reflect, URL] DOMString action;
attribute [ConvertNullToNullString] DOMString encoding;
attribute [ConvertNullToNullString] DOMString enctype;
- attribute [Reflect] DOMString method;
+ attribute [ConvertNullToNullString] DOMString method;
attribute [Reflect] DOMString target;
attribute [Reflect] DOMString autocomplete;
attribute [Reflect=checked] boolean defaultChecked;
readonly attribute HTMLFormElement form;
attribute [Reflect, URL] DOMString formAction;
- attribute [Reflect] DOMString formEnctype;
- attribute [Reflect] DOMString formMethod;
+ attribute [ConvertNullToNullString] DOMString formEnctype;
+ attribute [ConvertNullToNullString] DOMString formMethod;
attribute [Reflect] boolean formNoValidate;
attribute [Reflect] DOMString formTarget;
readonly attribute ValidityState validity;
m_action = stripLeadingAndTrailingHTMLSpaces(action);
}
-void FormSubmission::Attributes::parseEncodingType(const String& type)
+String FormSubmission::Attributes::parseEncodingType(const String& type)
{
- if (type.contains("multipart", false) || type.contains("form-data", false)) {
- m_encodingType = "multipart/form-data";
- m_isMultiPartForm = true;
- } else if (type.contains("text", false) || type.contains("plain", false)) {
- m_encodingType = "text/plain";
- m_isMultiPartForm = false;
- } else {
- m_encodingType = "application/x-www-form-urlencoded";
- m_isMultiPartForm = false;
- }
+ if (type.contains("multipart", false) || type.contains("form-data", false))
+ return "multipart/form-data";
+ if (type.contains("text", false) || type.contains("plain", false))
+ return "text/plain";
+ return "application/x-www-form-urlencoded";
+}
+
+void FormSubmission::Attributes::updateEncodingType(const String& type)
+{
+ m_encodingType = parseEncodingType(type);
+ m_isMultiPartForm = (m_encodingType == "multipart/form-data");
+}
+
+FormSubmission::Method FormSubmission::Attributes::parseMethodType(const String& type)
+{
+ return equalIgnoringCase(type, "post") ? FormSubmission::PostMethod : FormSubmission::GetMethod;
}
-void FormSubmission::Attributes::parseMethodType(const String& type)
+void FormSubmission::Attributes::updateMethodType(const String& type)
{
- if (equalIgnoringCase(type, "post"))
- m_method = FormSubmission::PostMethod;
- else if (equalIgnoringCase(type, "get"))
- m_method = FormSubmission::GetMethod;
+ m_method = parseMethodType(type);
}
void FormSubmission::Attributes::copyFrom(const Attributes& other)
if (!(attributeValue = submitButton->getAttribute(formactionAttr)).isNull())
copiedAttributes.parseAction(attributeValue);
if (!(attributeValue = submitButton->getAttribute(formenctypeAttr)).isNull())
- copiedAttributes.parseEncodingType(attributeValue);
+ copiedAttributes.updateEncodingType(attributeValue);
if (!(attributeValue = submitButton->getAttribute(formmethodAttr)).isNull())
- copiedAttributes.parseMethodType(attributeValue);
+ copiedAttributes.updateMethodType(attributeValue);
if (!(attributeValue = submitButton->getAttribute(formtargetAttr)).isNull())
copiedAttributes.setTarget(attributeValue);
}
}
Method method() const { return m_method; }
- void parseMethodType(const String&);
+ static Method parseMethodType(const String&);
+ void updateMethodType(const String&);
+ static String methodString(Method method) { return method == PostMethod ? "post" : "get"; }
const String& action() const { return m_action; }
void parseAction(const String&);
void setTarget(const String& target) { m_target = target; }
const String& encodingType() const { return m_encodingType; }
- void parseEncodingType(const String&);
+ static String parseEncodingType(const String&);
+ void updateEncodingType(const String&);
bool isMultiPartForm() const { return m_isMultiPartForm; }
const String& acceptCharset() const { return m_acceptCharset; }