Commit 42ee07bf authored by timloh's avatar timloh Committed by Commit bot

Fix non-<number> calcs being accepted as numbers

This patch fixes a missing check in CalcParser::consumeNumberRaw for the
CalcNumber category. This was causing non-<number> calcs to be accepted
as numbers (which caused problems in flex where <number> and <length>
can be used in the same shorthand, e.g. flex: calc(10px + 50%) 1 2)

BUG=559513,499780

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

Cr-Commit-Position: refs/heads/master@{#361070}
parent 22ae9766
......@@ -69,6 +69,10 @@ PASS flexitem.style.flex is "1.75 2 3px"
PASS getComputedStyle(flexitem).flex is "1.75 2 3px"
PASS flexitem.style.flex is "1 2 3px"
PASS getComputedStyle(flexitem).flex is "1 2 3px"
PASS flexitem.style.flex is "4 3 calc(20px + 40%)"
PASS getComputedStyle(flexitem).flex is "4 3 calc(20px + 40%)"
PASS flexitem.style.flex is "1 2 calc(10px + 50%)"
PASS getComputedStyle(flexitem).flex is "1 2 calc(10px + 50%)"
PASS flexitem.style.flex is "0 0 auto"
PASS getComputedStyle(flexitem).flex is "0 0 auto"
PASS flexitem.style.flex is "0 1 auto"
......
......@@ -149,6 +149,14 @@ flexitem.style.flex = '3px 1 2';
shouldBeEqualToString('flexitem.style.flex', '1 2 3px');
shouldBeEqualToString('getComputedStyle(flexitem).flex', '1 2 3px');
flexitem.style.flex = 'calc(20px + 40%) 4 3';
shouldBeEqualToString('flexitem.style.flex', '4 3 calc(20px + 40%)');
shouldBeEqualToString('getComputedStyle(flexitem).flex', '4 3 calc(20px + 40%)');
flexitem.style.flex = '1 2 calc(10px + 50%)';
shouldBeEqualToString('flexitem.style.flex', '1 2 calc(10px + 50%)');
shouldBeEqualToString('getComputedStyle(flexitem).flex', '1 2 calc(10px + 50%)');
flexitem.style.flex = 'auto 0 0';
shouldBeEqualToString('flexitem.style.flex', '0 0 auto');
shouldBeEqualToString('getComputedStyle(flexitem).flex', '0 0 auto');
......
......@@ -184,7 +184,7 @@ public:
bool consumeNumberRaw(double& result)
{
if (!m_calcValue)
if (!m_calcValue || m_calcValue->category() != CalcNumber)
return false;
m_sourceRange = m_range;
result = m_calcValue->doubleValue();
......
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