OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 namespace WebCore { | 44 namespace WebCore { |
45 | 45 |
46 using WebKit::WebLocalizedString; | 46 using WebKit::WebLocalizedString; |
47 using namespace HTMLNames; | 47 using namespace HTMLNames; |
48 | 48 |
49 static const int dateTimeLocalDefaultStep = 60; | 49 static const int dateTimeLocalDefaultStep = 60; |
50 static const int dateTimeLocalDefaultStepBase = 0; | 50 static const int dateTimeLocalDefaultStepBase = 0; |
51 static const int dateTimeLocalStepScaleFactor = 1000; | 51 static const int dateTimeLocalStepScaleFactor = 1000; |
52 | 52 |
53 PassRefPtr<InputType> DateTimeLocalInputType::create(HTMLInputElement* element) | 53 PassRefPtr<InputType> DateTimeLocalInputType::create(HTMLInputElement& element) |
54 { | 54 { |
55 return adoptRef(new DateTimeLocalInputType(element)); | 55 return adoptRef(new DateTimeLocalInputType(element)); |
56 } | 56 } |
57 | 57 |
58 void DateTimeLocalInputType::countUsage() | 58 void DateTimeLocalInputType::countUsage() |
59 { | 59 { |
60 observeFeatureIfVisible(UseCounter::InputTypeDateTimeLocal); | 60 observeFeatureIfVisible(UseCounter::InputTypeDateTimeLocal); |
61 } | 61 } |
62 | 62 |
63 const AtomicString& DateTimeLocalInputType::formControlType() const | 63 const AtomicString& DateTimeLocalInputType::formControlType() const |
(...skipping 15 matching lines...) Expand all Loading... |
79 void DateTimeLocalInputType::setValueAsDate(double value, ExceptionState& es) co
nst | 79 void DateTimeLocalInputType::setValueAsDate(double value, ExceptionState& es) co
nst |
80 { | 80 { |
81 // valueAsDate doesn't work for the datetime-local type according to the sta
ndard. | 81 // valueAsDate doesn't work for the datetime-local type according to the sta
ndard. |
82 InputType::setValueAsDate(value, es); | 82 InputType::setValueAsDate(value, es); |
83 } | 83 } |
84 | 84 |
85 StepRange DateTimeLocalInputType::createStepRange(AnyStepHandling anyStepHandlin
g) const | 85 StepRange DateTimeLocalInputType::createStepRange(AnyStepHandling anyStepHandlin
g) const |
86 { | 86 { |
87 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (date
TimeLocalDefaultStep, dateTimeLocalDefaultStepBase, dateTimeLocalStepScaleFactor
, StepRange::ScaledStepValueShouldBeInteger)); | 87 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (date
TimeLocalDefaultStep, dateTimeLocalDefaultStepBase, dateTimeLocalStepScaleFactor
, StepRange::ScaledStepValueShouldBeInteger)); |
88 | 88 |
89 const Decimal stepBase = parseToNumber(element()->fastGetAttribute(minAttr),
0); | 89 const Decimal stepBase = parseToNumber(element().fastGetAttribute(minAttr),
0); |
90 const Decimal minimum = parseToNumber(element()->fastGetAttribute(minAttr),
Decimal::fromDouble(DateComponents::minimumDateTime())); | 90 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), D
ecimal::fromDouble(DateComponents::minimumDateTime())); |
91 const Decimal maximum = parseToNumber(element()->fastGetAttribute(maxAttr),
Decimal::fromDouble(DateComponents::maximumDateTime())); | 91 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), D
ecimal::fromDouble(DateComponents::maximumDateTime())); |
92 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription,
element()->fastGetAttribute(stepAttr)); | 92 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription,
element().fastGetAttribute(stepAttr)); |
93 return StepRange(stepBase, minimum, maximum, step, stepDescription); | 93 return StepRange(stepBase, minimum, maximum, step, stepDescription); |
94 } | 94 } |
95 | 95 |
96 bool DateTimeLocalInputType::parseToDateComponentsInternal(const String& string,
DateComponents* out) const | 96 bool DateTimeLocalInputType::parseToDateComponentsInternal(const String& string,
DateComponents* out) const |
97 { | 97 { |
98 ASSERT(out); | 98 ASSERT(out); |
99 unsigned end; | 99 unsigned end; |
100 return out->parseDateTimeLocal(string, 0, end) && end == string.length(); | 100 return out->parseDateTimeLocal(string, 0, end) && end == string.length(); |
101 } | 101 } |
102 | 102 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 void DateTimeLocalInputType::setupLayoutParameters(DateTimeEditElement::LayoutPa
rameters& layoutParameters, const DateComponents& date) const | 152 void DateTimeLocalInputType::setupLayoutParameters(DateTimeEditElement::LayoutPa
rameters& layoutParameters, const DateComponents& date) const |
153 { | 153 { |
154 if (shouldHaveSecondField(date)) { | 154 if (shouldHaveSecondField(date)) { |
155 layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormat
WithSeconds(); | 155 layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormat
WithSeconds(); |
156 layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss"; | 156 layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm:ss"; |
157 } else { | 157 } else { |
158 layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormat
WithoutSeconds(); | 158 layoutParameters.dateTimeFormat = layoutParameters.locale.dateTimeFormat
WithoutSeconds(); |
159 layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm"; | 159 layoutParameters.fallbackDateTimeFormat = "yyyy-MM-dd'T'HH:mm"; |
160 } | 160 } |
161 if (!parseToDateComponents(element()->fastGetAttribute(minAttr), &layoutPara
meters.minimum)) | 161 if (!parseToDateComponents(element().fastGetAttribute(minAttr), &layoutParam
eters.minimum)) |
162 layoutParameters.minimum = DateComponents(); | 162 layoutParameters.minimum = DateComponents(); |
163 if (!parseToDateComponents(element()->fastGetAttribute(maxAttr), &layoutPara
meters.maximum)) | 163 if (!parseToDateComponents(element().fastGetAttribute(maxAttr), &layoutParam
eters.maximum)) |
164 layoutParameters.maximum = DateComponents(); | 164 layoutParameters.maximum = DateComponents(); |
165 layoutParameters.placeholderForDay = locale().queryString(WebLocalizedString
::PlaceholderForDayOfMonthField); | 165 layoutParameters.placeholderForDay = locale().queryString(WebLocalizedString
::PlaceholderForDayOfMonthField); |
166 layoutParameters.placeholderForMonth = locale().queryString(WebLocalizedStri
ng::PlaceholderForMonthField); | 166 layoutParameters.placeholderForMonth = locale().queryString(WebLocalizedStri
ng::PlaceholderForMonthField); |
167 layoutParameters.placeholderForYear = locale().queryString(WebLocalizedStrin
g::PlaceholderForYearField); | 167 layoutParameters.placeholderForYear = locale().queryString(WebLocalizedStrin
g::PlaceholderForYearField); |
168 } | 168 } |
169 | 169 |
170 bool DateTimeLocalInputType::isValidFormat(bool hasYear, bool hasMonth, bool has
Week, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) c
onst | 170 bool DateTimeLocalInputType::isValidFormat(bool hasYear, bool hasMonth, bool has
Week, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) c
onst |
171 { | 171 { |
172 return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute; | 172 return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute; |
173 } | 173 } |
174 #endif | 174 #endif |
175 | 175 |
176 } // namespace WebCore | 176 } // namespace WebCore |
OLD | NEW |