8000 Getting input.value for number inputs (type=number) with over 39 char… · WebKit/WebKit@134163e · GitHub
[go: up one dir, main page]

Skip to content

Commit 134163e

Browse files
Ahmad-S792Ahmad Saleem
authored andcommitted
Getting input.value for number inputs (type=number) with over 39 characters returns an empty string
Getting input.value for number inputs (type=number) with over 39 characters returns an empty string https://bugs.webkit.org/show_bug.cgi?id=249783 Reviewed by Ryosuke Niwa. This patch is to align WebKit with Blink / Chromium, Firefox / Gecko and Web-Specification. Merge - https://src.chromium.org/viewvc/blink?view=revision&revision=168513 Number input type maximum value increased from float to double. Float allowed only max value of 3.402823466e38, it has now been increased to 1.7976931348623158e+308, by using double. InvalidStateError exception is removed from NumberInputType::setValueAsDouble and NumberInputType::setValueAsDecimal, as HTMLInputType::setValueAsNumber checks if value is infinite. HTMLParserIdioms has also been updated as the functions are triggered in NumberInputType functions and has check for max values, thus updated. * Source/WebCore/html/NumberInputType.cpp: (NumberInputType::valueAsDouble): - Updated Comment and also removed FIXME (NumberInputType::valueAsDecimal): - Updated Comment and also removed FIXME (NumberInputType::createStepRange): (1) Remove "FIXME" (2) Use "doubleMax" instead of "floatMax" * Source/WebCore/html/parser/HTMLParserIdioms.cpp: (parseToDecimalForNumberType): (1) Updated Comment and also removed FIXME (2) Use "doubleMax" instead of "floatMax" (3) Update condition to ASSERT * LayoutTests/fast/forms/number/number-valueasnumber.html: Updated * LayoutTests/fast/forms/number/number-valueasnumber-expected.txt: Ditto * LayoutTests/fast/forms/number/number-stepup-stepdown.html: Updated * LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt: Ditto * LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html: Updated * LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt: Ditto Canonical link: https://commits.webkit.org/258614@main
1 parent 24d9e4a commit 134163e

8 files changed

+61
-76
lines changed

LayoutTests/fast/forms/number/number-stepup-stepdown-expected.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Check stepUp() and stepDown() bahevior for number type.
1+
Check stepUp() and stepDown() behavior for number type.
22

33
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
44

@@ -144,12 +144,12 @@ PASS stepDown("1", "1", "0") is "0"
144144
PASS stepDown("0", "1", "0") is "0"
145145
PASS stepDown("1", "1", "0", 2) is "0"
146146
PASS input.value is "0"
147-
PASS stepDown("1", "3.40282346e+38", "", 2) is "-3.40282346e+38"
147+
PASS stepDown("1", "1.797693134862315e+308", "", 2) is "-1.797693134862315e+308"
148148
PASS stepUp("-1", "1", "0") is "0"
149149
PASS stepUp("0", "1", "0") is "0"
150150
PASS stepUp("-1", "1", "0", 2) is "0"
151151
PASS input.value is "0"
152-
PASS stepUp("1", "3.40282346e+38", "", 2) is "3.40282346e+38"
152+
PASS stepUp("1", "1.797693134862315e+308", "", 2) is "1.797693134862315e+308"
153153

154154
stepDown()/stepUp() for stepMismatch values
155155
PASS stepUp("1", "2", "") is "3"
@@ -159,8 +159,8 @@ PASS stepDown("19", "10", "0") is "9"
159159
PASS stepUp("89", "10", "99") is "99"
160160

161161
Huge value and small step
162-
PASS input.min = ""; stepUp("1e+38", "1", "", 999999) is "1e+38"
163-
PASS input.max = ""; stepDown("1e+38", "1", "", 999999) is "1e+38"
162+
PASS input.min = ""; stepUp("1e+308", "1", "", 999999) is "1e+308"
163+
PASS input.max = ""; stepDown("1e+308", "1", "", 999999) is "1e+308"
164164

