Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: Source/core/html/forms/MonthInputType.cpp

Issue 83413002: Derive the step base for an input element as (now) specified. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Perform step base derivation via InputType::findStepBase() instead Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 = parseToNumber(element().fastGetAttribute(minAttr), Decimal::fromDouble(monthDefaultStepBase)); 111 const Decimal stepBase = findStepBase(Decimal::fromDouble(monthDefaultStepBa se));
112 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), D ecimal::fromDouble(DateComponents::minimumMonth())); 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())); 113 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), D ecimal::fromDouble(DateComponents::maximumMonth()));
114 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 114 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
115 return StepRange(stepBase, minimum, maximum, step, stepDescription); 115 return StepRange(stepBase, minimum, maximum, step, stepDescription);
116 } 116 }
117 117
118 Decimal MonthInputType::parseToNumber(const String& src, const Decimal& defaultV alue) const 118 Decimal MonthInputType::parseToNumber(const String& src, const Decimal& defaultV alue) const
119 { 119 {
120 DateComponents date; 120 DateComponents date;
121 if (!parseToDateComponents(src, &date)) 121 if (!parseToDateComponents(src, &date))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 layoutParameters.placeholderForMonth = "--"; 162 layoutParameters.placeholderForMonth = "--";
163 layoutParameters.placeholderForYear = "----"; 163 layoutParameters.placeholderForYear = "----";
164 } 164 }
165 165
166 bool MonthInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bo ol hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const 166 bool MonthInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, bo ol hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
167 { 167 {
168 return hasYear && hasMonth; 168 return hasYear && hasMonth;
169 } 169 }
170 #endif 170 #endif
171 } // namespace WebCore 171 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698