servo: Merge #20240 - style: Fix special color keywords (from emilio:special-color-fix); r=upsuper
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 08 Mar 2018 10:06:03 -0500
changeset 462225 da43a754239def4d0991bfd6324eea171abf7cba
parent 462224 ea80ceed7810d5a8d8de35344bc1a91b911441c5
child 462226 9e92145bb5726a3a23255140fe995edc724cac63
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersupsuper
bugs20240, 1444059
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #20240 - style: Fix special color keywords (from emilio:special-color-fix); r=upsuper They're -moz-activehyperlinktext and -moz-visitedhyperlinktext. This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1444059. Source-Repo: https://github.com/servo/servo Source-Revision: 212c321145a516ddf3ae17a9f04563d8d736bb0d
servo/components/style/properties/longhand/color.mako.rs
servo/components/style/values/specified/color.rs
--- a/servo/components/style/properties/longhand/color.mako.rs
+++ b/servo/components/style/properties/longhand/color.mako.rs
@@ -58,17 +58,16 @@ pub mod system_colors {
                           TextSelectForegroundCustom TextSelectBackgroundDisabled TextSelectBackgroundAttention
                           TextHighlightBackground TextHighlightForeground IMERawInputBackground
                           IMERawInputForeground IMERawInputUnderline IMESelectedRawTextBackground
                           IMESelectedRawTextForeground IMESelectedRawTextUnderline
                           IMEConvertedTextBackground IMEConvertedTextForeground IMEConvertedTextUnderline
                           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};
     use style_traits::{CssWriter, ToCss};
     use values::computed::{Context, ToComputedValue};
 
     pub type SystemColor = LookAndFeel_ColorID;
 
@@ -104,23 +103,22 @@ pub mod system_colors {
 
         #[inline]
         fn from_computed_value(_: &Self::ComputedValue) -> Self {
             unreachable!()
         }
     }
 
     impl SystemColor {
-        pub fn parse<'i, 't>(input: &mut Parser<'i, 't>,) -> Result<Self, ()> {
+        pub fn from_ident<'i, 't>(ident: &str) -> Result<Self, ()> {
             ascii_case_insensitive_phf_map! {
                 color_name -> SystemColor = {
                     % for color in system_colors:
                         "${color}" => LookAndFeel_ColorID::eColorID_${to_rust_ident(color)},
                     % endfor
                 }
             }
 
-            let ident = input.expect_ident().map_err(|_| ())?;
             color_name(ident).cloned().ok_or(())
         }
     }
 }
 % endif
--- a/servo/components/style/values/specified/color.rs
+++ b/servo/components/style/values/specified/color.rs
@@ -47,18 +47,18 @@ pub enum Color {
 
 #[cfg(feature = "gecko")]
 mod gecko {
     #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToCss)]
     pub enum SpecialColorKeyword {
         MozDefaultColor,
         MozDefaultBackgroundColor,
         MozHyperlinktext,
-        MozActiveHyperlinktext,
-        MozVisitedHyperlinktext,
+        MozActivehyperlinktext,
+        MozVisitedhyperlinktext,
     }
 }
 
 impl From<RGBA> for Color {
     fn from(value: RGBA) -> Self {
         Color::rgba(value)
     }
 }
@@ -155,22 +155,24 @@ impl Parse for Color {
                         parsed: rgba,
                         authored: authored.map(|s| s.to_ascii_lowercase().into_boxed_str()),
                     },
                 })
             }
             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));
+                        }
                     }
                 }
 
                 match e.kind {
                     ParseErrorKind::Basic(BasicParseErrorKind::UnexpectedToken(t)) => {
                         Err(e.location.new_custom_error(
                             StyleParseErrorKind::ValueError(ValueParseErrorKind::InvalidColor(t))
                         ))
@@ -363,18 +365,18 @@ impl Color {
             Color::Special(special) => {
                 use self::gecko::SpecialColorKeyword as Keyword;
                 _context.map(|context| {
                     let pres_context = context.device().pres_context();
                     convert_nscolor_to_computedcolor(match special {
                         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,
                     })
                 })
             }
             #[cfg(feature = "gecko")]
             Color::InheritFromBodyQuirk => {
                 _context.map(|context| {
                     ComputedColor::rgba(context.device().body_text_color())
                 })