Source/WebCore/ChangeLog

 12011-11-14 Rakesh KN <rakesh.kn@motorola.com>
 2
 3 Need support for dirname attribute
 4 https://bugs.webkit.org/show_bug.cgi?id=65542
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implemented 'dirname' form attribute.
 9
 10 Tests: fast/forms/form-dirname-attribute.html
 11 fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html
 12 fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html
 13 fast/forms/submit-form-with-dirname-attribute.html
 14
 15 * html/HTMLAttributeNames.in:
 16 Added "dirname" attribute.
 17 * html/HTMLInputElement.idl:
 18 Add "dirName" property to HTMLInputElement interface.
 19 * html/HTMLTextAreaElement.cpp:
 20 (WebCore::HTMLTextAreaElement::appendFormData):
 21 Append dirname form data.
 22 * html/HTMLTextAreaElement.idl:
 23 Add "dirName" property to HTMLTextAreaElement interface.
 24 * html/HTMLTextFormControlElement.cpp:
 25 (WebCore::parentHTMLElement):
 26 Helper function which returns only HTML parent element.
 27 (WebCore::HTMLTextFormControlElement::directionForFormData):
 28 Helper function for finding directionality of the Element.
 29 * html/HTMLTextFormControlElement.h:
 30 Helper function for finding directionality of the Element.
 31 * html/TextFieldInputType.cpp:
 32 (WebCore::TextFieldInputType::appendFormData):
 33 Append dirname form data.
 34 * html/TextFieldInputType.h:
 35 Append dirname form data.
 36
1372011-11-14 Rakesh KN <rakesh.kn@motorola.com>
238
339 Cannot select multiple options by mouse dragging in <select multiple="multiple" size="7"> list
100112

Source/WebCore/html/HTMLAttributeNames.in

@@default
9090defer
9191dir
9292direction
 93dirname
9394disabled
9495download
9596draggable
99824

Source/WebCore/html/HTMLInputElement.idl

@@module html {
2323 interface HTMLInputElement : HTMLElement {
2424 attribute [ConvertNullToNullString] DOMString defaultValue;
2525 attribute [Reflect=checked] boolean defaultChecked;
 26 attribute [Reflect] DOMString dirName;
2627 readonly attribute HTMLFormElement form;
2728 attribute [Reflect, URL] DOMString formAction;
2829 attribute [ConvertNullToNullString] DOMString formEnctype;
99824

Source/WebCore/html/HTMLTextAreaElement.cpp

@@bool HTMLTextAreaElement::appendFormData
173173
174174 const String& text = (m_wrap == HardWrap) ? valueWithHardLineBreaks() : value();
175175 encoding.appendData(name(), text);
176  return true;
 176
 177 const AtomicString& dirnameAttrValue = fastGetAttribute(dirnameAttr);
 178 if (!dirnameAttrValue.isNull())
 179 encoding.appendData(dirnameAttrValue, directionForFormData());
 180 return true;
177181}
178182
179183void HTMLTextAreaElement::reset()
99824

Source/WebCore/html/HTMLTextAreaElement.idl

@@module html {
2727 readonly attribute ValidityState validity;
2828 attribute [Reflect] DOMString accessKey;
2929 attribute long cols;
 30 attribute [Reflect] DOMString dirName;
3031 attribute [Reflect] boolean disabled;
3132 attribute [Reflect] boolean autofocus;
3233 attribute long maxLength setter raises(DOMException);
99824

Source/WebCore/html/HTMLTextFormControlElement.cpp

@@HTMLTextFormControlElement* enclosingTex
570570 return ancestor != container ? toTextFormControl(ancestor) : 0;
571571}
572572
 573static const Element* parentHTMLElement(const Element* element)
 574{
 575 while (element) {
 576 element = element->parentElement();
 577 if (element && element->isHTMLElement())
 578 return element;
 579 }
 580 return 0;
 581}
 582
 583String HTMLTextFormControlElement::directionForFormData() const
 584{
 585 for (const Element* element = this; element; element = parentHTMLElement(element)) {
 586 const AtomicString& dirAttributeValue = element->fastGetAttribute(dirAttr);
 587 if (dirAttributeValue.isNull())
 588 continue;
 589
 590 if (equalIgnoringCase(dirAttributeValue, "rtl") || equalIgnoringCase(dirAttributeValue, "ltr"))
 591 return dirAttributeValue;
 592
 593 if (equalIgnoringCase(dirAttributeValue, "auto")) {
 594 bool isAuto;
 595 TextDirection textDirection = static_cast<const HTMLElement*>(element)->directionalityIfhasDirAutoAttribute(isAuto);
 596 return textDirection == RTL ? "rtl" : "ltr";
 597 }
 598 }
 599
 600 return "ltr";
 601}
 602
573603} // namespace Webcore
99824

