diff --git a/components/style/properties/longhand/color.mako.rs b/components/style/properties/longhand/color.mako.rs index 554edd8aa4a..e3e8221eb8d 100644 --- a/components/style/properties/longhand/color.mako.rs +++ b/components/style/properties/longhand/color.mako.rs @@ -121,21 +121,20 @@ impl SystemColor { pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result> { - #[cfg(feature = "gecko")] - use std::ascii::AsciiExt; - static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[ - % for color in system_colors: - ("${color}", LookAndFeel_ColorID::eColorID_${to_rust_ident(color)}), - % endfor - ]; - - let ident = input.expect_ident()?; - for &(name, color) in PARSE_ARRAY.iter() { - if name.eq_ignore_ascii_case(&ident) { - return Ok(color) + ascii_case_insensitive_phf_map! { + color_name -> SystemColor = { + % for color in system_colors: + "${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)}, + % endfor } } - Err(SelectorParseError::UnexpectedIdent(ident).into()) + + let ident = input.expect_ident()?; + if let Some(color) = color_name(&ident) { + Ok(*color) + } else { + Err(SelectorParseError::UnexpectedIdent(ident).into()) + } } } % endif