mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #16713 - emilio:calc-in-calc, r=manishearth
style: Allow parsing nested calc() expressions. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16713) <!-- Reviewable:end -->
This commit is contained in:
commit
53b391daf8
3 changed files with 5 additions and 3 deletions
|
@ -843,6 +843,10 @@ impl CalcLengthOrPercentage {
|
||||||
input.parse_nested_block(|i| CalcLengthOrPercentage::parse_sum(context, i, expected_unit))
|
input.parse_nested_block(|i| CalcLengthOrPercentage::parse_sum(context, i, expected_unit))
|
||||||
.map(|result| CalcValueNode::Sum(Box::new(result)))
|
.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(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use style_traits::ToCss;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_calc() {
|
fn test_calc() {
|
||||||
assert!(parse(Length::parse, "calc(1px+ 2px)").is_err());
|
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());
|
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());
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[calc-in-calc.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue