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

Unified Diff: Source/core/html/forms/RangeInputType.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: Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/html/forms/RangeInputType.cpp
diff --git a/Source/core/html/forms/RangeInputType.cpp b/Source/core/html/forms/RangeInputType.cpp
index b688e7462adfdf214b4134c490b632d94883bf93..5177ab18bd9700c4ce5cff745f88b68bdd32085b 100644
--- a/Source/core/html/forms/RangeInputType.cpp
+++ b/Source/core/html/forms/RangeInputType.cpp
@@ -124,8 +124,8 @@ StepRange RangeInputType::createStepRange(AnyStepHandling anyStepHandling) const
{
DEFINE_STATIC_LOCAL(const StepRange::StepDescription, stepDescription, (rangeDefaultStep, rangeDefaultStepBase, rangeStepScaleFactor));
- const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), rangeDefaultMinimum);
- const Decimal maximum = ensureMaximum(parseToNumber(element().fastGetAttribute(maxAttr), rangeDefaultMaximum), minimum, rangeDefaultMaximum);
+ const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), String(), rangeDefaultMinimum);
+ const Decimal maximum = ensureMaximum(parseToNumber(element().fastGetAttribute(maxAttr), String(), rangeDefaultMaximum), minimum, rangeDefaultMaximum);
const AtomicString& precisionValue = element().fastGetAttribute(precisionAttr);
if (!precisionValue.isNull()) {
@@ -259,8 +259,15 @@ RenderObject* RangeInputType::createRenderer(RenderStyle*) const
return new RenderSlider(&element());
}
-Decimal RangeInputType::parseToNumber(const String& src, const Decimal& defaultValue) const
+Decimal RangeInputType::parseToNumber(const String& src, const String& alternative, const Decimal& defaultValue) const
{
+ if (!alternative.isEmpty()) {
+ Decimal result = parseToDecimalForNumberType(src, Decimal::nan());
+ if (!result.isFinite())
+ result = parseToDecimalForNumberType(alternative, defaultValue);
+
+ return result;
+ }
return parseToDecimalForNumberType(src, defaultValue);
}
@@ -305,7 +312,7 @@ String RangeInputType::fallbackValue() const
String RangeInputType::sanitizeValue(const String& proposedValue) const
{
StepRange stepRange(createStepRange(RejectAny));
- const Decimal proposedNumericValue = parseToNumber(proposedValue, stepRange.defaultValue());
+ const Decimal proposedNumericValue = parseToNumber(proposedValue, String(), stepRange.defaultValue());
return serializeForNumberType(stepRange.clampValue(proposedNumericValue));
}
@@ -354,7 +361,7 @@ void RangeInputType::updateTickMarkValues()
String optionValue = optionElement->value();
if (!element().isValidValue(optionValue))
continue;
- m_tickMarkValues.append(parseToNumber(optionValue, Decimal::nan()));
+ m_tickMarkValues.append(parseToNumber(optionValue, String(), Decimal::nan()));
}
m_tickMarkValues.shrinkToFit();
nonCopyingSort(m_tickMarkValues.begin(), m_tickMarkValues.end(), decimalCompare);

Powered by Google App Engine
This is Rietveld 408576698