From 03f6d21cb5fbeca705bd43776de260c2942830a7 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Tue, 28 Feb 2017 18:53:51 +1100 Subject: [PATCH] Make DeclaredValue store CSSWideKeyword Rather than having separate variant for each CSS-wide keyword. --- components/style/custom_properties.rs | 12 ++-- components/style/properties/helpers.mako.rs | 66 ++++++++++--------- .../helpers/animated_properties.mako.rs | 34 +++++----- .../style/properties/properties.mako.rs | 58 +++++++--------- .../style/properties/shorthand/box.mako.rs | 10 ++- .../style/properties/shorthand/list.mako.rs | 9 ++- .../properties/shorthand/outline.mako.rs | 5 +- .../properties/shorthand/position.mako.rs | 6 +- tests/unit/style/properties/serialization.rs | 29 ++++---- tests/unit/style/stylesheets.rs | 6 +- 10 files changed, 120 insertions(+), 115 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 9edeb7a04e3..d3d6e0aa6f7 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -9,7 +9,7 @@ use Atom; use cssparser::{Delimiter, Parser, SourcePosition, Token, TokenSerializationType}; use parser::ParserContext; -use properties::DeclaredValue; +use properties::{CSSWideKeyword, DeclaredValue}; use std::ascii::AsciiExt; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; @@ -362,11 +362,13 @@ pub fn cascade<'a>(custom_properties: &mut Option unreachable!(), - DeclaredValue::Initial => { - map.remove(&name); + DeclaredValue::CSSWideKeyword(keyword) => match keyword { + CSSWideKeyword::Initial => { + map.remove(&name); + } + CSSWideKeyword::Unset | // Custom properties are inherited by default. + CSSWideKeyword::Inherit => {} // The inherited value is what we already have. } - DeclaredValue::Unset | // Custom properties are inherited by default. - DeclaredValue::Inherit => {} // The inherited value is what we already have. } } diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 28c5fdb4f35..63aac61900a 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -267,30 +267,32 @@ % endif } DeclaredValue::WithVariables(_) => unreachable!(), - % if not data.current_style_struct.inherited: - DeclaredValue::Unset | - % endif - DeclaredValue::Initial => { - // We assume that it's faster to use copy_*_from rather than - // set_*(get_initial_value()); - let initial_struct = default_style - .get_${data.current_style_struct.name_lower}(); - context.mutate_style().mutate_${data.current_style_struct.name_lower}() - .copy_${property.ident}_from(initial_struct ${maybe_wm}); - }, - % if data.current_style_struct.inherited: - DeclaredValue::Unset | - % endif - DeclaredValue::Inherit => { - // This is a bit slow, but this is rare so it shouldn't - // matter. - // - // FIXME: is it still? - *cacheable = false; - let inherited_struct = - inherited_style.get_${data.current_style_struct.name_lower}(); - context.mutate_style().mutate_${data.current_style_struct.name_lower}() - .copy_${property.ident}_from(inherited_struct ${maybe_wm}); + DeclaredValue::CSSWideKeyword(keyword) => match keyword { + % if not data.current_style_struct.inherited: + CSSWideKeyword::Unset | + % endif + CSSWideKeyword::Initial => { + // We assume that it's faster to use copy_*_from rather than + // set_*(get_initial_value()); + let initial_struct = default_style + .get_${data.current_style_struct.name_lower}(); + context.mutate_style().mutate_${data.current_style_struct.name_lower}() + .copy_${property.ident}_from(initial_struct ${maybe_wm}); + }, + % if data.current_style_struct.inherited: + CSSWideKeyword::Unset | + % endif + CSSWideKeyword::Inherit => { + // This is a bit slow, but this is rare so it shouldn't + // matter. + // + // FIXME: is it still? + *cacheable = false; + let inherited_struct = + inherited_style.get_${data.current_style_struct.name_lower}(); + context.mutate_style().mutate_${data.current_style_struct.name_lower}() + .copy_${property.ident}_from(inherited_struct ${maybe_wm}); + } } } }, error_reporter); @@ -324,9 +326,7 @@ -> Result, ()> { % endif match input.try(|i| CSSWideKeyword::parse(context, i)) { - Ok(CSSWideKeyword::Inherit) => Ok(DeclaredValue::Inherit), - Ok(CSSWideKeyword::Initial) => Ok(DeclaredValue::Initial), - Ok(CSSWideKeyword::Unset) => Ok(DeclaredValue::Unset), + Ok(keyword) => Ok(DeclaredValue::CSSWideKeyword(keyword)), Err(()) => { input.look_for_var_functions(); let start = input.position(); @@ -483,8 +483,8 @@ #[allow(unused_imports)] use cssparser::Parser; use parser::ParserContext; - use properties::{DeclaredValue, PropertyDeclaration, UnparsedValue}; - use properties::{ShorthandId, longhands}; + use properties::{CSSWideKeyword, DeclaredValue, PropertyDeclaration}; + use properties::{ShorthandId, UnparsedValue, longhands}; use properties::declaration_block::Importance; use std::fmt; use style_traits::ToCss; @@ -563,9 +563,11 @@ let mut with_variables = false; % for sub_property in shorthand.sub_properties: match *self.${sub_property.ident} { - DeclaredValue::Initial => all_flags &= ALL_INITIAL, - DeclaredValue::Inherit => all_flags &= ALL_INHERIT, - DeclaredValue::Unset => all_flags &= ALL_UNSET, + DeclaredValue::CSSWideKeyword(keyword) => match keyword { + CSSWideKeyword::Initial => all_flags &= ALL_INITIAL, + CSSWideKeyword::Inherit => all_flags &= ALL_INHERIT, + CSSWideKeyword::Unset => all_flags &= ALL_UNSET, + }, DeclaredValue::WithVariables(_) => with_variables = true, DeclaredValue::Value(..) => { all_flags = SerializeFlags::empty(); diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 9b0d2cc6bb3..0a9e5cd3ae6 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -8,7 +8,7 @@ use app_units::Au; use cssparser::{Color as CSSParserColor, Parser, RGBA}; use euclid::{Point2D, Size2D}; #[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID; -use properties::{DeclaredValue, PropertyDeclaration}; +use properties::{CSSWideKeyword, DeclaredValue, PropertyDeclaration}; use properties::longhands; use properties::longhands::background_size::computed_value::T as BackgroundSize; use properties::longhands::font_weight::computed_value::T as FontWeight; @@ -287,21 +287,23 @@ impl AnimationValue { // https://bugzilla.mozilla.org/show_bug.cgi?id=1326131 DeclaredValue::WithVariables(_) => unimplemented!(), DeclaredValue::Value(ref val) => val.to_computed_value(context), - % if not prop.style_struct.inherited: - DeclaredValue::Unset | - % endif - DeclaredValue::Initial => { - let initial_struct = initial.get_${prop.style_struct.name_lower}(); - initial_struct.clone_${prop.ident}() - }, - % if prop.style_struct.inherited: - DeclaredValue::Unset | - % endif - DeclaredValue::Inherit => { - let inherit_struct = context.inherited_style - .get_${prop.style_struct.name_lower}(); - inherit_struct.clone_${prop.ident}() - }, + DeclaredValue::CSSWideKeyword(keyword) => match keyword { + % if not prop.style_struct.inherited: + CSSWideKeyword::Unset | + % endif + CSSWideKeyword::Initial => { + let initial_struct = initial.get_${prop.style_struct.name_lower}(); + initial_struct.clone_${prop.ident}() + }, + % if prop.style_struct.inherited: + CSSWideKeyword::Unset | + % endif + CSSWideKeyword::Inherit => { + let inherit_struct = context.inherited_style + .get_${prop.style_struct.name_lower}(); + inherit_struct.clone_${prop.ident}() + }, + } }; Some(AnimationValue::${prop.camel_case}(computed)) } diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index c0f887a9a3c..d841b7e555a 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -365,7 +365,13 @@ impl PropertyDeclarationIdSet { }) .unwrap_or( // Invalid at computed-value time. - DeclaredValue::${"Inherit" if property.style_struct.inherited else "Initial"} + DeclaredValue::CSSWideKeyword( + % if property.style_struct.inherited: + CSSWideKeyword::Inherit + % else: + CSSWideKeyword::Initial + % endif + ) ) ); } @@ -374,6 +380,7 @@ impl PropertyDeclarationIdSet { /// An enum to represent a CSS Wide keyword. #[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum CSSWideKeyword { /// The `initial` keyword. Initial, @@ -383,6 +390,16 @@ pub enum CSSWideKeyword { Unset, } +impl ToCss for CSSWideKeyword { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + dest.write_str(match *self { + CSSWideKeyword::Initial => "initial", + CSSWideKeyword::Inherit => "inherit", + CSSWideKeyword::Unset => "unset", + }) + } +} + impl Parse for CSSWideKeyword { fn parse(_context: &ParserContext, input: &mut Parser) -> Result { let ident = input.expect_ident()?; @@ -545,12 +562,8 @@ pub enum DeclaredValue { Value(T), /// An unparsed value that contains `var()` functions. WithVariables(Box), - /// The `initial` keyword. - Initial, - /// The `inherit` keyword. - Inherit, - /// The `unset` keyword. - Unset, + /// An CSS-wide keyword. + CSSWideKeyword(CSSWideKeyword), } /// An unparsed property value that contains `var()` functions. @@ -575,9 +588,7 @@ impl HasViewportPercentage for DeclaredValue { panic!("DeclaredValue::has_viewport_percentage without \ resolving variables!") }, - DeclaredValue::Initial | - DeclaredValue::Inherit | - DeclaredValue::Unset => false, + DeclaredValue::CSSWideKeyword(_) => false, } } } @@ -595,9 +606,7 @@ impl ToCss for DeclaredValue { } Ok(()) }, - DeclaredValue::Initial => dest.write_str("initial"), - DeclaredValue::Inherit => dest.write_str("inherit"), - DeclaredValue::Unset => dest.write_str("unset"), + DeclaredValue::CSSWideKeyword(ref keyword) => keyword.to_css(dest), } } } @@ -969,9 +978,7 @@ impl PropertyDeclaration { match id { PropertyId::Custom(name) => { let value = match input.try(|i| CSSWideKeyword::parse(context, i)) { - Ok(CSSWideKeyword::Unset) => DeclaredValue::Unset, - Ok(CSSWideKeyword::Inherit) => DeclaredValue::Inherit, - Ok(CSSWideKeyword::Initial) => DeclaredValue::Initial, + Ok(keyword) => DeclaredValue::CSSWideKeyword(keyword), Err(()) => match ::custom_properties::SpecifiedValue::parse(context, input) { Ok(value) => DeclaredValue::Value(value), Err(()) => return PropertyDeclarationParseResult::InvalidValue, @@ -1029,26 +1036,11 @@ impl PropertyDeclaration { ${property_pref_check(shorthand)} match input.try(|i| CSSWideKeyword::parse(context, i)) { - Ok(CSSWideKeyword::Inherit) => { + Ok(keyword) => { % for sub_property in shorthand.sub_properties: result_list.push(( PropertyDeclaration::${sub_property.camel_case}( - DeclaredValue::Inherit), Importance::Normal)); - % endfor - PropertyDeclarationParseResult::ValidOrIgnoredDeclaration - }, - Ok(CSSWideKeyword::Initial) => { - % for sub_property in shorthand.sub_properties: - result_list.push(( - PropertyDeclaration::${sub_property.camel_case}( - DeclaredValue::Initial), Importance::Normal)); - % endfor - PropertyDeclarationParseResult::ValidOrIgnoredDeclaration - }, - Ok(CSSWideKeyword::Unset) => { - % for sub_property in shorthand.sub_properties: - result_list.push((PropertyDeclaration::${sub_property.camel_case}( - DeclaredValue::Unset), Importance::Normal)); + DeclaredValue::CSSWideKeyword(keyword)), Importance::Normal)); % endfor PropertyDeclarationParseResult::ValidOrIgnoredDeclaration }, diff --git a/components/style/properties/shorthand/box.mako.rs b/components/style/properties/shorthand/box.mako.rs index d1b7ccb62f5..80cb4e091ff 100644 --- a/components/style/properties/shorthand/box.mako.rs +++ b/components/style/properties/shorthand/box.mako.rs @@ -23,9 +23,8 @@ *x_value == y_container.0 }, (&DeclaredValue::WithVariables(_), &DeclaredValue::WithVariables(_)) => true, - (&DeclaredValue::Initial, &DeclaredValue::Initial) => true, - (&DeclaredValue::Inherit, &DeclaredValue::Inherit) => true, - (&DeclaredValue::Unset, &DeclaredValue::Unset) => true, + (&DeclaredValue::CSSWideKeyword(x_keyword), + &DeclaredValue::CSSWideKeyword(y_keyword)) => x_keyword == y_keyword, _ => false }; @@ -359,9 +358,8 @@ macro_rules! try_parse_one { (&DeclaredValue::Value(ref x_value), &DeclaredValue::Value(ref y_value)) => { *x_value == *y_value }, - (&DeclaredValue::Initial, &DeclaredValue::Initial) => true, - (&DeclaredValue::Inherit, &DeclaredValue::Inherit) => true, - (&DeclaredValue::Unset, &DeclaredValue::Unset) => true, + (&DeclaredValue::CSSWideKeyword(x_keyword), + &DeclaredValue::CSSWideKeyword(y_keyword)) => x_keyword == y_keyword, (x, y) => { *x == *y }, }; diff --git a/components/style/properties/shorthand/list.mako.rs b/components/style/properties/shorthand/list.mako.rs index 6f1c8707fe0..7e44ec1c4ff 100644 --- a/components/style/properties/shorthand/list.mako.rs +++ b/components/style/properties/shorthand/list.mako.rs @@ -99,21 +99,24 @@ impl<'a> LonghandsToSerialize<'a> { fn to_css_declared(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self.list_style_position { - DeclaredValue::Initial => try!(write!(dest, "outside")), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => + try!(write!(dest, "outside")), _ => try!(self.list_style_position.to_css(dest)) } try!(write!(dest, " ")); match *self.list_style_image { - DeclaredValue::Initial => try!(write!(dest, "none")), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => + try!(write!(dest, "none")), _ => try!(self.list_style_image.to_css(dest)) }; try!(write!(dest, " ")); match *self.list_style_type { - DeclaredValue::Initial => write!(dest, "disc"), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => + write!(dest, "disc"), _ => self.list_style_type.to_css(dest) } } diff --git a/components/style/properties/shorthand/outline.mako.rs b/components/style/properties/shorthand/outline.mako.rs index 803a80afff9..84d6300ad0e 100644 --- a/components/style/properties/shorthand/outline.mako.rs +++ b/components/style/properties/shorthand/outline.mako.rs @@ -57,12 +57,13 @@ try!(write!(dest, " ")); match *self.outline_style { - DeclaredValue::Initial => try!(write!(dest, "none")), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => + try!(write!(dest, "none")), _ => try!(self.outline_style.to_css(dest)) }; match *self.outline_color { - DeclaredValue::Initial => Ok(()), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => Ok(()), _ => { try!(write!(dest, " ")); self.outline_color.to_css(dest) diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthand/position.mako.rs index 78286951dae..b3bac37b41d 100644 --- a/components/style/properties/shorthand/position.mako.rs +++ b/components/style/properties/shorthand/position.mako.rs @@ -40,14 +40,16 @@ impl<'a> LonghandsToSerialize<'a> { fn to_css_declared(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self.flex_direction { - DeclaredValue::Initial => try!(write!(dest, "row")), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => + try!(write!(dest, "row")), _ => try!(self.flex_direction.to_css(dest)) }; try!(write!(dest, " ")); match *self.flex_wrap { - DeclaredValue::Initial => write!(dest, "nowrap"), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial) => + write!(dest, "nowrap"), _ => self.flex_wrap.to_css(dest) } } diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index fd16fe3f71b..262a1a5ea29 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -7,7 +7,8 @@ use media_queries::CSSErrorReporterTest; use servo_url::ServoUrl; use style::computed_values::display::T::inline_block; use style::parser::ParserContext; -use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock, Importance, PropertyId}; +use style::properties::{CSSWideKeyword, DeclaredValue, PropertyDeclaration}; +use style::properties::{PropertyDeclarationBlock, Importance, PropertyId}; use style::properties::longhands::outline_color::computed_value::T as ComputedColor; use style::properties::parse_property_declaration_list; use style::stylesheets::Origin; @@ -376,7 +377,7 @@ mod shorthand_serialization { let mut properties = Vec::new(); let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); - let style = DeclaredValue::Initial; + let style = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); let color = DeclaredValue::Value(CSSColor { parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), authored: None @@ -396,7 +397,7 @@ mod shorthand_serialization { let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let style = DeclaredValue::Value(BorderStyle::solid); - let color = DeclaredValue::Initial; + let color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopStyle(style)); @@ -412,7 +413,7 @@ mod shorthand_serialization { let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let style = DeclaredValue::Value(BorderStyle::solid); - let color = DeclaredValue::Initial; + let color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderRightWidth(width)); properties.push(PropertyDeclaration::BorderRightStyle(style)); @@ -428,7 +429,7 @@ mod shorthand_serialization { let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let style = DeclaredValue::Value(BorderStyle::solid); - let color = DeclaredValue::Initial; + let color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderBottomWidth(width)); properties.push(PropertyDeclaration::BorderBottomStyle(style)); @@ -444,7 +445,7 @@ mod shorthand_serialization { let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let style = DeclaredValue::Value(BorderStyle::solid); - let color = DeclaredValue::Initial; + let color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderLeftWidth(width)); properties.push(PropertyDeclaration::BorderLeftStyle(style)); @@ -460,7 +461,7 @@ mod shorthand_serialization { let top_width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let top_style = DeclaredValue::Value(BorderStyle::solid); - let top_color = DeclaredValue::Initial; + let top_color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderTopWidth(top_width)); properties.push(PropertyDeclaration::BorderTopStyle(top_style)); @@ -468,7 +469,7 @@ mod shorthand_serialization { let right_width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let right_style = DeclaredValue::Value(BorderStyle::solid); - let right_color = DeclaredValue::Initial; + let right_color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderRightWidth(right_width)); properties.push(PropertyDeclaration::BorderRightStyle(right_style)); @@ -476,7 +477,7 @@ mod shorthand_serialization { let bottom_width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let bottom_style = DeclaredValue::Value(BorderStyle::solid); - let bottom_color = DeclaredValue::Initial; + let bottom_color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderBottomWidth(bottom_width)); properties.push(PropertyDeclaration::BorderBottomStyle(bottom_style)); @@ -484,7 +485,7 @@ mod shorthand_serialization { let left_width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let left_style = DeclaredValue::Value(BorderStyle::solid); - let left_color = DeclaredValue::Initial; + let left_color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::BorderLeftWidth(left_width)); properties.push(PropertyDeclaration::BorderLeftStyle(left_style)); @@ -522,8 +523,8 @@ mod shorthand_serialization { fn list_style_should_show_all_properties_even_if_only_one_is_set() { let mut properties = Vec::new(); - let position = DeclaredValue::Initial; - let image = DeclaredValue::Initial; + let position = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); + let image = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); let style_type = DeclaredValue::Value(ListStyleType::disc); properties.push(PropertyDeclaration::ListStylePosition(position)); @@ -565,7 +566,7 @@ mod shorthand_serialization { let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32))); let style = DeclaredValue::Value(Either::Second(BorderStyle::solid)); - let color = DeclaredValue::Initial; + let color = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); properties.push(PropertyDeclaration::OutlineWidth(width)); properties.push(PropertyDeclaration::OutlineStyle(style)); @@ -580,7 +581,7 @@ mod shorthand_serialization { let mut properties = Vec::new(); let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32))); - let style = DeclaredValue::Initial; + let style = DeclaredValue::CSSWideKeyword(CSSWideKeyword::Initial); let color = DeclaredValue::Value(CSSColor { parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), authored: None diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index f391b7d429f..83166e019e5 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -17,7 +17,8 @@ use style::error_reporting::ParseErrorReporter; use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage}; use style::parser::ParserContextExtraData; use style::properties::Importance; -use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands}; +use style::properties::{CSSWideKeyword, PropertyDeclaration, PropertyDeclarationBlock}; +use style::properties::{DeclaredValue, longhands}; use style::properties::longhands::animation_play_state; use style::stylesheets::{Origin, Namespaces}; use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule}; @@ -102,7 +103,8 @@ fn test_parse_stylesheet() { (PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::none)), Importance::Important), - (PropertyDeclaration::Custom(Atom::from("a"), DeclaredValue::Inherit), + (PropertyDeclaration::Custom(Atom::from("a"), + DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)), Importance::Important), ], important_count: 2,