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

Side by Side Diff: Source/core/html/forms/DateInputType.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 | « no previous file | Source/core/html/forms/DateTimeLocalInputType.cpp » ('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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 DateComponents::Type DateInputType::dateType() const 71 DateComponents::Type DateInputType::dateType() const
72 { 72 {
73 return DateComponents::Date; 73 return DateComponents::Date;
74 } 74 }
75 75
76 StepRange DateInputType::createStepRange(AnyStepHandling anyStepHandling) const 76 StepRange DateInputType::createStepRange(AnyStepHandling anyStepHandling) const
77 { 77 {
78 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (date DefaultStep, dateDefaultStepBase, dateStepScaleFactor, StepRange::ParsedStepValu eShouldBeInteger)); 78 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (date DefaultStep, dateDefaultStepBase, dateStepScaleFactor, StepRange::ParsedStepValu eShouldBeInteger));
79 79
80 const Decimal stepBase = findStepBase(0); 80 return InputType::createStepRange(anyStepHandling, 0, Decimal::fromDouble(Da teComponents::minimumDate()), Decimal::fromDouble(DateComponents::maximumDate()) , stepDescription);
81 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), D ecimal::fromDouble(DateComponents::minimumDate()));
82 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), D ecimal::fromDouble(DateComponents::maximumDate()));
83 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
84 return StepRange(stepBase, minimum, maximum, step, stepDescription);
85 } 81 }
86 82
87 bool DateInputType::parseToDateComponentsInternal(const String& string, DateComp onents* out) const 83 bool DateInputType::parseToDateComponentsInternal(const String& string, DateComp onents* out) const
88 { 84 {
89 ASSERT(out); 85 ASSERT(out);
90 unsigned end; 86 unsigned end;
91 return out->parseDate(string, 0, end) && end == string.length(); 87 return out->parseDate(string, 0, end) && end == string.length();
92 } 88 }
93 89
94 bool DateInputType::setMillisecondToDateComponents(double value, DateComponents* date) const 90 bool DateInputType::setMillisecondToDateComponents(double value, DateComponents* date) const
(...skipping 29 matching lines...) Expand all
124 layoutParameters.placeholderForYear = locale().queryString(WebLocalizedStrin g::PlaceholderForYearField); 120 layoutParameters.placeholderForYear = locale().queryString(WebLocalizedStrin g::PlaceholderForYearField);
125 } 121 }
126 122
127 bool DateInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, boo l hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const 123 bool DateInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, boo l hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
128 { 124 {
129 return hasYear && hasMonth && hasDay; 125 return hasYear && hasMonth && hasDay;
130 } 126 }
131 #endif 127 #endif
132 128
133 } // namespace WebCore 129 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/core/html/forms/DateTimeLocalInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698