summaryrefslogtreecommitdiff
path: root/Source/WebCore/html/StepRange.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/html/StepRange.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/html/StepRange.cpp')
-rw-r--r--Source/WebCore/html/StepRange.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/Source/WebCore/html/StepRange.cpp b/Source/WebCore/html/StepRange.cpp
index 4d0042f24..c0cb4fe1d 100644
--- a/Source/WebCore/html/StepRange.cpp
+++ b/Source/WebCore/html/StepRange.cpp
@@ -24,9 +24,7 @@
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include <wtf/MathExtras.h>
-#include <wtf/text/WTFString.h>
-
-using namespace std;
+#include <wtf/NeverDestroyed.h>
namespace WebCore {
@@ -68,13 +66,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;
@@ -83,7 +81,7 @@ Decimal StepRange::alignValueForStep(const Decimal& currentValue, const Decimal&
Decimal StepRange::clampValue(const Decimal& value) const
{
- const Decimal inRangeValue = max(m_minimum, min(value, m_maximum));
+ const Decimal inRangeValue = std::max(m_minimum, std::min(value, m_maximum));
if (!m_hasStep)
return inRangeValue;
// Rounds inRangeValue to minimum + N * step.
@@ -99,7 +97,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();
@@ -120,13 +118,13 @@ Decimal StepRange::parseStep(AnyStepHandling anyStepHandling, const StepDescript
break;
case ParsedStepValueShouldBeInteger:
// For date, month, and week, the parsed value should be an integer for some types.
- step = max(step.round(), Decimal(1));
+ step = std::max(step.round(), Decimal(1));
step *= stepDescription.stepScaleFactor;
break;
case ScaledStepValueShouldBeInteger:
// For datetime, datetime-local, time, the result should be an integer.
step *= stepDescription.stepScaleFactor;
- step = max(step.round(), Decimal(1));
+ step = std::max(step.round(), Decimal(1));
break;
default:
ASSERT_NOT_REACHED();
@@ -153,7 +151,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' :