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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 date.setMillisecondsSinceEpochForMonth(current); | 101 date.setMillisecondsSinceEpochForMonth(current); |
102 double months = date.monthsSinceEpoch(); | 102 double months = date.monthsSinceEpoch(); |
103 ASSERT(std::isfinite(months)); | 103 ASSERT(std::isfinite(months)); |
104 return Decimal::fromDouble(months); | 104 return Decimal::fromDouble(months); |
105 } | 105 } |
106 | 106 |
107 StepRange MonthInputType::createStepRange(AnyStepHandling anyStepHandling) const | 107 StepRange MonthInputType::createStepRange(AnyStepHandling anyStepHandling) const |
108 { | 108 { |
109 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (mont
hDefaultStep, monthDefaultStepBase, monthStepScaleFactor, StepRange::ParsedStepV
alueShouldBeInteger)); | 109 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (mont
hDefaultStep, monthDefaultStepBase, monthStepScaleFactor, StepRange::ParsedStepV
alueShouldBeInteger)); |
110 | 110 |
111 const Decimal stepBase = findStepBase(Decimal::fromDouble(monthDefaultStepBa
se)); | 111 return InputType::createStepRange(anyStepHandling, Decimal::fromDouble(month
DefaultStepBase), Decimal::fromDouble(DateComponents::minimumMonth()), Decimal::
fromDouble(DateComponents::maximumMonth()), stepDescription); |
112 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), D
ecimal::fromDouble(DateComponents::minimumMonth())); | |
113 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), D
ecimal::fromDouble(DateComponents::maximumMonth())); | |
114 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription,
element().fastGetAttribute(stepAttr)); | |
115 return StepRange(stepBase, minimum, maximum, step, stepDescription); | |
116 } | 112 } |
117 | 113 |
118 Decimal MonthInputType::parseToNumber(const String& src, const Decimal& defaultV
alue) const | 114 Decimal MonthInputType::parseToNumber(const String& src, const Decimal& defaultV
alue) const |
119 { | 115 { |
120 DateComponents date; | 116 DateComponents date; |
121 if (!parseToDateComponents(src, &date)) | 117 if (!parseToDateComponents(src, &date)) |
122 return defaultValue; | 118 return defaultValue; |
123 double months = date.monthsSinceEpoch(); | 119 double months = date.monthsSinceEpoch(); |
124 ASSERT(std::isfinite(months)); | 120 ASSERT(std::isfinite(months)); |
125 return Decimal::fromDouble(months); | 121 return Decimal::fromDouble(months); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 layoutParameters.placeholderForMonth = "--"; | 158 layoutParameters.placeholderForMonth = "--"; |
163 layoutParameters.placeholderForYear = "----"; | 159 layoutParameters.placeholderForYear = "----"; |
164 } | 160 } |
165 | 161 |
166 bool MonthInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bo
ol hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const | 162 bool MonthInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bo
ol hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const |
167 { | 163 { |
168 return hasYear && hasMonth; | 164 return hasYear && hasMonth; |
169 } | 165 } |
170 #endif | 166 #endif |
171 } // namespace WebCore | 167 } // namespace WebCore |
OLD | NEW |