diff options
Diffstat (limited to 'WebCore/html/ValidityState.h')
-rw-r--r-- | WebCore/html/ValidityState.h | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/WebCore/html/ValidityState.h b/WebCore/html/ValidityState.h index 7ae95d7..78238f1 100644 --- a/WebCore/html/ValidityState.h +++ b/WebCore/html/ValidityState.h @@ -2,6 +2,7 @@ * This file is part of the WebKit project. * * Copyright (C) 2009 Michelangelo De Simone <micdesim@gmail.com> + * Copyright (C) 2010 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,41 +25,43 @@ #define ValidityState_h #include "HTMLFormControlElement.h" -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { - class ValidityState : public RefCounted<ValidityState> { - public: - static PassRefPtr<ValidityState> create(HTMLFormControlElement* owner) - { - return adoptRef(new ValidityState(owner)); - } +class ValidityState : public Noncopyable { +public: + static PassOwnPtr<ValidityState> create(HTMLFormControlElement* control) + { + return new ValidityState(control); + } - HTMLFormControlElement* control() const { return m_control; } + void ref() { m_control->ref(); } + void deref() { m_control->deref(); } - String validationMessage(); - void setCustomErrorMessage(const String& message) { m_customErrorMessage = message; } + String validationMessage() const; - bool valueMissing() { return control()->valueMissing(); } - bool typeMismatch(); - bool patternMismatch() { return control()->patternMismatch(); } - bool tooLong() { return control()->tooLong(); } - bool rangeUnderflow(); - bool rangeOverflow(); - bool stepMismatch(); - bool customError() { return !m_customErrorMessage.isEmpty(); } - bool valid(); + void setCustomErrorMessage(const String& message) { m_customErrorMessage = message; } - private: - ValidityState(HTMLFormControlElement*); - HTMLFormControlElement* m_control; - String m_customErrorMessage; + bool valueMissing() const { return m_control->valueMissing(); } + bool typeMismatch() const; + bool patternMismatch() const { return m_control->patternMismatch(); } + bool tooLong() const { return m_control->tooLong(); } + bool rangeUnderflow() const; + bool rangeOverflow() const; + bool stepMismatch() const; + bool customError() const { return !m_customErrorMessage.isEmpty(); } + bool valid() const; - static bool isValidColorString(const String&); - bool isValidEmailAddress(const String&); - }; +private: + ValidityState(HTMLFormControlElement* control) : m_control(control) { } + + static bool isValidColorString(const String&); + static bool isValidEmailAddress(const String&); + + HTMLFormControlElement* m_control; + String m_customErrorMessage; +}; } // namespace WebCore |