style: Allow parsing nested calc() expressions.

This commit is contained in:
Emilio Cobos Álvarez 2017-05-03 20:58:24 +02:00
parent ed7686b42c
commit cd43331963
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 5 additions and 3 deletions

View file

@ -843,6 +843,10 @@ impl CalcLengthOrPercentage {
input.parse_nested_block(|i| CalcLengthOrPercentage::parse_sum(context, i, expected_unit))
.map(|result| CalcValueNode::Sum(Box::new(result)))
},
(Token::Function(ref name), _) if name.eq_ignore_ascii_case("calc") => {
input.parse_nested_block(|i| CalcLengthOrPercentage::parse_sum(context, i, expected_unit))
.map(|result| CalcValueNode::Sum(Box::new(result)))
}
_ => Err(())
}
}

View file

@ -16,6 +16,7 @@ use style_traits::ToCss;
#[test]
fn test_calc() {
assert!(parse(Length::parse, "calc(1px+ 2px)").is_err());
assert!(parse(Length::parse, "calc(calc(1px) + calc(1px + 4px))").is_ok());
assert!(parse(Length::parse, "calc( 1px + 2px )").is_ok());
assert!(parse(Length::parse, "calc(1px + 2px )").is_ok());
assert!(parse(Length::parse, "calc( 1px + 2px)").is_ok());

View file

@ -1,3 +0,0 @@
[calc-in-calc.htm]
type: reftest
expected: FAIL