summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/StepRange.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/html/StepRange.cpp')
-rw-r--r--Source/WebCore/html/StepRange.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/WebCore/html/StepRange.cpp b/Source/WebCore/html/StepRange.cpp
index e7e548445..76d21dcae 100644
--- a/Source/WebCore/html/StepRange.cpp
+++ b/Source/WebCore/html/StepRange.cpp
@@ -24,6 +24,7 @@
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include <wtf/MathExtras.h>
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -34,7 +35,6 @@ StepRange::StepRange()
, m_minimum(0)
, m_step(1)
, m_stepBase(0)
- , m_hasStep(false)
{
}
@@ -44,16 +44,18 @@ StepRange::StepRange(const StepRange& stepRange)
, m_step(stepRange.m_step)
, m_stepBase(stepRange.m_stepBase)
, m_stepDescription(stepRange.m_stepDescription)
+ , m_hasRangeLimitations(stepRange.m_hasRangeLimitations)
, m_hasStep(stepRange.m_hasStep)
{
}
-StepRange::StepRange(const Decimal& stepBase, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription)
+StepRange::StepRange(const Decimal& stepBase, RangeLimitations rangeLimitations, const Decimal& minimum, const Decimal& maximum, const Decimal& step, const StepDescription& stepDescription)
: m_maximum(maximum)
, m_minimum(minimum)
, m_step(step.isFinite() ? step : 1)
, m_stepBase(stepBase.isFinite() ? stepBase : 1)
, m_stepDescription(stepDescription)
+ , m_hasRangeLimitations(rangeLimitations == RangeLimitations::Valid)
, m_hasStep(step.isFinite())
{
ASSERT(m_maximum.isFinite());
@@ -65,13 +67,13 @@ StepRange::StepRange(const Decimal& stepBase, const Decimal& minimum, const Deci
Decimal StepRange::acceptableError() const
{
// FIXME: We should use DBL_MANT_DIG instead of FLT_MANT_DIG regarding to HTML5 specification.
- DEFINE_STATIC_LOCAL(const Decimal, twoPowerOfFloatMantissaBits, (Decimal::Positive, 0, UINT64_C(1) << FLT_MANT_DIG));
+ static NeverDestroyed<const Decimal> twoPowerOfFloatMantissaBits(Decimal::Positive, 0, UINT64_C(1) << FLT_MANT_DIG);
return m_stepDescription.stepValueShouldBe == StepValueShouldBeReal ? m_step / twoPowerOfFloatMantissaBits : Decimal(0);
}
Decimal StepRange::alignValueForStep(const Decimal& currentValue, const Decimal& newValue) const
{
- DEFINE_STATIC_LOCAL(const Decimal, tenPowerOf21, (Decimal::Positive, 21, 1));
+ static NeverDestroyed<const Decimal> tenPowerOf21(Decimal::Positive, 21, 1);
if (newValue >= tenPowerOf21)
return newValue;
@@ -96,7 +98,7 @@ Decimal StepRange::parseStep(AnyStepHandling anyStepHandling, const StepDescript
if (stepString.isEmpty())
return stepDescription.defaultValue();
- if (equalIgnoringCase(stepString, "any")) {
+ if (equalLettersIgnoringASCIICase(stepString, "any")) {
switch (anyStepHandling) {
case RejectAny:
return Decimal::nan();
@@ -150,7 +152,7 @@ bool StepRange::stepMismatch(const Decimal& valueForCheck) const
// Decimal's fractional part size is DBL_MAN_DIG-bit. If the current value
// is greater than step*2^DBL_MANT_DIG, the following computation for
// remainder makes no sense.
- DEFINE_STATIC_LOCAL(const Decimal, twoPowerOfDoubleMantissaBits, (Decimal::Positive, 0, UINT64_C(1) << DBL_MANT_DIG));
+ static NeverDestroyed<const Decimal> twoPowerOfDoubleMantissaBits(Decimal::Positive, 0, UINT64_C(1) << DBL_MANT_DIG);
if (value / twoPowerOfDoubleMantissaBits > m_step)
return false;
// The computation follows HTML5 4.10.7.2.10 `The step attribute' :