mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Simplify CSSWideKeyword::parse.
Differential Revision: https://phabricator.services.mozilla.com/D5972
This commit is contained in:
parent
72ce653daf
commit
bc39f16b4b
1 changed files with 11 additions and 14 deletions
|
@ -853,25 +853,22 @@ impl CSSWideKeyword {
|
||||||
CSSWideKeyword::Unset => "unset",
|
CSSWideKeyword::Unset => "unset",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Takes the result of cssparser::Parser::expect_ident() and converts it
|
|
||||||
/// to a CSSWideKeyword.
|
|
||||||
pub fn from_ident<'i>(ident: &str) -> Option<Self> {
|
|
||||||
match_ignore_ascii_case! { ident,
|
|
||||||
// If modifying this set of keyword, also update values::CustomIdent::from_ident
|
|
||||||
"initial" => Some(CSSWideKeyword::Initial),
|
|
||||||
"inherit" => Some(CSSWideKeyword::Inherit),
|
|
||||||
"unset" => Some(CSSWideKeyword::Unset),
|
|
||||||
_ => None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CSSWideKeyword {
|
impl CSSWideKeyword {
|
||||||
fn parse(input: &mut Parser) -> Result<Self, ()> {
|
fn parse(input: &mut Parser) -> Result<Self, ()> {
|
||||||
let ident = input.expect_ident().map_err(|_| ())?.clone();
|
let keyword = {
|
||||||
|
let ident = input.expect_ident().map_err(|_| ())?;
|
||||||
|
match_ignore_ascii_case! { ident,
|
||||||
|
// If modifying this set of keyword, also update values::CustomIdent::from_ident
|
||||||
|
"initial" => CSSWideKeyword::Initial,
|
||||||
|
"inherit" => CSSWideKeyword::Inherit,
|
||||||
|
"unset" => CSSWideKeyword::Unset,
|
||||||
|
_ => return Err(()),
|
||||||
|
}
|
||||||
|
};
|
||||||
input.expect_exhausted().map_err(|_| ())?;
|
input.expect_exhausted().map_err(|_| ())?;
|
||||||
CSSWideKeyword::from_ident(&ident).ok_or(())
|
Ok(keyword)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue