• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the WebKit project.
3  *
4  * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ValidityState_h
24 #define ValidityState_h
25 
26 #include "HTMLFormControlElement.h"
27 #include <wtf/PassRefPtr.h>
28 #include <wtf/RefCounted.h>
29 
30 namespace WebCore {
31 
32     class ValidityState : public RefCounted<ValidityState> {
33     public:
create(HTMLFormControlElement * owner)34         static PassRefPtr<ValidityState> create(HTMLFormControlElement* owner)
35         {
36             return adoptRef(new ValidityState(owner));
37         }
38 
control()39         HTMLFormControlElement* control() const { return m_control; }
40 
setCustomErrorMessage(const String & message)41         void setCustomErrorMessage(const String& message) { m_customErrorMessage = message; }
42 
valueMissing()43         bool valueMissing() { return control()->valueMissing(); }
typeMismatch()44         bool typeMismatch() { return false; }
patternMismatch()45         bool patternMismatch() { return control()->patternMismatch(); }
tooLong()46         bool tooLong() { return false; }
rangeUnderflow()47         bool rangeUnderflow() { return false; }
rangeOverflow()48         bool rangeOverflow() { return false; }
stepMismatch()49         bool stepMismatch() { return false; }
customError()50         bool customError() { return !m_customErrorMessage.isEmpty(); }
51         bool valid();
52 
53     private:
54         ValidityState(HTMLFormControlElement*);
55         HTMLFormControlElement* m_control;
56         String m_customErrorMessage;
57     };
58 
59 } // namespace WebCore
60 
61 #endif // ValidityState_h
62