From 5fb6acb753cb716f8e80fabae3633f8fd90baa80 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Thu, 23 Jul 2015 01:14:03 +0200 Subject: [PATCH] Rename DeclaredValue::SpecifiedValue to DeclaredValue::Value --- components/script/dom/element.rs | 32 ++++++++++++++--------------- components/style/properties.mako.rs | 22 ++++++++++---------- tests/unit/style/stylesheets.rs | 6 +++--- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index f128e25626e..8d55dcdcedd 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -62,7 +62,7 @@ use dom::virtualmethods::{VirtualMethods, vtable_for}; use devtools_traits::AttrInfo; use smallvec::VecLike; use style::legacy::{UnsignedIntegerAttribute, from_declaration}; -use style::properties::DeclaredValue::SpecifiedValue; +use style::properties::DeclaredValue; use style::properties::longhands::{self, background_image, border_spacing}; use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute}; use style::values::CSSFloat; @@ -271,7 +271,7 @@ impl RawLayoutElementHelpers for Element { if let Some(color) = bgcolor { hints.push(from_declaration( - PropertyDeclaration::BackgroundColor(SpecifiedValue( + PropertyDeclaration::BackgroundColor(DeclaredValue::Value( CSSColor { parsed: Color::RGBA(color), authored: None })))); } @@ -284,7 +284,7 @@ impl RawLayoutElementHelpers for Element { if let Some(url) = background { hints.push(from_declaration( - PropertyDeclaration::BackgroundImage(SpecifiedValue( + PropertyDeclaration::BackgroundImage(DeclaredValue::Value( background_image::SpecifiedValue(Some(specified::Image::Url(url))))))); } @@ -297,7 +297,7 @@ impl RawLayoutElementHelpers for Element { if let Some(color) = color { hints.push(from_declaration( - PropertyDeclaration::Color(SpecifiedValue(CSSRGBA { + PropertyDeclaration::Color(DeclaredValue::Value(CSSRGBA { parsed: color, authored: None, })))); @@ -313,7 +313,7 @@ impl RawLayoutElementHelpers for Element { if let Some(cellspacing) = cellspacing { let width_value = specified::Length::Absolute(Au::from_px(cellspacing as i32)); hints.push(from_declaration( - PropertyDeclaration::BorderSpacing(SpecifiedValue( + PropertyDeclaration::BorderSpacing(DeclaredValue::Value( border_spacing::SpecifiedValue { horizontal: width_value, vertical: width_value, @@ -343,7 +343,7 @@ impl RawLayoutElementHelpers for Element { let value = specified::Length::ServoCharacterWidth( specified::CharacterWidth(size)); hints.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue( + PropertyDeclaration::Width(DeclaredValue::Value( specified::LengthOrPercentageOrAuto::Length(value))))); } @@ -367,13 +367,13 @@ impl RawLayoutElementHelpers for Element { let width_value = specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); hints.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue(width_value)))); + PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); } LengthOrPercentageOrAuto::Length(length) => { let width_value = specified::LengthOrPercentageOrAuto::Length( specified::Length::Absolute(length)); hints.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue(width_value)))); + PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); } } @@ -391,13 +391,13 @@ impl RawLayoutElementHelpers for Element { let height_value = specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); hints.push(from_declaration( - PropertyDeclaration::Height(SpecifiedValue(height_value)))); + PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); } LengthOrPercentageOrAuto::Length(length) => { let height_value = specified::LengthOrPercentageOrAuto::Length( specified::Length::Absolute(length)); hints.push(from_declaration( - PropertyDeclaration::Height(SpecifiedValue(height_value)))); + PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); } } @@ -420,7 +420,7 @@ impl RawLayoutElementHelpers for Element { // https://html.spec.whatwg.org/multipage/#textarea-effective-width let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(cols)); hints.push(from_declaration( - PropertyDeclaration::Width(SpecifiedValue( + PropertyDeclaration::Width(DeclaredValue::Value( specified::LengthOrPercentageOrAuto::Length(value))))); } @@ -441,7 +441,7 @@ impl RawLayoutElementHelpers for Element { // https://html.spec.whatwg.org/multipage/#textarea-effective-height let value = specified::Length::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat)); hints.push(from_declaration( - PropertyDeclaration::Height(SpecifiedValue( + PropertyDeclaration::Height(DeclaredValue::Value( specified::LengthOrPercentageOrAuto::Length(value))))); } @@ -456,16 +456,16 @@ impl RawLayoutElementHelpers for Element { if let Some(border) = border { let width_value = specified::Length::Absolute(Au::from_px(border as i32)); hints.push(from_declaration( - PropertyDeclaration::BorderTopWidth(SpecifiedValue( + PropertyDeclaration::BorderTopWidth(DeclaredValue::Value( longhands::border_top_width::SpecifiedValue(width_value))))); hints.push(from_declaration( - PropertyDeclaration::BorderLeftWidth(SpecifiedValue( + PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value( longhands::border_left_width::SpecifiedValue(width_value))))); hints.push(from_declaration( - PropertyDeclaration::BorderBottomWidth(SpecifiedValue( + PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value( longhands::border_bottom_width::SpecifiedValue(width_value))))); hints.push(from_declaration( - PropertyDeclaration::BorderRightWidth(SpecifiedValue( + PropertyDeclaration::BorderRightWidth(DeclaredValue::Value( longhands::border_right_width::SpecifiedValue(width_value))))); } } diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index a2dd00916f1..8ab6d2442e9 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -156,7 +156,7 @@ pub mod longhands { } seen.set_${property.ident}(); let computed_value = match *declared_value { - DeclaredValue::SpecifiedValue(ref specified_value) => { + DeclaredValue::Value(ref specified_value) => { specified_value.to_computed_value(&context) } DeclaredValue::Initial => get_initial_value(), @@ -209,7 +209,7 @@ pub mod longhands { % if derived_from is None: pub fn parse_specified(context: &ParserContext, input: &mut Parser) -> Result, ()> { - parse(context, input).map(DeclaredValue::SpecifiedValue) + parse(context, input).map(DeclaredValue::Value) } % endif @@ -1653,7 +1653,7 @@ pub mod longhands { Color::RGBA(rgba) => rgba, Color::CurrentColor => return Ok(DeclaredValue::Inherit) }; - Ok(DeclaredValue::SpecifiedValue(CSSRGBA { + Ok(DeclaredValue::Value(CSSRGBA { parsed: rgba, authored: value.authored, })) @@ -5661,7 +5661,7 @@ impl CSSWideKeyword { #[derive(Clone, PartialEq, Eq, Copy, Debug)] pub enum DeclaredValue { - SpecifiedValue(T), + Value(T), Initial, Inherit, // There is no Unset variant here. @@ -5672,7 +5672,7 @@ pub enum DeclaredValue { impl DeclaredValue { pub fn specified_value(&self) -> String { match self { - &DeclaredValue::SpecifiedValue(ref inner) => inner.to_css_string(), + &DeclaredValue::Value(ref inner) => inner.to_css_string(), &DeclaredValue::Initial => "initial".to_owned(), &DeclaredValue::Inherit => "inherit".to_owned(), } @@ -5742,7 +5742,7 @@ impl PropertyDeclaration { Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit, Ok(CSSWideKeyword::InitialKeyword) => DeclaredValue::Initial, Err(()) => match ::custom_properties::parse(input) { - Ok(value) => DeclaredValue::SpecifiedValue(value), + Ok(value) => DeclaredValue::Value(value), Err(()) => return PropertyDeclarationParseResult::InvalidValue, } }; @@ -5808,7 +5808,7 @@ impl PropertyDeclaration { % for sub_property in shorthand.sub_properties: result_list.push(PropertyDeclaration::${sub_property.camel_case}( match result.${sub_property.ident} { - Some(value) => DeclaredValue::SpecifiedValue(value), + Some(value) => DeclaredValue::Value(value), None => DeclaredValue::Initial, } )); @@ -6122,7 +6122,7 @@ fn cascade_with_cached_declarations( } seen.set_${property.ident}(); let computed_value = match *declared_value { - DeclaredValue::SpecifiedValue(ref specified_value) + DeclaredValue::Value(ref specified_value) => specified_value.to_computed_value(context), DeclaredValue::Initial => longhands::${property.ident}::get_initial_value(), @@ -6277,7 +6277,7 @@ pub fn cascade(viewport_size: Size2D, macro_rules! get_specified( ($style_struct_getter: ident, $property: ident, $declared_value: expr) => { match *$declared_value { - DeclaredValue::SpecifiedValue(specified_value) => specified_value, + DeclaredValue::Value(specified_value) => specified_value, DeclaredValue::Initial => longhands::$property::get_initial_value(), DeclaredValue::Inherit => inherited_style.$style_struct_getter().$property.clone(), } @@ -6292,7 +6292,7 @@ pub fn cascade(viewport_size: Size2D, match *declaration { PropertyDeclaration::FontSize(ref value) => { context.font_size = match *value { - DeclaredValue::SpecifiedValue(ref specified_value) => { + DeclaredValue::Value(ref specified_value) => { match specified_value.0 { Length::FontRelative(value) => { value.to_computed_value(context.inherited_font_size, @@ -6310,7 +6310,7 @@ pub fn cascade(viewport_size: Size2D, } PropertyDeclaration::Color(ref value) => { context.color = match *value { - DeclaredValue::SpecifiedValue(ref specified_value) => { + DeclaredValue::Value(ref specified_value) => { specified_value.parsed } DeclaredValue::Initial => longhands::color::get_initial_value(), diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index 2f1cc1fc3be..8d133e8820e 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -52,7 +52,7 @@ fn test_parse_stylesheet() { declarations: PropertyDeclarationBlock { normal: Arc::new(vec![]), important: Arc::new(vec![ - PropertyDeclaration::Display(DeclaredValue::SpecifiedValue( + PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::none)), ]), }, @@ -90,7 +90,7 @@ fn test_parse_stylesheet() { ], declarations: PropertyDeclarationBlock { normal: Arc::new(vec![ - PropertyDeclaration::Display(DeclaredValue::SpecifiedValue( + PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::block)), ]), important: Arc::new(vec![]), @@ -123,7 +123,7 @@ fn test_parse_stylesheet() { PropertyDeclaration::BackgroundAttachment(DeclaredValue::Initial), PropertyDeclaration::BackgroundRepeat(DeclaredValue::Initial), PropertyDeclaration::BackgroundPosition(DeclaredValue::Initial), - PropertyDeclaration::BackgroundColor(DeclaredValue::SpecifiedValue( + PropertyDeclaration::BackgroundColor(DeclaredValue::Value( longhands::background_color::SpecifiedValue { authored: Some("blue".to_owned()), parsed: cssparser::Color::RGBA(cssparser::RGBA {