Commit e45eada6 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Fix float parsing in srcset

The HTMLSrcsetParser was using a non-compliant float parser (the one used by
WTFString::charactersToFloat which is in wtf/dtoa/double-conversion).
As a result some tests were failing.
This CL switches it to use the decimal parser in HTMLParserIdioms.

BUG=523159

Review URL: https://codereview.chromium.org/1306743003

git-svn-id: svn://svn.chromium.org/blink/trunk@201132 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 65681ac0
...@@ -97,7 +97,11 @@ struct DescriptorToken { ...@@ -97,7 +97,11 @@ struct DescriptorToken {
isValid = false; isValid = false;
return 0; return 0;
} }
return charactersToFloat(attribute + start, lengthExcludingDescriptor, &isValid); Decimal result = parseToDecimalForNumberType(String(attribute + start, lengthExcludingDescriptor));
isValid = result.isFinite();
if (!isValid)
return 0;
return static_cast<float>(result.toDouble());
} }
}; };
......
...@@ -100,6 +100,7 @@ TEST(HTMLSrcsetParserTest, Basic) ...@@ -100,6 +100,7 @@ TEST(HTMLSrcsetParserTest, Basic)
{1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_limits<float>::infinity(), 400}, {1.0, 0, "", "400.gif 400w, 6000.gif 6000w", "400.gif", std::numeric_limits<float>::infinity(), 400},
{2.0, -1, "", ", 1x.gif 1x, 2x.gif 2x", "2x.gif", 2.0, -1}, {2.0, -1, "", ", 1x.gif 1x, 2x.gif 2x", "2x.gif", 2.0, -1},
{1.0, -1, "", ",1x.gif 1x, 2x.gif 2x", "1x.gif", 1.0, -1}, {1.0, -1, "", ",1x.gif 1x, 2x.gif 2x", "1x.gif", 1.0, -1},
{1.0, -1, "", ",1x.gif 1.x , 2x.gif 2x", "2x.gif", 2.0, -1},
{1.2, -1, "", ",1x.gif 1x, 1.4x.gif 1.4x, 2x.gif 2x", "1.4x.gif", 1.4, -1}, {1.2, -1, "", ",1x.gif 1x, 1.4x.gif 1.4x, 2x.gif 2x", "1.4x.gif", 1.4, -1},
{1.0, -1, "", "inf.gif 0.00000000001x", "inf.gif", 1e-11, -1}, {1.0, -1, "", "inf.gif 0.00000000001x", "inf.gif", 1e-11, -1},
{1.0, -1, "", "data:,a ( , data:,b 1x, ), data:,c", "data:,c", 1.0, -1}, {1.0, -1, "", "data:,a ( , data:,b 1x, ), data:,c", "data:,c", 1.0, -1},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment