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

Side by Side Diff: Source/core/html/forms/WeekInputType.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/TimeInputType.cpp ('k') | no next file » | 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 65
66 DateComponents::Type WeekInputType::dateType() const 66 DateComponents::Type WeekInputType::dateType() const
67 { 67 {
68 return DateComponents::Week; 68 return DateComponents::Week;
69 } 69 }
70 70
71 StepRange WeekInputType::createStepRange(AnyStepHandling anyStepHandling) const 71 StepRange WeekInputType::createStepRange(AnyStepHandling anyStepHandling) const
72 { 72 {
73 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (week DefaultStep, weekDefaultStepBase, weekStepScaleFactor, StepRange::ParsedStepValu eShouldBeInteger)); 73 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (week DefaultStep, weekDefaultStepBase, weekStepScaleFactor, StepRange::ParsedStepValu eShouldBeInteger));
74 74
75 const Decimal stepBase = findStepBase(weekDefaultStepBase); 75 return InputType::createStepRange(anyStepHandling, weekDefaultStepBase, Deci mal::fromDouble(DateComponents::minimumWeek()), Decimal::fromDouble(DateComponen ts::maximumWeek()), stepDescription);
76 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), D ecimal::fromDouble(DateComponents::minimumWeek()));
77 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), D ecimal::fromDouble(DateComponents::maximumWeek()));
78 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
79 return StepRange(stepBase, minimum, maximum, step, stepDescription);
80 } 76 }
81 77
82 bool WeekInputType::parseToDateComponentsInternal(const String& string, DateComp onents* out) const 78 bool WeekInputType::parseToDateComponentsInternal(const String& string, DateComp onents* out) const
83 { 79 {
84 ASSERT(out); 80 ASSERT(out);
85 unsigned end; 81 unsigned end;
86 return out->parseWeek(string, 0, end) && end == string.length(); 82 return out->parseWeek(string, 0, end) && end == string.length();
87 } 83 }
88 84
89 bool WeekInputType::setMillisecondToDateComponents(double value, DateComponents* date) const 85 bool WeekInputType::setMillisecondToDateComponents(double value, DateComponents* date) const
(...skipping 27 matching lines...) Expand all
117 layoutParameters.placeholderForYear = "----"; 113 layoutParameters.placeholderForYear = "----";
118 } 114 }
119 115
120 bool WeekInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, boo l hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const 116 bool WeekInputType::isValidFormat(bool hasYear, bool hasMonth, bool hasWeek, boo l hasDay, bool hasAMPM, bool hasHour, bool hasMinute, bool hasSecond) const
121 { 117 {
122 return hasYear && hasWeek; 118 return hasYear && hasWeek;
123 } 119 }
124 #endif 120 #endif
125 121
126 } // namespace WebCore 122 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/TimeInputType.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698