~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/html/shadow/DateTimeFieldElements.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Google Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1.  Redistributions of source code must retain the above copyright
 
8
 *     notice, this list of conditions and the following disclaimer.
 
9
 * 2.  Redistributions in binary form must reproduce the above copyright
 
10
 *     notice, this list of conditions and the following disclaimer in the
 
11
 *     documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
 
14
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
16
 * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
 
17
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
18
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
19
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
20
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
21
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
22
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
23
 * SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#ifndef DateTimeFieldElements_h
 
27
#define DateTimeFieldElements_h
 
28
 
 
29
#if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
 
30
#include "DateTimeNumericFieldElement.h"
 
31
#include "DateTimeSymbolicFieldElement.h"
 
32
 
 
33
namespace WebCore {
 
34
 
 
35
class DateTimeAMPMFieldElement : public DateTimeSymbolicFieldElement {
 
36
    WTF_MAKE_NONCOPYABLE(DateTimeAMPMFieldElement);
 
37
 
 
38
public:
 
39
    static PassRefPtr<DateTimeAMPMFieldElement> create(Document*, FieldOwner&, const Vector<String>&);
 
40
 
 
41
private:
 
42
    DateTimeAMPMFieldElement(Document*, FieldOwner&, const Vector<String>&);
 
43
 
 
44
    // DateTimeFieldElement functions.
 
45
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
46
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
47
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
48
};
 
49
 
 
50
class DateTimeDayFieldElement : public DateTimeNumericFieldElement {
 
51
    WTF_MAKE_NONCOPYABLE(DateTimeDayFieldElement);
 
52
 
 
53
public:
 
54
    static PassRefPtr<DateTimeDayFieldElement> create(Document*, FieldOwner&, const String& placeholder);
 
55
 
 
56
private:
 
57
    DateTimeDayFieldElement(Document*, FieldOwner&, const String& placeholder);
 
58
 
 
59
    // DateTimeFieldElement functions.
 
60
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
61
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
62
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
63
};
 
64
 
 
65
// DateTimeHourFieldElement is used for hour field of date time format
 
66
// supporting following patterns:
 
67
//  - 0 to 11
 
68
//  - 1 to 12
 
69
//  - 0 to 23
 
70
//  - 1 to 24
 
71
class DateTimeHourFieldElement : public DateTimeNumericFieldElement {
 
72
    WTF_MAKE_NONCOPYABLE(DateTimeHourFieldElement);
 
73
 
 
74
public:
 
75
    static PassRefPtr<DateTimeHourFieldElement> create(Document*, FieldOwner&, int minimum, int maximum);
 
76
 
 
77
private:
 
78
    DateTimeHourFieldElement(Document*, FieldOwner&, int minimum, int maximum);
 
79
 
 
80
    // DateTimeFieldElement functions.
 
81
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
82
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
83
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
84
    virtual void setValueAsInteger(int, EventBehavior = DispatchNoEvent) OVERRIDE FINAL;
 
85
    virtual int valueAsInteger() const OVERRIDE FINAL;
 
86
 
 
87
    const int m_alignment;
 
88
};
 
89
 
 
90
class DateTimeMillisecondFieldElement : public DateTimeNumericFieldElement {
 
91
    WTF_MAKE_NONCOPYABLE(DateTimeMillisecondFieldElement);
 
92
 
 
93
public:
 
94
    static PassRefPtr<DateTimeMillisecondFieldElement> create(Document*, FieldOwner&);
 
95
 
 
96
private:
 
97
    DateTimeMillisecondFieldElement(Document*, FieldOwner&);
 
98
 
 
99
    // DateTimeFieldElement functions.
 
100
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
101
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
102
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
103
};
 
104
 
 
105
class DateTimeMinuteFieldElement : public DateTimeNumericFieldElement {
 
106
    WTF_MAKE_NONCOPYABLE(DateTimeMinuteFieldElement);
 
107
 
 
108
public:
 
109
    static PassRefPtr<DateTimeMinuteFieldElement> create(Document*, FieldOwner&);
 
110
 
 
111
private:
 
112
    DateTimeMinuteFieldElement(Document*, FieldOwner&);
 
113
 
 
114
    // DateTimeFieldElement functions.
 
115
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
116
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
117
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
118
};
 
119
 
 
120
class DateTimeMonthFieldElement : public DateTimeNumericFieldElement {
 
121
    WTF_MAKE_NONCOPYABLE(DateTimeMonthFieldElement);
 
122
 
 
123
public:
 
124
    static PassRefPtr<DateTimeMonthFieldElement> create(Document*, FieldOwner&, const String& placeholder);
 
125
 
 
126
private:
 
127
    DateTimeMonthFieldElement(Document*, FieldOwner&, const String& placeholder);
 
128
 
 
129
    // DateTimeFieldElement functions.
 
130
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
131
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
132
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
133
};
 
134
 
 
135
class DateTimeSecondFieldElement : public DateTimeNumericFieldElement {
 
136
    WTF_MAKE_NONCOPYABLE(DateTimeSecondFieldElement);
 
137
 
 
138
public:
 
139
    static PassRefPtr<DateTimeSecondFieldElement> create(Document*, FieldOwner&);
 
140
 
 
141
private:
 
142
    DateTimeSecondFieldElement(Document*, FieldOwner&);
 
143
 
 
144
    // DateTimeFieldElement functions.
 
145
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
146
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
147
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
148
};
 
149
 
 
150
class DateTimeSymbolicMonthFieldElement : public DateTimeSymbolicFieldElement {
 
151
    WTF_MAKE_NONCOPYABLE(DateTimeSymbolicMonthFieldElement);
 
152
 
 
153
public:
 
154
    static PassRefPtr<DateTimeSymbolicMonthFieldElement> create(Document*, FieldOwner&, const Vector<String>&);
 
155
 
 
156
private:
 
157
    DateTimeSymbolicMonthFieldElement(Document*, FieldOwner&, const Vector<String>&);
 
158
 
 
159
    // DateTimeFieldElement functions.
 
160
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
161
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
162
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
163
};
 
164
 
 
165
class DateTimeWeekFieldElement : public DateTimeNumericFieldElement {
 
166
    WTF_MAKE_NONCOPYABLE(DateTimeWeekFieldElement);
 
167
 
 
168
public:
 
169
    static PassRefPtr<DateTimeWeekFieldElement> create(Document*, FieldOwner&);
 
170
 
 
171
private:
 
172
    DateTimeWeekFieldElement(Document*, FieldOwner&);
 
173
 
 
174
    // DateTimeFieldElement functions.
 
175
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
176
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
177
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
178
};
 
179
 
 
180
class DateTimeYearFieldElement : public DateTimeNumericFieldElement {
 
181
    WTF_MAKE_NONCOPYABLE(DateTimeYearFieldElement);
 
182
 
 
183
public:
 
184
    struct Parameters {
 
185
        int minimumYear;
 
186
        int maximumYear;
 
187
        bool minIsSpecified;
 
188
        bool maxIsSpecified;
 
189
        String placeholder;
 
190
 
 
191
        Parameters()
 
192
            : minimumYear(-1)
 
193
            , maximumYear(-1)
 
194
            , minIsSpecified(false)
 
195
            , maxIsSpecified(false)
 
196
        {
 
197
        }
 
198
    };
 
199
 
 
200
    static PassRefPtr<DateTimeYearFieldElement> create(Document*, FieldOwner&, const Parameters&);
 
201
 
 
202
private:
 
203
    DateTimeYearFieldElement(Document*, FieldOwner&, const Parameters&);
 
204
 
 
205
    // DateTimeFieldElement functions.
 
206
    virtual void populateDateTimeFieldsState(DateTimeFieldsState&) OVERRIDE FINAL;
 
207
    virtual void setValueAsDate(const DateComponents&) OVERRIDE FINAL;
 
208
    virtual void setValueAsDateTimeFieldsState(const DateTimeFieldsState&) OVERRIDE FINAL;
 
209
 
 
210
    // DateTimeNumericFieldElement functions.
 
211
    virtual int clampValueForHardLimits(int) const OVERRIDE FINAL;
 
212
    virtual int defaultValueForStepDown() const OVERRIDE FINAL;
 
213
    virtual int defaultValueForStepUp() const OVERRIDE FINAL;
 
214
 
 
215
    bool m_minIsSpecified;
 
216
    bool m_maxIsSpecified;
 
217
};
 
218
 
 
219
} // namespace WebCore
 
220
 
 
221
#endif
 
222
#endif