1967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch/*
2967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * Copyright (C) 2010 Google Inc. All rights reserved.
3967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
4967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * Redistribution and use in source and binary forms, with or without
5967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * modification, are permitted provided that the following conditions are
6967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * met:
7967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
8967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Redistributions of source code must retain the above copyright
9967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * notice, this list of conditions and the following disclaimer.
10967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Redistributions in binary form must reproduce the above
11967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * copyright notice, this list of conditions and the following disclaimer
12967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * in the documentation and/or other materials provided with the
13967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * distribution.
14967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *     * Neither the name of Google Inc. nor the names of its
15967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * contributors may be used to endorse or promote products derived from
16967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * this software without specific prior written permission.
17967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch *
18967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch */
30967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
31bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#ifndef NumberInputType_h
32bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#define NumberInputType_h
33967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
34bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#include "TextFieldInputType.h"
35967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
36967717af5423377c967781471ee106e2bb4e11c8Ben Murdochnamespace WebCore {
37967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
38bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenclass NumberInputType : public TextFieldInputType {
39bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenpublic:
40bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    static PassOwnPtr<InputType> create(HTMLInputElement*);
41967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
42bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsenprivate:
43bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    NumberInputType(HTMLInputElement* element) : TextFieldInputType(element) { }
44bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen    virtual const AtomicString& formControlType() const;
45a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double valueAsNumber() const;
46a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual void setValueAsNumber(double, ExceptionCode&) const;
47a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual bool typeMismatchFor(const String&) const;
48a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual bool typeMismatch() const;
49a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual bool rangeUnderflow(const String&) const;
50a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual bool rangeOverflow(const String&) const;
51cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual bool supportsRangeLimitation() const;
52a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double minimum() const;
53a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double maximum() const;
54a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual bool stepMismatch(const String&, double) const;
55a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double stepBase() const;
566b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner    virtual double stepBaseWithDecimalPlaces(unsigned*) const;
57a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double defaultStep() const;
58a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double stepScaleFactor() const;
59cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual void handleKeydownEvent(KeyboardEvent*);
60cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual void handleWheelEvent(WheelEvent*);
61a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual double parseToDouble(const String&, double) const;
626b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner    virtual double parseToDoubleWithDecimalPlaces(const String&, double, unsigned*) const;
63a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch    virtual String serialize(double) const;
646b70adc33054f8aee8c54d0f460458a9df11b8a5Russell Brenner    virtual double acceptableError(double) const;
65cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual void handleBlurEvent();
662fc2651226baac27029e38c9d6ef883fa32084dbSteve Block    virtual String visibleValue() const;
6781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch    virtual String convertFromVisibleValue(const String&) const;
68cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual bool isAcceptableValue(const String&);
69cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual String sanitizeValue(const String&);
70cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual bool hasUnacceptableValue();
71cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual bool shouldRespectSpeechAttribute();
72cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual bool isNumberField() const;
73cad810f21b803229eb11403f9209855525a25d57Steve Block    virtual bool hasSpinButton();
74bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen};
75967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
76967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch} // namespace WebCore
77967717af5423377c967781471ee106e2bb4e11c8Ben Murdoch
78bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen#endif // NumberInputType_h
79