mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
style: Don't allow whitespace between media query operator delim tokens
Differential Revision: https://phabricator.services.mozilla.com/D113648
This commit is contained in:
parent
fb9d8ddc73
commit
43cec05c04
1 changed files with 30 additions and 16 deletions
|
@ -196,23 +196,37 @@ fn consume_operation_or_colon(input: &mut Parser) -> Result<Option<Operator>, ()
|
||||||
_ => return Err(()),
|
_ => return Err(()),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Ok(Some(match first_delim {
|
let operator = match first_delim {
|
||||||
'=' => Operator::Equal,
|
'=' => return Ok(Some(Operator::Equal)),
|
||||||
'>' => {
|
'>' => Operator::GreaterThan,
|
||||||
if input.try_parse(|i| i.expect_delim('=')).is_ok() {
|
'<' => Operator::LessThan,
|
||||||
Operator::GreaterThanEqual
|
|
||||||
} else {
|
|
||||||
Operator::GreaterThan
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'<' => {
|
|
||||||
if input.try_parse(|i| i.expect_delim('=')).is_ok() {
|
|
||||||
Operator::LessThanEqual
|
|
||||||
} else {
|
|
||||||
Operator::LessThan
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => return Err(()),
|
_ => return Err(()),
|
||||||
|
};
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/mediaqueries-4/#mq-syntax:
|
||||||
|
//
|
||||||
|
// No whitespace is allowed between the “<” or “>”
|
||||||
|
// <delim-token>s and the following “=” <delim-token>, if it’s
|
||||||
|
// present.
|
||||||
|
//
|
||||||
|
// TODO(emilio): Maybe we should ignore comments as well?
|
||||||
|
// https://github.com/w3c/csswg-drafts/issues/6248
|
||||||
|
let parsed_equal = input.try_parse(|i| {
|
||||||
|
let t = i.next_including_whitespace().map_err(|_| ())?;
|
||||||
|
if !matches!(t, Token::Delim('=')) {
|
||||||
|
return Err(())
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}).is_ok();
|
||||||
|
|
||||||
|
if !parsed_equal {
|
||||||
|
return Ok(Some(operator));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(Some(match operator {
|
||||||
|
Operator::GreaterThan => Operator::GreaterThanEqual,
|
||||||
|
Operator::LessThan => Operator::LessThanEqual,
|
||||||
|
_ => unreachable!(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue