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

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

Issue 2048943002: Fix an assertion failure in InputType::applyStep() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/StepRange.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/StepRange.cpp b/third_party/WebKit/Source/core/html/forms/StepRange.cpp
index 252ff6083e264bb9a7912b0e2ae5a45681bb170f..b1769b3ab5607f634185a40da82dd5d07c50b9ff 100644
--- a/third_party/WebKit/Source/core/html/forms/StepRange.cpp
+++ b/third_party/WebKit/Source/core/html/forms/StepRange.cpp
@@ -168,4 +168,19 @@ bool StepRange::stepMismatch(const Decimal& valueForCheck) const
return computedAcceptableError < remainder && remainder < (m_step - computedAcceptableError);
}
+Decimal StepRange::stepSnappedMaximum() const
+{
+ Decimal base = stepBase();
+ Decimal step = this->step();
+ if (base - step == base || !(base / step).isFinite())
+ return Decimal::nan();
+ Decimal alignedMaximum = base + ((maximum() - base) / step).floor() * step;
+ if (alignedMaximum > maximum())
+ alignedMaximum -= step;
+ DCHECK_LE(alignedMaximum, maximum());
+ if (alignedMaximum < minimum())
+ return Decimal::nan();
+ return alignedMaximum;
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/forms/StepRange.h ('k') | third_party/WebKit/Source/core/html/forms/StepRangeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698