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

Side by Side Diff: Source/core/html/forms/NumberInputType.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 * 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 bool NumberInputType::typeMismatch() const 159 bool NumberInputType::typeMismatch() const
160 { 160 {
161 ASSERT(!typeMismatchFor(element().value())); 161 ASSERT(!typeMismatchFor(element().value()));
162 return false; 162 return false;
163 } 163 }
164 164
165 StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) cons t 165 StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) cons t
166 { 166 {
167 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (numb erDefaultStep, numberDefaultStepBase, numberStepScaleFactor)); 167 DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (numb erDefaultStep, numberDefaultStepBase, numberStepScaleFactor));
168 const Decimal stepBase = parseToDecimalForNumberType(element().fastGetAttrib ute(minAttr), numberDefaultStepBase); 168 const Decimal stepBase = findStepBase(numberDefaultStepBase);
169 // FIXME: We should use numeric_limits<double>::max for number input type. 169 // FIXME: We should use numeric_limits<double>::max for number input type.
170 const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max()); 170 const Decimal floatMax = Decimal::fromDouble(numeric_limits<float>::max());
171 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), - floatMax); 171 const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), - floatMax);
172 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), f loatMax); 172 const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), f loatMax);
173 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr)); 173 const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
174 return StepRange(stepBase, minimum, maximum, step, stepDescription); 174 return StepRange(stepBase, minimum, maximum, step, stepDescription);
175 } 175 }
176 176
177 bool NumberInputType::sizeShouldIncludeDecoration(int defaultSize, int& preferre dSize) const 177 bool NumberInputType::sizeShouldIncludeDecoration(int defaultSize, int& preferre dSize) const
178 { 178 {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 307
308 void NumberInputType::stepAttributeChanged() 308 void NumberInputType::stepAttributeChanged()
309 { 309 {
310 InputType::stepAttributeChanged(); 310 InputType::stepAttributeChanged();
311 311
312 if (element().renderer()) 312 if (element().renderer())
313 element().renderer()->setNeedsLayoutAndPrefWidthsRecalc(); 313 element().renderer()->setNeedsLayoutAndPrefWidthsRecalc();
314 } 314 }
315 315
316 } // namespace WebCore 316 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698