Source/WebCore/html/HTMLTextFormControlElement.h

@@public:
7979 void setInnerTextValue(const String&);
8080 String innerTextValue() const;
8181
 82 String directionForFormData() const;
 83
8284protected:
8385 HTMLTextFormControlElement(const QualifiedName&, Document*, HTMLFormElement*);
8486 virtual void updatePlaceholderText() = 0;
99824

Source/WebCore/html/TextFieldInputType.cpp

3333#include "TextFieldInputType.h"
3434
3535#include "BeforeTextInsertedEvent.h"
 36#include "FormDataList.h"
3637#include "Frame.h"
3738#include "HTMLInputElement.h"
 39#include "HTMLNames.h"
3840#include "KeyboardEvent.h"
3941#include "Page.h"
4042#include "RenderLayer.h"

4951
5052namespace WebCore {
5153
 54using namespace HTMLNames;
 55
5256TextFieldInputType::TextFieldInputType(HTMLInputElement* element)
5357 : InputType(element)
5458{

@@void TextFieldInputType::updatePlacehold
364368 ASSERT(!ec);
365369}
366370
 371bool TextFieldInputType::appendFormData(FormDataList& list, bool multipart) const
 372{
 373 InputType::appendFormData(list, multipart);
 374 const AtomicString& dirnameAttrValue = element()->fastGetAttribute(dirnameAttr);
 375 if (!dirnameAttrValue.isNull())
 376 list.appendData(dirnameAttrValue, element()->directionForFormData());
 377 return true;
 378}
 379
367380} // namespace WebCore
99824

Source/WebCore/html/TextFieldInputType.h

3535
3636namespace WebCore {
3737
 38class FormDataList;
3839class SpinButtonElement;
3940
4041// The class represents types of which UI contain text fields.

@@private:
7778 virtual bool shouldRespectListAttribute();
7879 virtual HTMLElement* placeholderElement() const;
7980 virtual void updatePlaceholderText();
 81 virtual bool appendFormData(FormDataList&, bool multipart) const;
8082
8183 RefPtr<HTMLElement> m_container;
8284 RefPtr<HTMLElement> m_innerBlock;
99824

LayoutTests/ChangeLog

 12011-11-14 Rakesh KN <rakesh.kn@motorola.com>
 2
 3 Need support for dirname attribute
 4 https://bugs.webkit.org/show_bug.cgi?id=65542
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implemented 'dirname' form attribute.
 9
 10 * fast/forms/form-dirname-attribute-expected.txt: Added.
 11 * fast/forms/form-dirname-attribute.html: Added.
 12 * fast/forms/submit-form-with-dirname-attribute-expected.txt: Added.
 13 * fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute-expected.txt: Added.
 14 * fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html: Added.
 15 * fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor-expected.txt: Added.
 16 * fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html: Added.
 17 * fast/forms/submit-form-with-dirname-attribute.html: Added.
 18
1192011-11-14 Kristóf Kosztyó <kkristof@inf.u-szeged.hu>
220
321 [Qt] Unreviewed gardening after r100050
100112

LayoutTests/fast/forms/form-dirname-attribute-expected.txt

 1"dirname" attribute
 2
 3PASS input.dirName is "Hello"
 4PASS textArea.dirName is "Hello"
 5PASS successfullyParsed is true
 6
 7TEST COMPLETE
 8
0

LayoutTests/fast/forms/form-dirname-attribute.html

 1<!DOCTYPE html>
 2<html>
 3<head>
 4<meta charset="utf-8">
 5<link rel="stylesheet" href="../js/resources/js-test-style.css">
 6<script src="../js/resources/js-test-pre.js"> </script>
 7</head>
 8<body>
 9<p>"dirname" attribute</p>
 10<pre id="console"></pre>
 11<script>
 12var input = document.createElement('input');
 13input.setAttribute('dirName', "Hello");
 14shouldBeEqualToString('input.dirName', "Hello");
 15
 16var textArea = document.createElement('textarea');
 17textArea.setAttribute('dirName', "Hello");
 18shouldBeEqualToString('textArea.dirName', "Hello");
 19successfullyParsed = true;
 20</script>
 21<script src="../js/resources/js-test-post.js"></script>
 22</body>
 23</html>
0

LayoutTests/fast/forms/submit-form-with-dirname-attribute-expected.txt

 1Test that when dirname attribute is specified then it is added in submission body.
 2
 3Comment:
 4
 5WithRTLDir:
 6
 7WithLTRDir:
 8
 9WithInvalidDir:
 10
 11WithRTLValue:
 12
 13Post Comment
 14
 15PASS document.location.search.indexOf("comment.dir=ltr") != -1 is true
 16PASS document.location.search.indexOf("txtareaRTL.dir=rtl") != -1 is true
 17PASS document.location.search.indexOf("txtareaLTR.dir=ltr") != -1 is true
 18PASS document.location.search.indexOf("txtareaInvalid.dir=ltr") != -1 is true
 19PASS document.location.search.indexOf("inputRTLvalue.dir=ltr") != -1 is true
 20PASS successfullyParsed is true
 21
 22TEST COMPLETE
 23
0

LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute-expected.txt

 1Test that when dirname attribute is specified then it is added in submission body.
 2
 3
 4
 5Post Comment
 6
 7Hello
 8PASS document.location.search.indexOf("rtlAncestor.dir=rtl") != -1 is true
 9PASS document.location.search.indexOf("autoAncestor.dir=ltr") != -1 is true
 10PASS successfullyParsed is true
 11
 12TEST COMPLETE
 13
0

LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-ancestor-dir-attribute.html

 1<html>
 2<head>
 3<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 4</head>
 5<script src="../js/resources/js-test-pre.js"> </script>
 6<script>
 7window.jsTestIsAsync = true;
 8
 9function test() {
 10 document.forms.f.submit();
 11}
 12</script>
 13<body onload="test()">
 14<p>Test that when dirname attribute is specified then it is added in submission body.</p>
 15
 16<div dir="auto">
 17 <form action="#action" method="GET" name="f">
 18 <div dir="rtl">
 19 <input type=text name="comment" dirname="rtlAncestor.dir" required>
 20 </div>
 21 <input type=text name="autoAncestor" dirname="autoAncestor.dir" value="שלום">
 22 <p><button name="mode" type=submit value="add">Post Comment</button></p>
 23 </form>
 24Hello
 25</div>
 26
 27<div id="console"></div>
 28<div id="action">
 29<script>
 30if (document.location.href.match('\\?')) {
 31 shouldBeTrue('document.location.search.indexOf("rtlAncestor.dir=rtl") != -1');
 32 shouldBeTrue('document.location.search.indexOf("autoAncestor.dir=ltr") != -1');
 33 finishJSTest();
 34}
 35
 36successfullyParsed = true;
 37</script>
 38</div>
 39<script src="../js/resources/js-test-post.js"></script>
 40</body>
 41</html>
0

LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor-expected.txt

 1Test that when dir attribute is specified for non html element, it is not considered for dirname attribute value in submission body.
 2
 3
 4Post Comment
 5
 6PASS document.location.search.indexOf("nonHtmlAncestor.dir=ltr") != -1 is true
 7PASS successfullyParsed is true
 8
 9TEST COMPLETE
 10
0

LayoutTests/fast/forms/submit-form-with-dirname-attribute-with-nonhtml-ancestor.html

 1<html>
 2<head>
 3<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 4</head>
 5<script src="../js/resources/js-test-pre.js"> </script>
 6<script>
 7window.jsTestIsAsync = true;
 8
 9function test() {
 10 document.forms.f.submit();
 11}
 12</script>
 13<body onload="test()">
 14<p>Test that when dir attribute is specified for non html element, it is not considered for dirname attribute value in submission body.</p>
 15<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 400 400" dir="rtl">
 16 <div>
 17 <form action="#action" method="GET" name="f">
 18 <input type=text name="nonHtmlAncestor" dirname="nonHtmlAncestor.dir">
 19 <p><button name="mode" type=submit value="add">Post Comment</button></p>
 20 </form>
 21 </div>
 22</svg>
 23<div id="console"></div>
 24<div id="action">
 25<script>
 26if (document.location.href.match('\\?')) {
 27 shouldBeTrue('document.location.search.indexOf("nonHtmlAncestor.dir=ltr") != -1');
 28 finishJSTest();
 29}
 30
 31successfullyParsed = true;
 32</script>
 33</div>
 34<script src="../js/resources/js-test-post.js"></script>
 35</body>
 36</html>
0

LayoutTests/fast/forms/submit-form-with-dirname-attribute.html

 1<html>
 2<head>
 3<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 4</head>
 5<script src="../js/resources/js-test-pre.js"> </script>
 6<script>
 7window.jsTestIsAsync = true;
 8
 9function test() {
 10 document.forms.f.submit();
 11}
 12</script>
 13<body onload="test()">
 14<p>Test that when dirname attribute is specified then it is added in submission body.</p>
 15
 16<form action="#action" name="f">
 17 <p><label>Comment: <input type=text name="comment" dirname="comment.dir" required></label></p>
 18 <p><label>WithRTLDir: <textarea name="txtarea" dir="rtl" dirname="txtareaRTL.dir"></textarea></label></p>
 19 <p><label>WithLTRDir: <textarea name="txtarea1" dir="ltr" dirname="txtareaLTR.dir"></textarea></label></p>
 20 <p><label>WithInvalidDir: <textarea name="txtarea2" dir="invalid" dirname="txtareaInvalid.dir"></textarea></label></p>
 21 <p><label>WithRTLValue: <input name="input" dirname="inputRTLvalue.dir" value="مرحبًا"></label></p>
 22 <p><button name="mode" type=submit value="add">Post Comment</button></p>
 23</form>
 24
 25<div id="console"></div>
 26<div id="action">
 27<script>
 28if (document.location.href.match('\\?')) {
 29 shouldBeTrue('document.location.search.indexOf("comment.dir=ltr") != -1');
 30 shouldBeTrue('document.location.search.indexOf("txtareaRTL.dir=rtl") != -1');
 31 shouldBeTrue('document.location.search.indexOf("txtareaLTR.dir=ltr") != -1');
 32 shouldBeTrue('document.location.search.indexOf("txtareaInvalid.dir=ltr") != -1');
 33 shouldBeTrue('document.location.search.indexOf("inputRTLvalue.dir=ltr") != -1');
 34 finishJSTest();
 35}
 36
 37successfullyParsed = true;
 38</script>
 39</div>
 40<script src="../js/resources/js-test-post.js"></script>
 41</body>
 42</html>
0