mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #16141 - emilio:keyword-from-ident, r=nox
style: Add <keyword>::from_ident helper to avoid tokenizing the same value multiple times. We can use this to avoid tokenizing multiple times in some places, like #16127. <!-- 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/16141) <!-- Reviewable:end -->
This commit is contained in:
commit
447742b0a7
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.
|
||||
pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
|
||||
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), )+
|
||||
_ => Err(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue