mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Require spaces around operators in calc() (fixes #15486)
This commit is contained in:
parent
8b60a409c1
commit
0138bbcdd1
3 changed files with 37 additions and 10 deletions
|
@ -584,19 +584,33 @@ impl CalcLengthOrPercentage {
|
|||
let mut products = Vec::new();
|
||||
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
||||
|
||||
while let Ok(token) = input.next() {
|
||||
match token {
|
||||
Token::Delim('+') => {
|
||||
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
||||
loop {
|
||||
let position = input.position();
|
||||
match input.next_including_whitespace() {
|
||||
Ok(Token::WhiteSpace(_)) => {
|
||||
match input.next() {
|
||||
Ok(Token::Delim('+')) => {
|
||||
products.push(try!(CalcLengthOrPercentage::parse_product(input, expected_unit)));
|
||||
}
|
||||
Token::Delim('-') => {
|
||||
let mut right = try!(CalcLengthOrPercentage::parse_product(input, expected_unit));
|
||||
right.values.push(CalcValueNode::Number(-1.));
|
||||
products.push(right);
|
||||
|
||||
Ok(Token::Delim('-')) => {
|
||||
let mut right = try!(CalcLengthOrPercentage::parse_product(input, expected_unit));
|
||||
right.values.push(CalcValueNode::Number(-1.));
|
||||
products.push(right);
|
||||
}
|
||||
_ => return Err(())
|
||||
|
||||
_ => {
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
input.reset(position);
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(CalcSumNode { products: products })
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue