Skip to content

Commit

Permalink
Bug 1846745 - Use static atoms for predefined counter-style names. r=…
Browse files Browse the repository at this point in the history
…layout-reviewers,jfkthame

Depends on D185156

Differential Revision: https://phabricator.services.mozilla.com/D185157
  • Loading branch information
emilio committed Aug 3, 2023
1 parent 54192d9 commit dddcd7a
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions servo/components/style/counter_style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,25 @@ pub fn parse_counter_style_name<'i, 't>(
input: &mut Parser<'i, 't>,
) -> Result<CustomIdent, ParseError<'i>> {
macro_rules! predefined {
($($name: expr,)+) => {
{
ascii_case_insensitive_phf_map! {
// FIXME: use static atoms https://github.com/rust-lang/rust/issues/33156
predefined -> &'static str = {
$(
$name => $name,
)+
}
($($name: tt,)+) => {{
ascii_case_insensitive_phf_map! {
predefined -> Atom = {
$(
$name => atom!($name),
)+
}
}

let location = input.current_source_location();
let ident = input.expect_ident()?;
if let Some(&lower_cased) = predefined::get(&ident) {
Ok(CustomIdent(Atom::from(lower_cased)))
} else {
// none is always an invalid <counter-style> value.
CustomIdent::from_ident(location, ident, &["none"])
}
let location = input.current_source_location();
let ident = input.expect_ident()?;
// This effectively performs case normalization only on predefined names.
if let Some(lower_case) = predefined::get(&ident) {
Ok(CustomIdent(lower_case.clone()))
} else {
// none is always an invalid <counter-style> value.
CustomIdent::from_ident(location, ident, &["none"])
}
}
}}
}
include!("predefined.rs")
}
Expand Down

0 comments on commit dddcd7a

Please sign in to comment.