| Differences between
and this patch
- a/LayoutTests/ChangeLog +16 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2009-08-05  Michelangelo De Simone  <micdesim@gmail.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=27455
6
        Test suite for form controls' custom validation message.
7
8
        * fast/forms/ValidityState-customError-001-expected.txt: Added.
9
        * fast/forms/ValidityState-customError-001.html: Added.
10
        * fast/forms/ValidityState-customError-002-expected.txt: Added.
11
        * fast/forms/ValidityState-customError-002.html: Added.
12
        * fast/forms/ValidityState-customError-003-expected.txt: Added.
13
        * fast/forms/ValidityState-customError-003.html: Added.
14
        * fast/forms/ValidityState-customError-004-expected.txt: Added.
15
        * fast/forms/ValidityState-customError-004.html: Added.
16
1
2009-08-04  Chris Fleizach  <cfleizach@apple.com>
17
2009-08-04  Chris Fleizach  <cfleizach@apple.com>
2
18
3
        Reviewed by Darin Adler.
19
        Reviewed by Darin Adler.
- a/LayoutTests/fast/forms/ValidityState-customError-001-expected.txt +6 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-001-expected.txt_sec1
1
   
2
SUCCESS
3
SUCCESS
4
SUCCESS
5
SUCCESS
6
SUCCESS
- a/LayoutTests/fast/forms/ValidityState-customError-001.html +30 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-001.html_sec1
1
<html>
2
<head>
3
<title>setCustomValidity and customError</title>
4
<script language="JavaScript" type="text/javascript">
5
    function log(message) {
6
        document.getElementById("console").innerHTML += "<li>"+message+"</li>";
7
    }
8
9
    function test() {
10
        if (window.layoutTestController)
11
            layoutTestController.dumpAsText();
12
13
        v = document.getElementsByName("victim");
14
        for (i = 0; i < v.length; i++) {
15
            v[i].setCustomValidity("Custom validation message");
16
            log(v[i].validity.customError ? "SUCCESS" : "FAILURE");
17
        }
18
    }
19
</script>
20
</head>
21
<body onload="test()">
22
<fieldset name="victim"></fieldset>
23
<button name="victim"></button>
24
<select name="victim"></select>
25
<textarea name="victim"></textarea>
26
<input name="victim" />
27
<hr>
28
<ol id="console"></ol>
29
</body>
30
</html>
- a/LayoutTests/fast/forms/ValidityState-customError-002-expected.txt +6 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-002-expected.txt_sec1
1
   
2
SUCCESS
3
SUCCESS
4
SUCCESS
5
SUCCESS
6
SUCCESS
- a/LayoutTests/fast/forms/ValidityState-customError-002.html +33 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-002.html_sec1
1
<html>
2
<head>
3
<title>setCustomValidity and customError 2</title>
4
<script language="JavaScript" type="text/javascript">
5
    function log(message) {
6
        document.getElementById("console").innerHTML += "<li>"+message+"</li>";
7
    }
8
9
    function test() {
10
        if (window.layoutTestController)
11
            layoutTestController.dumpAsText();
12
13
        v = document.getElementsByName("victim");
14
        for (i = 0; i < v.length; i++)
15
            v[i].setCustomValidity("Custom validation message");
16
17
        for (i = 0; i < v.length; i++) {
18
            v[i].setCustomValidity("");
19
            log(!v[i].validity.customError ? "SUCCESS" : "FAILURE");
20
        }
21
    }
22
</script>
23
</head>
24
<body onload="test()">
25
<fieldset name="victim"></fieldset>
26
<button name="victim"></button>
27
<select name="victim"></select>
28
<textarea name="victim"></textarea>
29
<input name="victim" />
30
<hr>
31
<ol id="console"></ol>
32
</body>
33
</html>
- a/LayoutTests/fast/forms/ValidityState-customError-003-expected.txt +6 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-003-expected.txt_sec1
1
   
2
SUCCESS
3
SUCCESS
4
SUCCESS
5
SUCCESS
6
SUCCESS
- a/LayoutTests/fast/forms/ValidityState-customError-003.html +28 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-003.html_sec1
1
<html>
2
<head>
3
<title>setCustomValidity and customError 2</title>
4
<script language="JavaScript" type="text/javascript">
5
    function log(message) {
6
        document.getElementById("console").innerHTML += "<li>"+message+"</li>";
7
    }
8
9
    function test() {
10
        if (window.layoutTestController)
11
            layoutTestController.dumpAsText();
12
13
        v = document.getElementsByName("victim");
14
        for (i = 0; i < v.length; i++)
15
            log(!v[i].validity.customError ? "SUCCESS" : "FAILURE");
16
    }
17
</script>
18
</head>
19
<body onload="test()">
20
<fieldset name="victim"></fieldset>
21
<button name="victim"></button>
22
<select name="victim"></select>
23
<textarea name="victim"></textarea>
24
<input name="victim" />
25
<hr>
26
<ol id="console"></ol>
27
</body>
28
</html>
- a/LayoutTests/fast/forms/ValidityState-customError-004-expected.txt +21 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-004-expected.txt_sec1
1
   
2
SUCCESS
3
SUCCESS
4
SUCCESS
5
SUCCESS
6
SUCCESS
7
SUCCESS
8
SUCCESS
9
SUCCESS
10
SUCCESS
11
SUCCESS
12
SUCCESS
13
SUCCESS
14
SUCCESS
15
SUCCESS
16
SUCCESS
17
SUCCESS
18
SUCCESS
19
SUCCESS
20
SUCCESS
21
SUCCESS
- a/LayoutTests/fast/forms/ValidityState-customError-004.html +40 lines
Line 0 a/LayoutTests/fast/forms/ValidityState-customError-004.html_sec1
1
<html>
2
<head>
3
<title>setCustomValidity and customError 4</title>
4
<script language="JavaScript" type="text/javascript">
5
    function log(message) {
6
        document.getElementById("console").innerHTML += "<li>"+message+"</li>";
7
    }
8
9
    function test() {
10
        if (window.layoutTestController)
11
            layoutTestController.dumpAsText();
12
13
        v = document.getElementsByName("victim");
14
15
        // Blank
16
        for (i = 0; i < v.length; i++) {
17
            v[i].setCustomValidity("Custom string");
18
            v[i].setCustomValidity();
19
            log(!v[i].validity.customError ? "SUCCESS" : "FAILURE");
20
            v[i].setCustomValidity("one", "two", "three");
21
            log(v[i].validity.customError ? "SUCCESS" : "FAILURE");
22
            v[i].setCustomValidity(null);
23
            log(!v[i].validity.customError ? "SUCCESS" : "FAILURE");
24
            v[i].setCustomValidity("Custom string");
25
            v[i].setCustomValidity(undefined);
26
            log(!v[i].validity.customError ? "SUCCESS" : "FAILURE");
27
        }
28
    }
29
</script>
30
</head>
31
<body onload="test()">
32
<fieldset name="victim"></fieldset>
33
<button name="victim"></button>
34
<select name="victim"></select>
35
<textarea name="victim"></textarea>
36
<input name="victim" />
37
<hr>
38
<ol id="console"></ol>
39
</body>
40
</html>
- a/WebCore/ChangeLog +28 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2009-08-05  Michelangelo De Simone  <micdesim@gmail.com>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=27455
6
        Support for a custom validation message in ValidityState and related
7
        form controls.
8
        http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#dom-cva-setcustomvalidity
9
10
        Test: fast/forms/ValidityState-customError-001.html
11
              fast/forms/ValidityState-customError-002.html
12
              fast/forms/ValidityState-customError-003.html
13
              fast/forms/ValidityState-customError-004.html
14
15
        * html/HTMLButtonElement.idl: added setCustomValidity method
16
        * html/HTMLFieldSetElement.idl: ditto
17
        * html/HTMLFormControlElement.cpp:
18
        (WebCore::HTMLFormControlElement::setCustomValidity): ditto
19
        * html/HTMLFormControlElement.h: ditto
20
        * html/HTMLInputElement.idl: ditto
21
        * html/HTMLSelectElement.idl: ditto
22
        * html/HTMLTextAreaElement.idl: ditto
23
        * html/ValidityState.cpp:
24
        (WebCore::ValidityState::ValidityState):
25
        (WebCore::ValidityState::setCustomValidity): ditto
26
        * html/ValidityState.h:
27
        (WebCore::ValidityState::customError): validation flag
28
1
2009-08-04  Chris Fleizach  <cfleizach@apple.com>
29
2009-08-04  Chris Fleizach  <cfleizach@apple.com>
2
30
3
        Bug 27994 - WAI-ARIA: aria-valuetext needs to be implemented
31
        Bug 27994 - WAI-ARIA: aria-valuetext needs to be implemented
- a/WebCore/html/HTMLButtonElement.idl +1 lines
Lines 36-41 module html { a/WebCore/html/HTMLButtonElement.idl_sec1
36
        readonly attribute  DOMString            type;
36
        readonly attribute  DOMString            type;
37
                 attribute  [ConvertNullToNullString] DOMString            value;
37
                 attribute  [ConvertNullToNullString] DOMString            value;
38
        readonly attribute boolean               willValidate;
38
        readonly attribute boolean               willValidate;
39
        void setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
39
        void click();
40
        void click();
40
    };
41
    };
41
42
- a/WebCore/html/HTMLFieldSetElement.idl +1 lines
Lines 29-34 module html { a/WebCore/html/HTMLFieldSetElement.idl_sec1
29
        readonly attribute ValidityState   validity;
29
        readonly attribute ValidityState   validity;
30
#endif
30
#endif
31
        readonly attribute boolean         willValidate;
31
        readonly attribute boolean         willValidate;
32
        void     setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
32
    };
33
    };
33
34
34
}
35
}
- a/WebCore/html/HTMLFormControlElement.cpp +5 lines
Lines 262-267 bool HTMLFormControlElement::willValidate() const a/WebCore/html/HTMLFormControlElement.cpp_sec1
262
    //      The control is not an output element.
262
    //      The control is not an output element.
263
    return form() && name().length() && !disabled() && !isReadOnlyFormControl();
263
    return form() && name().length() && !disabled() && !isReadOnlyFormControl();
264
}
264
}
265
266
void HTMLFormControlElement::setCustomValidity(const String& error)
267
{
268
    validity()->setCustomValidity(error);
269
}
265
    
270
    
