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