servo: Merge #16141 - style: Add <keyword>::from_ident helper to avoid tokenizing the same value multiple times (from emilio:keyword-from-ident); r=nox

We can use this to avoid tokenizing multiple times in some places, like #16127.

Source-Repo: https://github.com/servo/servo
Source-Revision: 447742b0a70395e55d6d1518fa51ad5b190abc8c

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 25adf3ad8feae17a3038424f4c9274d44c54fc58
This commit is contained in:
Emilio Cobos Álvarez 2017-03-26 17:21:49 -07:00
parent 2e2e70805e
commit f02a65b840

View File

@ -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(())
}