Diff
Modified: trunk/LayoutTests/ChangeLog (99815 => 99816)
--- trunk/LayoutTests/ChangeLog 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/LayoutTests/ChangeLog 2011-11-10 06:50:34 UTC (rev 99816)
@@ -1,3 +1,21 @@
+2011-11-09 Rakesh KN <[email protected]>
+
+ Need support for dirname attribute
+ https://bugs.webkit.org/show_bug.cgi?id=65542
+
+ Reviewed by Eric Seidel.
+
+ Implemented 'dirname' form attribute.
+
+ * fast/forms/form-dirname-attribute-expected.txt: Added.
+ * fast/forms/form-dirname-attribute.html: Added.
+ * fast/forms/submit-form-with-dirname-attribute-expected.txt: Added.
+ * fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute-expected.txt: Added.
+ * fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html: Added.
+ * fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor-expected.txt: Added.
+ * fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html: Added.
+ * fast/forms/submit-form-with-dirname-attribute.html: Added.
+
2011-11-09 Shinya Kawanaka <[email protected]>
Internals.markerRangeForNode should be able to take markers by specifying a marker type.
Added: trunk/LayoutTests/fast/forms/form-dirname-attribute-expected.txt (0 => 99816)
--- trunk/LayoutTests/fast/forms/form-dirname-attribute-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/form-dirname-attribute-expected.txt 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,8 @@
+"dirname" attribute
+
+PASS input.dirName is "Hello"
+PASS textArea.dirName is "Hello"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/form-dirname-attribute.html (0 => 99816)
--- trunk/LayoutTests/fast/forms/form-dirname-attribute.html (rev 0)
+++ trunk/LayoutTests/fast/forms/form-dirname-attribute.html 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href=""
+<script src="" </script>
+</head>
+<body>
+<p>"dirname" attribute</p>
+<pre id="console"></pre>
+<script>
+var input = document.createElement('input');
+input.setAttribute('dirName', "Hello");
+shouldBeEqualToString('input.dirName', "Hello");
+
+var textArea = document.createElement('textarea');
+textArea.setAttribute('dirName', "Hello");
+shouldBeEqualToString('textArea.dirName', "Hello");
+successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-expected.txt (0 => 99816)
--- trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-expected.txt 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,23 @@
+Test that when dirname attribute is specified then it is added in submission body.
+
+Comment:
+
+WithRTLDir:
+
+WithLTRDir:
+
+WithInvalidDir:
+
+WithRTLValue:
+
+Post Comment
+
+PASS document.location.search.indexOf("comment.dir=ltr") != -1 is true
+PASS document.location.search.indexOf("txtareaRTL.dir=rtl") != -1 is true
+PASS document.location.search.indexOf("txtareaLTR.dir=ltr") != -1 is true
+PASS document.location.search.indexOf("txtareaInvalid.dir=ltr") != -1 is true
+PASS document.location.search.indexOf("inputRTLvalue.dir=ltr") != -1 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute-expected.txt (0 => 99816)
--- trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute-expected.txt 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,13 @@
+Test that when dirname attribute is specified then it is added in submission body.
+
+
+
+Post Comment
+
+Hello
+PASS document.location.search.indexOf("rtlAncestor.dir=rtl") != -1 is true
+PASS document.location.search.indexOf("autoAncestor.dir=ltr") != -1 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html (0 => 99816)
--- trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,41 @@
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+</head>
+<script src="" </script>
+<script>
+window.jsTestIsAsync = true;
+
+function test() {
+ document.forms.f.submit();
+}
+</script>
+<body _onload_="test()">
+<p>Test that when dirname attribute is specified then it is added in submission body.</p>
+
+<div dir="auto">
+ <form action="" method="GET" name="f">
+ <div dir="rtl">
+ <input type=text name="comment" dirname="rtlAncestor.dir" required>
+ </div>
+ <input type=text name="autoAncestor" dirname="autoAncestor.dir" value="שלום">
+ <p><button name="mode" type=submit value="add">Post Comment</button></p>
+ </form>
+Hello
+</div>
+
+<div id="console"></div>
+<div id="action">
+<script>
+if (document.location.href.match('\\?')) {
+ shouldBeTrue('document.location.search.indexOf("rtlAncestor.dir=rtl") != -1');
+ shouldBeTrue('document.location.search.indexOf("autoAncestor.dir=ltr") != -1');
+ finishJSTest();
+}
+
+successfullyParsed = true;
+</script>
+</div>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor-expected.txt (0 => 99816)
--- trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor-expected.txt 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,10 @@
+Test that when dir attribute is specified for non html element, it is not considered for dirname attribute value in submission body.
+
+
+Post Comment
+
+PASS document.location.search.indexOf("nonHtmlAncestor.dir=ltr") != -1 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html (0 => 99816)
--- trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,36 @@
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+</head>
+<script src="" </script>
+<script>
+window.jsTestIsAsync = true;
+
+function test() {
+ document.forms.f.submit();
+}
+</script>
+<body _onload_="test()">
+<p>Test that when dir attribute is specified for non html element, it is not considered for dirname attribute value in submission body.</p>
+<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 400 400" dir="rtl">
+ <div>
+ <form action="" method="GET" name="f">
+ <input type=text name="nonHtmlAncestor" dirname="nonHtmlAncestor.dir">
+ <p><button name="mode" type=submit value="add">Post Comment</button></p>
+ </form>
+ </div>
+</svg>
+<div id="console"></div>
+<div id="action">
+<script>
+if (document.location.href.match('\\?')) {
+ shouldBeTrue('document.location.search.indexOf("nonHtmlAncestor.dir=ltr") != -1');
+ finishJSTest();
+}
+
+successfullyParsed = true;
+</script>
+</div>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute.html (0 => 99816)
--- trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute.html (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-form-with-dirname-attribute.html 2011-11-10 06:50:34 UTC (rev 99816)
@@ -0,0 +1,42 @@
+<html>
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+</head>
+<script src="" </script>
+<script>
+window.jsTestIsAsync = true;
+
+function test() {
+ document.forms.f.submit();
+}
+</script>
+<body _onload_="test()">
+<p>Test that when dirname attribute is specified then it is added in submission body.</p>
+
+<form action="" name="f">
+ <p><label>Comment: <input type=text name="comment" dirname="comment.dir" required></label></p>
+ <p><label>WithRTLDir: <textarea name="txtarea" dir="rtl" dirname="txtareaRTL.dir"></textarea></label></p>
+ <p><label>WithLTRDir: <textarea name="txtarea1" dir="ltr" dirname="txtareaLTR.dir"></textarea></label></p>
+ <p><label>WithInvalidDir: <textarea name="txtarea2" dir="invalid" dirname="txtareaInvalid.dir"></textarea></label></p>
+ <p><label>WithRTLValue: <input name="input" dirname="inputRTLvalue.dir" value="مرحبًا"></label></p>
+ <p><button name="mode" type=submit value="add">Post Comment</button></p>
+</form>
+
+<div id="console"></div>
+<div id="action">
+<script>
+if (document.location.href.match('\\?')) {
+ shouldBeTrue('document.location.search.indexOf("comment.dir=ltr") != -1');
+ shouldBeTrue('document.location.search.indexOf("txtareaRTL.dir=rtl") != -1');
+ shouldBeTrue('document.location.search.indexOf("txtareaLTR.dir=ltr") != -1');
+ shouldBeTrue('document.location.search.indexOf("txtareaInvalid.dir=ltr") != -1');
+ shouldBeTrue('document.location.search.indexOf("inputRTLvalue.dir=ltr") != -1');
+ finishJSTest();
+}
+
+successfullyParsed = true;
+</script>
+</div>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (99815 => 99816)
--- trunk/Source/WebCore/ChangeLog 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/ChangeLog 2011-11-10 06:50:34 UTC (rev 99816)
@@ -1,3 +1,39 @@
+2011-11-09 Rakesh KN <[email protected]>
+
+ Need support for dirname attribute
+ https://bugs.webkit.org/show_bug.cgi?id=65542
+
+ Reviewed by Eric Seidel.
+
+ Implemented 'dirname' form attribute.
+
+ Tests: fast/forms/form-dirname-attribute.html
+ fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html
+ fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html
+ fast/forms/submit-form-with-dirname-attribute.html
+
+ * html/HTMLAttributeNames.in:
+ Added "dirname" attribute.
+ * html/HTMLInputElement.idl:
+ Add "dirName" property to HTMLInputElement interface.
+ * html/HTMLTextAreaElement.cpp:
+ (WebCore::HTMLTextAreaElement::appendFormData):
+ Append dirname form data.
+ * html/HTMLTextAreaElement.idl:
+ Add "dirName" property to HTMLTextAreaElement interface.
+ * html/HTMLTextFormControlElement.cpp:
+ (WebCore::parentHTMLElement):
+ Helper function which returns only HTML parent element.
+ (WebCore::HTMLTextFormControlElement::directionForFormData):
+ Helper function for finding directionality of the Element.
+ * html/HTMLTextFormControlElement.h:
+ Helper function for finding directionality of the Element.
+ * html/TextFieldInputType.cpp:
+ (WebCore::TextFieldInputType::appendFormData):
+ Append dirname form data.
+ * html/TextFieldInputType.h:
+ Append dirname form data.
+
2011-11-09 Shinya Kawanaka <[email protected]>
Internals.markerRangeForNode should be able to take markers by specifying a marker type.
Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (99815 => 99816)
--- trunk/Source/WebCore/html/HTMLAttributeNames.in 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in 2011-11-10 06:50:34 UTC (rev 99816)
@@ -90,6 +90,7 @@
defer
dir
direction
+dirname
disabled
download
draggable
Modified: trunk/Source/WebCore/html/HTMLInputElement.idl (99815 => 99816)
--- trunk/Source/WebCore/html/HTMLInputElement.idl 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/HTMLInputElement.idl 2011-11-10 06:50:34 UTC (rev 99816)
@@ -23,6 +23,7 @@
interface HTMLInputElement : HTMLElement {
attribute [ConvertNullToNullString] DOMString defaultValue;
attribute [Reflect=checked] boolean defaultChecked;
+ attribute [Reflect] DOMString dirName;
readonly attribute HTMLFormElement form;
attribute [Reflect, URL] DOMString formAction;
attribute [ConvertNullToNullString] DOMString formEnctype;
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (99815 => 99816)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp 2011-11-10 06:50:34 UTC (rev 99816)
@@ -173,7 +173,11 @@
const String& text = (m_wrap == HardWrap) ? valueWithHardLineBreaks() : value();
encoding.appendData(name(), text);
- return true;
+
+ const AtomicString& dirnameAttrValue = fastGetAttribute(dirnameAttr);
+ if (!dirnameAttrValue.isNull())
+ encoding.appendData(dirnameAttrValue, directionForFormData());
+ return true;
}
void HTMLTextAreaElement::reset()
Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.idl (99815 => 99816)
--- trunk/Source/WebCore/html/HTMLTextAreaElement.idl 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.idl 2011-11-10 06:50:34 UTC (rev 99816)
@@ -27,6 +27,7 @@
readonly attribute ValidityState validity;
attribute [Reflect] DOMString accessKey;
attribute long cols;
+ attribute [Reflect] DOMString dirName;
attribute [Reflect] boolean disabled;
attribute [Reflect] boolean autofocus;
attribute long maxLength setter raises(DOMException);
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (99815 => 99816)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2011-11-10 06:50:34 UTC (rev 99816)
@@ -570,4 +570,34 @@
return ancestor != container ? toTextFormControl(ancestor) : 0;
}
+const Element* parentHTMLElement(const Element* element)
+{
+ while (element) {
+ element = element->parentElement();
+ if (element && element->isHTMLElement())
+ return element;
+ }
+ return 0;
+}
+
+String HTMLTextFormControlElement::directionForFormData() const
+{
+ for (const Element* element = this; element; element = parentHTMLElement(element)) {
+ const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAttr);
+ if (dirAttributeValue.isNull())
+ continue;
+
+ if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dirAttributeValue, "ltr"))
+ return dirAttributeValue;
+
+ if (equalIgnoringCase(dirAttributeValue, "auto")) {
+ bool isAuto;
+ TextDirection textDirection = static_cast<const HTMLElement*>(element)->directionalityIfhasDirAutoAttribute(isAuto);
+ return textDirection == RTL ? "rtl" : "ltr";
+ }
+ }
+
+ return "ltr";
+}
+
} // namespace Webcore
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (99815 => 99816)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h 2011-11-10 06:50:34 UTC (rev 99816)
@@ -79,6 +79,8 @@
void setInnerTextValue(const String&);
String innerTextValue() const;
+ String directionForFormData() const;
+
protected:
HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
virtual void updatePlaceholderText() = 0;
Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (99815 => 99816)
--- trunk/Source/WebCore/html/TextFieldInputType.cpp 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp 2011-11-10 06:50:34 UTC (rev 99816)
@@ -33,8 +33,10 @@
#include "TextFieldInputType.h"
#include "BeforeTextInsertedEvent.h"
+#include "FormDataList.h"
#include "Frame.h"
#include "HTMLInputElement.h"
+#include "HTMLNames.h"
#include "KeyboardEvent.h"
#include "Page.h"
#include "RenderLayer.h"
@@ -49,6 +51,8 @@
namespace WebCore {
+using namespace HTMLNames;
+
TextFieldInputType::TextFieldInputType(HTMLInputElement* element)
: InputType(element)
{
@@ -364,4 +368,13 @@
ASSERT(!ec);
}
+bool TextFieldInputType::appendFormData(FormDataList& list, bool multipart) const
+{
+ InputType::appendFormData(list, multipart);
+ const AtomicString& dirnameAttrValue = element()->fastGetAttribute(dirnameAttr);
+ if (!dirnameAttrValue.isNull())
+ list.appendData(dirnameAttrValue, element()->directionForFormData());
+ return true;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/TextFieldInputType.h (99815 => 99816)
--- trunk/Source/WebCore/html/TextFieldInputType.h 2011-11-10 06:28:32 UTC (rev 99815)
+++ trunk/Source/WebCore/html/TextFieldInputType.h 2011-11-10 06:50:34 UTC (rev 99816)
@@ -35,6 +35,7 @@
namespace WebCore {
+class FormDataList;
class SpinButtonElement;
// The class represents types of which UI contain text fields.
@@ -77,6 +78,7 @@
virtual bool shouldRespectListAttribute();
virtual HTMLElement* placeholderElement() const;
virtual void updatePlaceholderText();
+ virtual bool appendFormData(FormDataList&, bool multipart) const;
RefPtr<HTMLElement> m_container;
RefPtr<HTMLElement> m_innerBlock;