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

Unified Diff: third_party/WebKit/Source/core/html/forms/InputType.cpp

Issue 2033323002: :in-range and :out-of-range CSS selectors should check 'have range limitations.' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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: third_party/WebKit/Source/core/html/forms/InputType.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/InputType.cpp b/third_party/WebKit/Source/core/html/forms/InputType.cpp
index 6bd906c44da9206a8fccdf1e212155671a42649e..5e88d20f06163d16beb9455f7b7881d317176e4a 100644
--- a/third_party/WebKit/Source/core/html/forms/InputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/InputType.cpp
@@ -292,7 +292,7 @@ bool InputType::isInRange(const String& value) const
return true;
StepRange stepRange(createStepRange(RejectAny));
- return numericValue >= stepRange.minimum() && numericValue <= stepRange.maximum();
+ return stepRange.hasRangeLimitations() && numericValue >= stepRange.minimum() && numericValue <= stepRange.maximum();
}
bool InputType::isOutOfRange(const String& value) const
@@ -308,7 +308,7 @@ bool InputType::isOutOfRange(const String& value) const
return false;
StepRange stepRange(createStepRange(RejectAny));
- return numericValue < stepRange.minimum() || numericValue > stepRange.maximum();
+ return stepRange.hasRangeLimitations() && (numericValue < stepRange.minimum() || numericValue > stepRange.maximum());
}
bool InputType::stepMismatch(const String& value) const
@@ -921,11 +921,20 @@ Decimal InputType::findStepBase(const Decimal& defaultValue) const
StepRange InputType::createStepRange(AnyStepHandling anyStepHandling, const Decimal& stepBaseDefault, const Decimal& minimumDefault, const Decimal& maximumDefault, const StepRange::StepDescription& stepDescription) const
{
+ bool hasRangeLimitations = false;
const Decimal stepBase = findStepBase(stepBaseDefault);
- const Decimal minimum = parseToNumber(element().fastGetAttribute(minAttr), minimumDefault);
- const Decimal maximum = parseToNumber(element().fastGetAttribute(maxAttr), maximumDefault);
+ Decimal minimum = parseToNumberOrNaN(element().fastGetAttribute(minAttr));
+ if (minimum.isFinite())
+ hasRangeLimitations = true;
+ else
+ minimum = minimumDefault;
+ Decimal maximum = parseToNumberOrNaN(element().fastGetAttribute(maxAttr));
+ if (maximum.isFinite())
+ hasRangeLimitations = true;
+ else
+ maximum = maximumDefault;
const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element().fastGetAttribute(stepAttr));
- return StepRange(stepBase, minimum, maximum, step, stepDescription);
+ return StepRange(stepBase, minimum, maximum, hasRangeLimitations, step, stepDescription);
}
void InputType::addWarningToConsole(const char* messageFormat, const String& value) const

Powered by Google App Engine
This is Rietveld 408576698