mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Add <keyword>::from_ident helper to avoid tokenizing the same value multiple times.
This commit is contained in:
parent
c2d9f663af
commit
a5436e9091
1 changed files with 6 additions and 1 deletions
|
@ -117,7 +117,12 @@ macro_rules! __define_css_keyword_enum__actual {
|
||||||
/// Parse this property from a CSS input stream.
|
/// Parse this property from a CSS input stream.
|
||||||
pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
|
pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
|
||||||
let ident = input.expect_ident()?;
|
let ident = input.expect_ident()?;
|
||||||
match_ignore_ascii_case! { &ident,
|
Self::from_ident(&ident)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Parse this property from an already-tokenized identifier.
|
||||||
|
pub fn from_ident(ident: &str) -> Result<$name, ()> {
|
||||||
|
match_ignore_ascii_case! { ident,
|
||||||
$( $css => Ok($name::$variant), )+
|
$( $css => Ok($name::$variant), )+
|
||||||
_ => Err(())
|
_ => Err(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue