From 2192090ea5432db9db7b2c37a10102b8adeb46d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 8 Mar 2018 14:01:09 +0100 Subject: [PATCH 1/2] style: Fix special color keywords. They're -moz-activehyperlinktext and -moz-visitedhyperlinktext. --- components/style/values/specified/color.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/style/values/specified/color.rs b/components/style/values/specified/color.rs index 134bd673cb1..a9c52de811a 100644 --- a/components/style/values/specified/color.rs +++ b/components/style/values/specified/color.rs @@ -52,8 +52,8 @@ mod gecko { MozDefaultColor, MozDefaultBackgroundColor, MozHyperlinktext, - MozActiveHyperlinktext, - MozVisitedHyperlinktext, + MozActivehyperlinktext, + MozVisitedhyperlinktext, } } @@ -368,8 +368,8 @@ impl Color { Keyword::MozDefaultColor => pres_context.mDefaultColor, Keyword::MozDefaultBackgroundColor => pres_context.mBackgroundColor, Keyword::MozHyperlinktext => pres_context.mLinkColor, - Keyword::MozActiveHyperlinktext => pres_context.mActiveLinkColor, - Keyword::MozVisitedHyperlinktext => pres_context.mVisitedLinkColor, + Keyword::MozActivehyperlinktext => pres_context.mActiveLinkColor, + Keyword::MozVisitedhyperlinktext => pres_context.mVisitedLinkColor, }) }) } From 0717047e1ed186a98cac4aaffccf8db913441da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 8 Mar 2018 14:08:54 +0100 Subject: [PATCH 2/2] style: Make weird color parsing marginally faster. --- components/style/properties/longhand/color.mako.rs | 4 +--- components/style/values/specified/color.rs | 12 +++++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/style/properties/longhand/color.mako.rs b/components/style/properties/longhand/color.mako.rs index 3dfc685f082..a4d1830190a 100644 --- a/components/style/properties/longhand/color.mako.rs +++ b/components/style/properties/longhand/color.mako.rs @@ -63,7 +63,6 @@ pub mod system_colors { IMESelectedConvertedTextBackground IMESelectedConvertedTextForeground IMESelectedConvertedTextUnderline SpellCheckerUnderline""".split() %> - use cssparser::Parser; use gecko_bindings::bindings::Gecko_GetLookAndFeelSystemColor; use gecko_bindings::structs::root::mozilla::LookAndFeel_ColorID; use std::fmt::{self, Write}; @@ -109,7 +108,7 @@ pub mod system_colors { } impl SystemColor { - pub fn parse<'i, 't>(input: &mut Parser<'i, 't>,) -> Result { + pub fn from_ident<'i, 't>(ident: &str) -> Result { ascii_case_insensitive_phf_map! { color_name -> SystemColor = { % for color in system_colors: @@ -118,7 +117,6 @@ pub mod system_colors { } } - let ident = input.expect_ident().map_err(|_| ())?; color_name(ident).cloned().ok_or(()) } } diff --git a/components/style/values/specified/color.rs b/components/style/values/specified/color.rs index a9c52de811a..492e92c32d2 100644 --- a/components/style/values/specified/color.rs +++ b/components/style/values/specified/color.rs @@ -160,12 +160,14 @@ impl Parse for Color { Err(e) => { #[cfg(feature = "gecko")] { - if let Ok(system) = input.try(SystemColor::parse) { - return Ok(Color::System(system)); - } + if let Ok(ident) = input.expect_ident() { + if let Ok(system) = SystemColor::from_ident(ident) { + return Ok(Color::System(system)); + } - if let Ok(c) = gecko::SpecialColorKeyword::parse(input) { - return Ok(Color::Special(c)); + if let Ok(c) = gecko::SpecialColorKeyword::from_ident(ident) { + return Ok(Color::Special(c)); + } } }