| OLD | NEW |
| (Empty) |
| 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 #include "core/html/shadow/DateTimeNumericFieldElement.h" | |
| 30 #include "core/html/shadow/DateTimeSymbolicFieldElement.h" | |
| 31 #include "platform/wtf/Allocator.h" | |
| 32 | |
| 33 namespace blink { | |
| 34 | |
| 35 class DateTimeAMPMFieldElement final : public DateTimeSymbolicFieldElement { | |
| 36 WTF_MAKE_NONCOPYABLE(DateTimeAMPMFieldElement); | |
| 37 | |
| 38 public: | |
| 39 static DateTimeAMPMFieldElement* Create(Document&, | |
| 40 FieldOwner&, | |
| 41 const Vector<String>&); | |
| 42 | |
| 43 private: | |
| 44 DateTimeAMPMFieldElement(Document&, FieldOwner&, const Vector<String>&); | |
| 45 | |
| 46 // DateTimeFieldElement functions. | |
| 47 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 48 void SetValueAsDate(const DateComponents&) override; | |
| 49 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 50 }; | |
| 51 | |
| 52 class DateTimeDayFieldElement final : public DateTimeNumericFieldElement { | |
| 53 WTF_MAKE_NONCOPYABLE(DateTimeDayFieldElement); | |
| 54 | |
| 55 public: | |
| 56 static DateTimeDayFieldElement* Create(Document&, | |
| 57 FieldOwner&, | |
| 58 const String& placeholder, | |
| 59 const Range&); | |
| 60 | |
| 61 private: | |
| 62 DateTimeDayFieldElement(Document&, | |
| 63 FieldOwner&, | |
| 64 const String& placeholder, | |
| 65 const Range&); | |
| 66 | |
| 67 // DateTimeFieldElement functions. | |
| 68 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 69 void SetValueAsDate(const DateComponents&) override; | |
| 70 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 71 }; | |
| 72 | |
| 73 class DateTimeHourFieldElementBase : public DateTimeNumericFieldElement { | |
| 74 WTF_MAKE_NONCOPYABLE(DateTimeHourFieldElementBase); | |
| 75 | |
| 76 protected: | |
| 77 DateTimeHourFieldElementBase(Document&, | |
| 78 FieldOwner&, | |
| 79 const Range&, | |
| 80 const Range& hard_limits, | |
| 81 const Step&); | |
| 82 void Initialize(); | |
| 83 | |
| 84 private: | |
| 85 // DateTimeFieldElement functions. | |
| 86 void SetValueAsDate(const DateComponents&) override; | |
| 87 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 88 }; | |
| 89 | |
| 90 class DateTimeHour11FieldElement final : public DateTimeHourFieldElementBase { | |
| 91 WTF_MAKE_NONCOPYABLE(DateTimeHour11FieldElement); | |
| 92 | |
| 93 public: | |
| 94 static DateTimeHour11FieldElement* Create(Document&, | |
| 95 FieldOwner&, | |
| 96 const Range&, | |
| 97 const Step&); | |
| 98 | |
| 99 private: | |
| 100 DateTimeHour11FieldElement(Document&, | |
| 101 FieldOwner&, | |
| 102 const Range& hour23_range, | |
| 103 const Step&); | |
| 104 | |
| 105 // DateTimeFieldElement functions. | |
| 106 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 107 void SetValueAsInteger(int, EventBehavior = kDispatchNoEvent) override; | |
| 108 }; | |
| 109 | |
| 110 class DateTimeHour12FieldElement final : public DateTimeHourFieldElementBase { | |
| 111 WTF_MAKE_NONCOPYABLE(DateTimeHour12FieldElement); | |
| 112 | |
| 113 public: | |
| 114 static DateTimeHour12FieldElement* Create(Document&, | |
| 115 FieldOwner&, | |
| 116 const Range&, | |
| 117 const Step&); | |
| 118 | |
| 119 private: | |
| 120 DateTimeHour12FieldElement(Document&, | |
| 121 FieldOwner&, | |
| 122 const Range& hour23_range, | |
| 123 const Step&); | |
| 124 | |
| 125 // DateTimeFieldElement functions. | |
| 126 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 127 void SetValueAsInteger(int, EventBehavior = kDispatchNoEvent) override; | |
| 128 }; | |
| 129 | |
| 130 class DateTimeHour23FieldElement final : public DateTimeHourFieldElementBase { | |
| 131 WTF_MAKE_NONCOPYABLE(DateTimeHour23FieldElement); | |
| 132 | |
| 133 public: | |
| 134 static DateTimeHour23FieldElement* Create(Document&, | |
| 135 FieldOwner&, | |
| 136 const Range&, | |
| 137 const Step&); | |
| 138 | |
| 139 private: | |
| 140 DateTimeHour23FieldElement(Document&, | |
| 141 FieldOwner&, | |
| 142 const Range& hour23_range, | |
| 143 const Step&); | |
| 144 | |
| 145 // DateTimeFieldElement functions. | |
| 146 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 147 void SetValueAsInteger(int, EventBehavior = kDispatchNoEvent) override; | |
| 148 }; | |
| 149 | |
| 150 class DateTimeHour24FieldElement final : public DateTimeHourFieldElementBase { | |
| 151 WTF_MAKE_NONCOPYABLE(DateTimeHour24FieldElement); | |
| 152 | |
| 153 public: | |
| 154 static DateTimeHour24FieldElement* Create(Document&, | |
| 155 FieldOwner&, | |
| 156 const Range&, | |
| 157 const Step&); | |
| 158 | |
| 159 private: | |
| 160 DateTimeHour24FieldElement(Document&, | |
| 161 FieldOwner&, | |
| 162 const Range& hour23_range, | |
| 163 const Step&); | |
| 164 | |
| 165 // DateTimeFieldElement functions. | |
| 166 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 167 void SetValueAsInteger(int, EventBehavior = kDispatchNoEvent) override; | |
| 168 }; | |
| 169 | |
| 170 class DateTimeMillisecondFieldElement final | |
| 171 : public DateTimeNumericFieldElement { | |
| 172 WTF_MAKE_NONCOPYABLE(DateTimeMillisecondFieldElement); | |
| 173 | |
| 174 public: | |
| 175 static DateTimeMillisecondFieldElement* Create(Document&, | |
| 176 FieldOwner&, | |
| 177 const Range&, | |
| 178 const Step&); | |
| 179 | |
| 180 private: | |
| 181 DateTimeMillisecondFieldElement(Document&, | |
| 182 FieldOwner&, | |
| 183 const Range&, | |
| 184 const Step&); | |
| 185 | |
| 186 // DateTimeFieldElement functions. | |
| 187 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 188 void SetValueAsDate(const DateComponents&) override; | |
| 189 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 190 }; | |
| 191 | |
| 192 class DateTimeMinuteFieldElement final : public DateTimeNumericFieldElement { | |
| 193 WTF_MAKE_NONCOPYABLE(DateTimeMinuteFieldElement); | |
| 194 | |
| 195 public: | |
| 196 static DateTimeMinuteFieldElement* Create(Document&, | |
| 197 FieldOwner&, | |
| 198 const Range&, | |
| 199 const Step&); | |
| 200 | |
| 201 private: | |
| 202 DateTimeMinuteFieldElement(Document&, FieldOwner&, const Range&, const Step&); | |
| 203 | |
| 204 // DateTimeFieldElement functions. | |
| 205 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 206 void SetValueAsDate(const DateComponents&) override; | |
| 207 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 208 }; | |
| 209 | |
| 210 class DateTimeMonthFieldElement final : public DateTimeNumericFieldElement { | |
| 211 WTF_MAKE_NONCOPYABLE(DateTimeMonthFieldElement); | |
| 212 | |
| 213 public: | |
| 214 static DateTimeMonthFieldElement* Create(Document&, | |
| 215 FieldOwner&, | |
| 216 const String& placeholder, | |
| 217 const Range&); | |
| 218 | |
| 219 private: | |
| 220 DateTimeMonthFieldElement(Document&, | |
| 221 FieldOwner&, | |
| 222 const String& placeholder, | |
| 223 const Range&); | |
| 224 | |
| 225 // DateTimeFieldElement functions. | |
| 226 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 227 void SetValueAsDate(const DateComponents&) override; | |
| 228 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 229 }; | |
| 230 | |
| 231 class DateTimeSecondFieldElement final : public DateTimeNumericFieldElement { | |
| 232 WTF_MAKE_NONCOPYABLE(DateTimeSecondFieldElement); | |
| 233 | |
| 234 public: | |
| 235 static DateTimeSecondFieldElement* Create(Document&, | |
| 236 FieldOwner&, | |
| 237 const Range&, | |
| 238 const Step&); | |
| 239 | |
| 240 private: | |
| 241 DateTimeSecondFieldElement(Document&, FieldOwner&, const Range&, const Step&); | |
| 242 | |
| 243 // DateTimeFieldElement functions. | |
| 244 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 245 void SetValueAsDate(const DateComponents&) override; | |
| 246 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 247 }; | |
| 248 | |
| 249 class DateTimeSymbolicMonthFieldElement final | |
| 250 : public DateTimeSymbolicFieldElement { | |
| 251 WTF_MAKE_NONCOPYABLE(DateTimeSymbolicMonthFieldElement); | |
| 252 | |
| 253 public: | |
| 254 static DateTimeSymbolicMonthFieldElement* Create(Document&, | |
| 255 FieldOwner&, | |
| 256 const Vector<String>&, | |
| 257 int minimum, | |
| 258 int maximum); | |
| 259 | |
| 260 private: | |
| 261 DateTimeSymbolicMonthFieldElement(Document&, | |
| 262 FieldOwner&, | |
| 263 const Vector<String>&, | |
| 264 int minimum, | |
| 265 int maximum); | |
| 266 | |
| 267 // DateTimeFieldElement functions. | |
| 268 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 269 void SetValueAsDate(const DateComponents&) override; | |
| 270 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 271 }; | |
| 272 | |
| 273 class DateTimeWeekFieldElement final : public DateTimeNumericFieldElement { | |
| 274 WTF_MAKE_NONCOPYABLE(DateTimeWeekFieldElement); | |
| 275 | |
| 276 public: | |
| 277 static DateTimeWeekFieldElement* Create(Document&, FieldOwner&, const Range&); | |
| 278 | |
| 279 private: | |
| 280 DateTimeWeekFieldElement(Document&, FieldOwner&, const Range&); | |
| 281 | |
| 282 // DateTimeFieldElement functions. | |
| 283 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 284 void SetValueAsDate(const DateComponents&) override; | |
| 285 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 286 }; | |
| 287 | |
| 288 class DateTimeYearFieldElement final : public DateTimeNumericFieldElement { | |
| 289 WTF_MAKE_NONCOPYABLE(DateTimeYearFieldElement); | |
| 290 | |
| 291 public: | |
| 292 struct Parameters { | |
| 293 STACK_ALLOCATED(); | |
| 294 int minimum_year; | |
| 295 int maximum_year; | |
| 296 bool min_is_specified; | |
| 297 bool max_is_specified; | |
| 298 String placeholder; | |
| 299 | |
| 300 Parameters() | |
| 301 : minimum_year(-1), | |
| 302 maximum_year(-1), | |
| 303 min_is_specified(false), | |
| 304 max_is_specified(false) {} | |
| 305 }; | |
| 306 | |
| 307 static DateTimeYearFieldElement* Create(Document&, | |
| 308 FieldOwner&, | |
| 309 const Parameters&); | |
| 310 | |
| 311 private: | |
| 312 DateTimeYearFieldElement(Document&, FieldOwner&, const Parameters&); | |
| 313 | |
| 314 // DateTimeFieldElement functions. | |
| 315 void PopulateDateTimeFieldsState(DateTimeFieldsState&) override; | |
| 316 void SetValueAsDate(const DateComponents&) override; | |
| 317 void SetValueAsDateTimeFieldsState(const DateTimeFieldsState&) override; | |
| 318 | |
| 319 // DateTimeNumericFieldElement functions. | |
| 320 int DefaultValueForStepDown() const override; | |
| 321 int DefaultValueForStepUp() const override; | |
| 322 | |
| 323 bool min_is_specified_; | |
| 324 bool max_is_specified_; | |
| 325 }; | |
| 326 | |
| 327 } // namespace blink | |
| 328 | |
| 329 #endif | |
| OLD | NEW |