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

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

Issue 108513007: Factor out common StepRange construction code. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/core/html/forms/DateInputType.cpp ('k') | Source/core/html/forms/InputType.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 void DateTimeLocalInputType::setValueAsDate(double value, ExceptionState& except ionState) const 79 void DateTimeLocalInputType::setValueAsDate(double value, ExceptionState& except ionState) const
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, exceptionState); 82 InputType::setValueAsDate(value, exceptionState);
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 = findStepBase(0); 89 return InputType::createStepRange(anyStepHandling, 0, Decimal::fromDouble(Da teComponents::minimumDateTime()), Decimal::fromDouble(DateComponents::maximumDat eTime()), stepDescription);
90 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), D ecimal::fromDouble(DateComponents::minimumDateTime()));
91 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), D ecimal::fromDouble(DateComponents::maximumDateTime()));
92 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
93 return StepRange(stepBase, minimum, maximum, step, stepDescription);
94 } 90 }
95 91
96 bool DateTimeLocalInputType::parseToDateComponentsInternal(const String& string, DateComponents* out) const 92 bool DateTimeLocalInputType::parseToDateComponentsInternal(const String& string, DateComponents* out) const
97 { 93 {
98 ASSERT(out); 94 ASSERT(out);
99 unsigned end; 95 unsigned end;
100 return out->parseDateTimeLocal(string, 0, end) && end == string.length(); 96 return out->parseDateTimeLocal(string, 0, end) && end == string.length();
101 } 97 }
102 98
103 bool DateTimeLocalInputType::setMillisecondToDateComponents(double value, DateCo mponents* date) const 99 bool DateTimeLocalInputType::setMillisecondToDateComponents(double value, DateCo mponents* date) const
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 layoutParameters.placeholderForYear = locale().queryString(WebLocalizedStrin g::PlaceholderForYearField); 163 layoutParameters.placeholderForYear = locale().queryString(WebLocalizedStrin g::PlaceholderForYearField);
168 } 164 }
169 165
170 bool DateTimeLocalInputType::isValidFormat(bool hasYear, bool hasMonth, bool has Week, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) c onst 166 bool DateTimeLocalInputType::isValidFormat(bool hasYear, bool hasMonth, bool has Week, bool hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) c onst
171 { 167 {
172 return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute; 168 return hasYear && hasMonth && hasDay && hasAMPM && hasHour && hasMinute;
173 } 169 }
174 #endif 170 #endif
175 171
176 } // namespace WebCore 172 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/DateInputType.cpp ('k') | Source/core/html/forms/InputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698