266
void HTMLFormControlElement::dispatchFocusEvent()
271
void HTMLFormControlElement::dispatchFocusEvent()
267
{
272
{
- a/WebCore/html/HTMLFormControlElement.h -2 / +3 lines
Lines 25-30 a/WebCore/html/HTMLFormControlElement.h_sec1
25
#define HTMLFormControlElement_h
25
#define HTMLFormControlElement_h
26
26
27
#include "HTMLElement.h"
27
#include "HTMLElement.h"
28
//#include "ValidityState.h"
28
29
29
namespace WebCore {
30
namespace WebCore {
30
31
Lines 77-84 public: a/WebCore/html/HTMLFormControlElement.h_sec2
77
    bool required() const;
78
    bool required() const;
78
    void setRequired(bool);
79
    void setRequired(bool);
79
80
80
    virtual bool valueMissing() const { return false; }
81
82
    virtual void recalcStyle(StyleChange);
81
    virtual void recalcStyle(StyleChange);
83
82
84
    virtual const AtomicString& formControlName() const;
83
    virtual const AtomicString& formControlName() const;
Lines 104-110 public: a/WebCore/html/HTMLFormControlElement.h_sec3
104
    virtual short tabIndex() const;
103
    virtual short tabIndex() const;
105
104
106
    virtual bool willValidate() const;
105
    virtual bool willValidate() const;
106
    void setCustomValidity(const String&);
107
107
108
    virtual bool valueMissing() const { return false; }
108
    virtual bool patternMismatch() const { return false; }
109
    virtual bool patternMismatch() const { return false; }
109
110
110
    void formDestroyed() { m_form = 0; }
111
    void formDestroyed() { m_form = 0; }
- a/WebCore/html/HTMLInputElement.idl +1 lines
Lines 56-61 module html { a/WebCore/html/HTMLInputElement.idl_sec1
56
                 attribute [ConvertNullToNullString] DOMString useMap;
56
                 attribute [ConvertNullToNullString] DOMString useMap;
57
                 attribute [ConvertNullToNullString] DOMString value;
57
                 attribute [ConvertNullToNullString] DOMString value;
58
        readonly attribute boolean         willValidate;
58
        readonly attribute boolean         willValidate;
59
        void               setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
59
        void               select();
60
        void               select();
60
        void               click();
61
        void               click();
61
        
62
        
- a/WebCore/html/HTMLSelectElement.idl +1 lines
Lines 45-50 module html { a/WebCore/html/HTMLSelectElement.idl_sec1
45
        readonly attribute ValidityState   validity;
45
        readonly attribute ValidityState   validity;
46
#endif
46
#endif
47
        readonly attribute boolean         willValidate;
47
        readonly attribute boolean         willValidate;
48
        void               setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
48
49
49
        // Modified in DOM Level 2:
50
        // Modified in DOM Level 2:
50
        readonly attribute HTMLOptionsCollection options;
51
        readonly attribute HTMLOptionsCollection options;
- a/WebCore/html/HTMLTextAreaElement.idl +1 lines
Lines 44-49 module html { a/WebCore/html/HTMLTextAreaElement.idl_sec1
44
        void     select();
44
        void     select();
45
45
46
        readonly attribute boolean         willValidate;
46
        readonly attribute boolean         willValidate;
47
        void     setCustomValidity(in [ConvertUndefinedOrNullToNullString] DOMString error);
47
48
48
       // WinIE & FireFox extension:
49
       // WinIE & FireFox extension:
49
                 attribute long selectionStart;
50
                 attribute long selectionStart;
- a/WebCore/html/ValidityState.cpp +11 lines
Lines 27-36 namespace WebCore { a/WebCore/html/ValidityState.cpp_sec1
27
27
28
ValidityState::ValidityState(HTMLFormControlElement* parent)
28
ValidityState::ValidityState(HTMLFormControlElement* parent)
29
    : m_control(parent)
29
    : m_control(parent)
30
    , m_customError("")
30
{
31
{
31
    ASSERT(parent);
32
    ASSERT(parent);
32
}
33
}
33
34
35
void ValidityState::setCustomValidity(const String& error)
36
{
37
    if (error.isNull()) {
38
        m_customError = "";
39
        return;
40
    }
41
42
    m_customError = error;
43
}
44
34
bool ValidityState::valid()
45
bool ValidityState::valid()
35
{
46
{
36
    bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow() ||
47
    bool someError = typeMismatch() || stepMismatch() || rangeUnderflow() || rangeOverflow() ||
- a/WebCore/html/ValidityState.h -1 / +4 lines
Lines 38-43 namespace WebCore { a/WebCore/html/ValidityState.h_sec1
38
38
39
        HTMLFormControlElement* control() const { return m_control; }
39
        HTMLFormControlElement* control() const { return m_control; }
40
40
41
        void setCustomValidity(const String&);
42
41
        bool valueMissing() { return control()->valueMissing(); }
43
        bool valueMissing() { return control()->valueMissing(); }
42
        bool typeMismatch() { return false; }
44
        bool typeMismatch() { return false; }
43
        bool patternMismatch() { return control()->patternMismatch(); }
45
        bool patternMismatch() { return control()->patternMismatch(); }
Lines 45-56 namespace WebCore { a/WebCore/html/ValidityState.h_sec2
45
        bool rangeUnderflow() { return false; }
47
        bool rangeUnderflow() { return false; }
46
        bool rangeOverflow() { return false; }
48
        bool rangeOverflow() { return false; }
47
        bool stepMismatch() { return false; }
49
        bool stepMismatch() { return false; }
48
        bool customError() { return false; }
50
        bool customError() { return !m_customError.isEmpty(); }
49
        bool valid();
51
        bool valid();
50
52
51
    private:
53
    private:
52
        ValidityState(HTMLFormControlElement*);
54
        ValidityState(HTMLFormControlElement*);
53
        HTMLFormControlElement* m_control;
55
        HTMLFormControlElement* m_control;
56
        String m_customError;
54
    };
57
    };
55
58
56
} // namespace WebCore
59
} // namespace WebCore

Return to Bug 27455