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

Side by Side Diff: Source/core/html/forms/NumberInputType.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/MonthInputType.cpp ('k') | Source/core/html/forms/TimeInputType.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 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * Copyright (C) 2011 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 bool NumberInputType::typeMismatch() const 151 bool NumberInputType::typeMismatch() const
152 { 152 {
153 ASSERT(!typeMismatchFor(element().value())); 153 ASSERT(!typeMismatchFor(element().value()));
154 return false; 154 return false;
155 } 155 }
156 156
157 StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) cons t 157 StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) cons t
158 { 158 {
159 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (numb erDefaultStep, numberDefaultStepBase, numberStepScaleFactor)); 159 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (numb erDefaultStep, numberDefaultStepBase, numberStepScaleFactor));
160 const Decimal stepBase = findStepBase(numberDefaultStepBase); 160
161 // FIXME: We should use numeric_limits<double>::max for number input type. 161 // FIXME: We should use numeric_limits<double>::max for number input type.
162 const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max()); 162 const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max());
163 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), - floatMax); 163 return InputType::createStepRange(anyStepHandling, numberDefaultStepBase, -f loatMax, floatMax, stepDescription);
164 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), f loatMax);
165 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
166 return StepRange(stepBase, minimum, maximum, step, stepDescription);
167 } 164 }
168 165
169 bool NumberInputType::sizeShouldIncludeDecoration(int defaultSize, int& preferre dSize) const 166 bool NumberInputType::sizeShouldIncludeDecoration(int defaultSize, int& preferre dSize) const
170 { 167 {
171 preferredSize = defaultSize; 168 preferredSize = defaultSize;
172 169
173 const String stepString = element().fastGetAttribute(stepAttr); 170 const String stepString = element().fastGetAttribute(stepAttr);
174 if (equalIgnoringCase(stepString, "any")) 171 if (equalIgnoringCase(stepString, "any"))
175 return false; 172 return false;
176 173
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 296
300 void NumberInputType::stepAttributeChanged() 297 void NumberInputType::stepAttributeChanged()
301 { 298 {
302 InputType::stepAttributeChanged(); 299 InputType::stepAttributeChanged();
303 300
304 if (element().renderer()) 301 if (element().renderer())
305 element().renderer()->setNeedsLayoutAndPrefWidthsRecalc(); 302 element().renderer()->setNeedsLayoutAndPrefWidthsRecalc();
306 } 303 }
307 304
308 } // namespace WebCore 305 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/forms/MonthInputType.cpp ('k') | Source/core/html/forms/TimeInputType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698