165165
Fractional numbers
166166
PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1"

LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer-expected.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ Overflow/underflow
141141
PASS stepDown("1", "1", "0") is "0"
142142
PASS stepDown("0", "1", "0") is "0"
143143
PASS stepDown("1", "1", "0", 2) is "0"
144-
PASS stepDown("1", "3.40282346e+38", "", 2) is "-3.40282346e+38"
144+
PASS stepDown("1", "1.797693134862315e+308", "", 2) is "-1.797693134862315e+308"
145145
PASS stepUp("-1", "1", "0") is "0"
146146
PASS stepUp("0", "1", "0") is "0"
147147
PASS stepUp("-1", "1", "0", 2) is "0"
148-
PASS stepUp("1", "3.40282346e+38", "", 2) is "3.40282346e+38"
148+
PASS stepUp("1", "1.797693134862315e+308", "", 2) is "1.797693134862315e+308"
149149

150150
stepDown()/stepUp() for stepMismatch values
151151
PASS stepUp("1", "2", "") is "2"
@@ -158,8 +158,8 @@ PASS stepDown("7", "300", "") is "0"
158158
PASS stepDown("-7", "300", "") is "-300"
159159

160160
Huge value and small step
161-
PASS input.min = ""; stepUp("1e+38", "1", "", 999) is "1e+38"
162-
PASS input.max = ""; stepDown("1e+38", "1", "", 999) is "1e+38"
161+
PASS input.min = ""; stepUp("1e+308", "1", "", 999) is "1e+308"
162+
PASS input.max = ""; stepDown("1e+308", "1", "", 999) is "1e+308"
163163

164164
Fractional numbers
165165
PASS input.min = ""; stepUp("0", "0.33333333333333333", "", 3) is "1"

LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="../../../resources/js-test-pre.js"></script>
4+
<script src="../../../resources/js-test.js"></script>
55
</head>
66
<body>
77
<script>
@@ -269,11 +269,11 @@
269269
shouldBe('stepDown("1", "1", "0")', '"0"');
270270
shouldBe('stepDown("0", "1", "0")', '"0"');
271271
shouldBe('stepDown("1", "1", "0", 2)', '"0"');
272-
shouldBe('stepDown("1", "3.40282346e+38", "", 2)', '"-3.40282346e+38"');
272+
shouldBe('stepDown("1", "1.797693134862315e+308", "", 2)', '"-1.797693134862315e+308"');
273273
shouldBe('stepUp("-1", "1", "0")', '"0"');
27 9E88 4274
shouldBe('stepUp("0", "1", "0")', '"0"');
275275
shouldBe('stepUp("-1", "1", "0", 2)', '"0"');
276-
shouldBe('stepUp("1", "3.40282346e+38", "", 2)', '"3.40282346e+38"');
276+
shouldBe('stepUp("1", "1.797693134862315e+308", "", 2)', '"1.797693134862315e+308"');
277277

278278
debug('');
279279
debug('stepDown()/stepUp() for stepMismatch values');
@@ -288,8 +288,8 @@
288288

289289
debug('');
290290
debug('Huge value and small step');
291-
shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999)', '"1e+38"');
292-
shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999)', '"1e+38"');
291+
shouldBe('input.min = ""; stepUp("1e+308", "1", "", 999)', '"1e+308"');
292+
shouldBe('input.max = ""; stepDown("1e+308", "1", "", 999)', '"1e+308"');
293293

294294
debug('');
295295
debug('Fractional numbers');
@@ -324,6 +324,5 @@
324324

325325
debug('');
326326
</script>
327-
<script src="../../../resources/js-test-post.js"></script>
328327
</body>
329328
</html>

LayoutTests/fast/forms/number/number-stepup-stepdown.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="../../../resources/js-test-pre.js"></script>
4+
<script src="../../../resources/js-test.js"></script>
55
</head>
66
<body>
77
<script>
8-
description('Check stepUp() and stepDown() bahevior for number type.');
8+
description('Check stepUp() and stepDown() behavior for number type.');
99

1010
var input = document.createElement('input');
1111

@@ -223,12 +223,12 @@
223223
shouldBe('stepDown("0", "1", "0")', '"0"');
224224
shouldBe('stepDown("1", "1", "0", 2)', '"0"');
225225
shouldBe('input.value', '"0"');
226-
shouldBe('stepDown("1", "3.40282346e+38", "", 2)', '"-3.40282346e+38"');
226+
shouldBeEqualToString('stepDown("1", "1.797693134862315e+308", "", 2)', '-1.797693134862315e+308');
227227
shouldBe('stepUp("-1", "1", "0")', '"0"');
228228
shouldBe('stepUp("0", "1", "0")', '"0"');
229229
shouldBe('stepUp("-1", "1", "0", 2)', '"0"');
230230
shouldBe('input.value', '"0"');
231-
shouldBe('stepUp("1", "3.40282346e+38", "", 2)', '"3.40282346e+38"');
231+
shouldBeEqualToString('stepUp("1", "1.797693134862315e+308", "", 2)', '1.797693134862315e+308');
232232

233233
debug('');
234234
debug('stepDown()/stepUp() for stepMismatch values');
@@ -240,8 +240,8 @@
240240

241241
debug('');
242242
debug('Huge value and small step');
243-
shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999999)', '"1e+38"');
244-
shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999999)', '"1e+38"');
243+
shouldBe('input.min = ""; stepUp("1e+308", "1", "", 999999)', '"1e+308"');
244+
shouldBe('input.max = ""; stepDown("1e+308", "1", "", 999999)', '"1e+308"');
245245

246246
debug('');
247247
debug('Fractional numbers');
@@ -262,6 +262,5 @@
262262

263263
debug('');
264264
</script>
265-
<script src="../../../resources/js-test-post.js"></script>
266265
</body>
267266
</html>

LayoutTests/fast/forms/number/number-valueasnumber-expected.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PASS valueAsNumberFor("-1.2") is -1.2
1313
PASS valueAsNumberFor("1.2E10") is 1.2E10
1414
PASS valueAsNumberFor("1.2E-10") is 1.2E-10
1515
PASS valueAsNumberFor("1.2E+10") is 1.2E10
16-
PASS valueAsNumberFor("123456789012345678901234567890123456789") is 1.2345678901234568E+38
16+
PASS valueAsNumberFor("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789") is 1.2345678901234568E+308
1717
PASS valueAsNumberFor("0.12345678901234567890123456789012345678901234567890") is 0.123456789012345678
1818
valueAsNumber for invalid string values:
1919
PASS isNaN(valueAsNumberFor("")) is true
@@ -40,11 +40,11 @@ PASS setValueAsNumberAndGetValue(-0) is "0"
4040
PASS setValueAsNumberAndGetValue(-1.2) is "-1.2"
4141
PASS setValueAsNumberAndGetValue(1.2e10) is "12000000000"
4242
PASS setValueAsNumberAndGetValue(1.2e-10) is "1.2e-10"
43-
PASS setValueAsNumberAndGetValue(1.2345678901234567e+38) is "1.2345678901234567e+38"
44-
PASS setValueAsNumberAndGetValue("-3.40282346e+38") is "-3.40282346e+38"
45-
PASS setValueAsNumberAndGetValue("-3.40282348e+38") threw exception InvalidStateError: The object is in an invalid state..
46-
PASS setValueAsNumberAndGetValue("3.40282346e+38") is "3.40282346e+38"
47-
PASS setValueAsNumberAndGetValue("3.40282348e+38") threw exception InvalidStateError: The object is in an invalid state..
43+
PASS setValueAsNumberAndGetValue(1.2345678901234567e+308) is "1.2345678901234567e+308"
44+
PASS setValueAsNumberAndGetValue("-1.797693134862315e+308") is "-1.797693134862315e+308"
45+
PASS setValueAsNumberAndGetValue("-1.797693134862316e+308") threw exception NotSupportedError: The operation is not supported..
46+
PASS setValueAsNumberAndGetValue("1.797693134862315e+308") is "1.797693134862315e+308"
47+
PASS setValueAsNumberAndGetValue("1.797693134862316e+308") threw exception NotSupportedError: The operation is not supported..
4848
Tests to set invalid values to valueAsNumber:
4949
PASS setValueAsNumberAndGetValue(null) is "0"
5050
PASS setValueAsNumberAndGetValue("foo") threw exception NotSupportedError: The operation is not supported..

LayoutTests/fast/forms/number/number-valueasnumber.html

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="../../../resources/js-test-pre.js"></script>
4+
<script src="../../../resources/js-test.js"></script>
55
</head>
66
<body>
77
<script>
@@ -30,7 +30,7 @@
3030
shouldBe('valueAsNumberFor("1.2E10")', '1.2E10');
3131
shouldBe('valueAsNumberFor("1.2E-10")', '1.2E-10');
3232
shouldBe('valueAsNumberFor("1.2E+10")', '1.2E10');
33-
shouldBe('valueAsNumberFor("123456789012345678901234567890123456789")', '1.2345678901234568E+38');
33+
shouldBe('valueAsNumberFor("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789")', '1.2345678901234568E+308');
3434
shouldBe('valueAsNumberFor("0.12345678901234567890123456789012345678901234567890")', '0.123456789012345678');
3535

3636
debug('valueAsNumber for invalid string values:');
@@ -53,28 +53,27 @@
5353
shouldBeTrue('isNaN(valueAsNumberFor("1.2E65535"))');
5454

5555
debug('Tests for the valueAsNumber setter:');
56-
shouldBe('setValueAsNumberAndGetValue(0)', '"0"');
57-
shouldBe('setValueAsNumberAndGetValue(10)', '"10"');
58-
shouldBe('setValueAsNumberAndGetValue(01)', '"1"');
59-
shouldBe('setValueAsNumberAndGetValue(-0)', '"0"');
60-
shouldBe('setValueAsNumberAndGetValue(-1.2)', '"-1.2"');
61-
shouldBe('setValueAsNumberAndGetValue(1.2e10)', '"12000000000"');
62-
shouldBe('setValueAsNumberAndGetValue(1.2e-10)', '"1.2e-10"');
63-
shouldBe('setValueAsNumberAndGetValue(1.2345678901234567e+38)', '"1.2345678901234567e+38"');
64-
shouldBe('setValueAsNumberAndGetValue("-3.40282346e+38")', '"-3.40282346e+38"');
65-
shouldThrowErrorName('setValueAsNumberAndGetValue("-3.40282348e+38")', 'InvalidStateError');
66-
shouldBe('setValueAsNumberAndGetValue("3.40282346e+38")', '"3.40282346e+38"');
67-
shouldThrowErrorName('setValueAsNumberAndGetValue("3.40282348e+38")', 'InvalidStateError');
56+
shouldBeEqualToString('setValueAsNumberAndGetValue(0)', '0');
57+
shouldBeEqualToString('setValueAsNumberAndGetValue(10)', '10');
58+
shouldBeEqualToString('setValueAsNumberAndGetValue(01)', '1');
59+
shouldBeEqualToString('setValueAsNumberAndGetValue(-0)', '0');
60+
shouldBeEqualToString('setValueAsNumberAndGetValue(-1.2)', '-1.2');
61+
shouldBeEqualToString('setValueAsNumberAndGetValue(1.2e10)', '12000000000');
62+
shouldBeEqualToString('setValueAsNumberAndGetValue(1.2e-10)', '1.2e-10');
63+
shouldBeEqualToString('setValueAsNumberAndGetValue(1.2345678901234567e+308)', '1.2345678901234567e+308');
64+
shouldBeEqualToString('setValueAsNumberAndGetValue("-1.797693134862315e+308")', '-1.797693134862315e+308');
65+
shouldThrowErrorName('setValueAsNumberAndGetValue("-1.797693134862316e+308")', "NotSupportedError");
66+
shouldBe('setValueAsNumberAndGetValue("1.797693134862315e+308")', '"1.797693134862315e+308"');
67+
shouldThrowErrorName('setValueAsNumberAndGetValue("1.797693134862316e+308")', "NotSupportedError");
6868

6969
debug('Tests to set invalid values to valueAsNumber:');
70-
shouldBe('setValueAsNumberAndGetValue(null)', '"0"');
71-
shouldThrowErrorName('setValueAsNumberAndGetValue("foo")', 'NotSupportedError');
72-
shouldThrowErrorName('setValueAsNumberAndGetValue(NaN)', 'NotSupportedError');
73-
shouldThrowErrorName('setValueAsNumberAndGetValue(Number.NaN)', 'NotSupportedError');
74-
shouldThrowErrorName('setValueAsNumberAndGetValue(Infinity)', 'NotSupportedError');
75-
shouldThrowErrorName('setValueAsNumberAndGetValue(Number.POSITIVE_INFINITY)', 'NotSupportedError');
76-
shouldThrowErrorName('setValueAsNumberAndGetValue(Number.NEGATIVE_INFINITY)', 'NotSupportedError');
70+
shouldBeEqualToString('setValueAsNumberAndGetValue(null)', '0');
71+
shouldThrowErrorName('setValueAsNumberAndGetValue("foo")', "NotSupportedError");
72+
shouldThrowErrorName('setValueAsNumberAndGetValue(NaN)', "NotSupportedError");
73+
shouldThrowErrorName('setValueAsNumberAndGetValue(Number.NaN)', "NotSupportedError");
74+
shouldThrowErrorName('setValueAsNumberAndGetValue(Infinity)', "NotSupportedError");
75+
shouldThrowErrorName('setValueAsNumberAndGetValue(Number.POSITIVE_INFINITY)', "NotSupportedError");
76+
shouldThrowErrorName('setValueAsNumberAndGetValue(Number.NEGATIVE_INFINITY)', "NotSupportedError");
7777
</script>
78-
<script src="../../../resources/js-test-post.js"></script>
7978
</body>
8079
</html>

Source/WebCore/html/NumberInputType.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2010 Google Inc. All rights reserved.
3-
* Copyright (C) 2011-2018 Apple Inc. All rights reserved.
2+
* Copyright (C) 2010-2014 Google Inc. All rights reserved.
3+
* Copyright (C) 2011-2023 Apple Inc. All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
66
* modification, are permitted provided that the following conditions are
@@ -110,21 +110,13 @@ double NumberInputType::valueAsDouble() const
110110

111111
ExceptionOr<void> NumberInputType::setValueAsDouble(double newValue, TextFieldEventBehavior eventBehavior) const
112112
{
113-
// FIXME: We should use numeric_limits<double>::max for number input type.
114-
const double floatMax = std::numeric_limits<float>::max();
115-
if (newValue < -floatMax || newValue > floatMax)
116-
return Exception { InvalidStateError };
117113
ASSERT(element());
118114
element()->setValue(serializeForNumberType(newValue), eventBehavior);
119115
return { };
120116
}
121117

122118
ExceptionOr<void> NumberInputType::setValueAsDecimal(const Decimal& newValue, TextFieldEventBehavior eventBehavior) const
123119
{
124-
// FIXME: We should use numeric_limits<double>::max for number input type.
125-
const Decimal floatMax = Decimal::fromDouble(std::numeric_limits<float>::max());
126-
if (newValue < -floatMax || newValue > floatMax)
127-
return Exception { InvalidStateError };
128120
ASSERT(element());
129121
element()->setValue(serializeForNumberType(newValue), eventBehavior);
130122
return { };
@@ -151,8 +143,7 @@ StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) cons
151143
if (stepBase.isNaN())
152144
stepBase = parseToDecimalForNumberType(element()->attributeWithoutSynchronization(valueAttr), numberDefaultStepBase);
153145

154-
// FIXME: We should use numeric_limits<double>::max for number input type.
155-
const Decimal floatMax = Decimal::fromDouble(std::numeric_limits<float>::max());
146+
const Decimal doubleMax = Decimal::fromDouble(std::numeric_limits<double>::max());
156147
const Element& element = *this->element();
157148

158149
RangeLimitations rangeLimitations = RangeLimitations::Invalid;
@@ -165,8 +156,8 @@ StepRange NumberInputType::createStepRange(AnyStepHandling anyStepHandling) cons
165156
}
166157
return defaultValue;
167158
};
168-
Decimal minimum = extractBound(minAttr, -floatMax);
169-
Decimal maximum = extractBound(maxAttr, floatMax);
159+
Decimal minimum = extractBound(minAttr, -doubleMax);
160+
Decimal maximum = extractBound(maxAttr, doubleMax);
170161

171162
const Decimal step = StepRange::parseStep(anyStepHandling, stepDescription, element.attributeWithoutSynchronization(stepAttr));
172163
return StepRange(stepBase, rangeLimitations, minimum, maximum, step, stepDescription);

Source/WebCore/html/parser/HTMLParserIdioms.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* Copyright (C) 2010-2017 Apple Inc. All rights reserved.
2+
* Copyright (C) 2010-2023 Apple Inc. All rights reserved.
3+
* Copyright (C) 2014 Google Inc. All rights reserved.
34
*
45
* Redistribution and use in source and binary forms, with or without
56
* modification, are permitted provided that the following conditions
@@ -98,7 +99,7 @@ String serializeForNumberType(double number)
9899

99100
Decimal parseToDecimalForNumberType(StringView string, const Decimal& fallbackValue)
100101
{
101-
// See HTML5 2.5.4.3 `Real numbers.' and parseToDoubleForNumberType
102+
// https://html.spec.whatwg.org/#floating-point-numbers and parseToDoubleForNumberType
102103
if (string.isEmpty())
103104
return fallbackValue;
104105

@@ -111,11 +112,9 @@ Decimal parseToDecimalForNumberType(StringView string, const Decimal& fallbackVa
111112
if (!value.isFinite())
112113
return fallbackValue;
113114

114-
// Numbers are considered finite IEEE 754 single-precision floating point values.
115-
// See HTML5 2.5.4.3 `Real numbers.'
116-
// FIXME: We should use numeric_limits<double>::max for number input type.
117-
const Decimal floatMax = Decimal::fromDouble(std::numeric_limits<float>::max());
118-
if (value < -floatMax || value > floatMax)
115+
// Numbers are considered finite IEEE 754 Double-precision floating point values.
116+
const Decimal doubleMax = Decimal::fromDouble(std::numeric_limits<double>::max());
117+
if (value < -doubleMax || value > doubleMax)
119118
return fallbackValue;
120119

121120
// We return +0 for -0 case.
@@ -129,7 +128,7 @@ Decimal parseToDecimalForNumberType(StringView string)
129128

130129
double parseToDoubleForNumberType(StringView string, double fallbackValue)
131130
{
132-
// See HTML5 2.5.4.3 `Real numbers.'
131+
// https://html.spec.whatwg.org/#floating-point-numbers
133132
if (string.isEmpty())
134133
return fallbackValue;
135134

@@ -156,10 +155,8 @@ double parseToDoubleForNumberType(StringView string, double fallbackValue)
156155
if (!std::isfinite(value))
157156
return fallbackValue;
158157

159-
// Numbers are considered finite IEEE 754 single-precision floating point values.
160-
// See HTML5 2.5.4.3 `Real numbers.'
161-
if (-std::numeric_limits<float>::max() > value || value > std::numeric_limits<float>::max())
162-
return fallbackValue;
158+
// Numbers are considered finite IEEE 754 Double-precision floating point values.
159+
ASSERT(-std::numeric_limits<double>::max() <= value || value < std::numeric_limits<double>::max());
163160

164161
// The following expression converts -0 to +0.
165162
return value ? value : 0;

0 commit comments

Comments
 (0)
0