From 8cf331a49891dfe59be22995c65f706ccbc994d4 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 15 Mar 2017 11:59:53 -0700 Subject: [PATCH] Rearrange PropertyDeclaration to avoid embedding DeclaredValue. From https://bugzilla.mozilla.org/show_bug.cgi?id=1347719 This effectively combines the discriminants of the two enums and reduces the size of PropertyDeclaration by one word. MozReview-Commit-ID: 9rCRiSVZTQT --- components/script/dom/element.rs | 52 +++-- components/style/custom_properties.rs | 4 +- components/style/keyframes.rs | 13 +- components/style/properties/gecko.mako.rs | 6 +- components/style/properties/helpers.mako.rs | 47 +++-- .../helpers/animated_properties.mako.rs | 85 ++++---- .../style/properties/properties.mako.rs | 192 +++++++++++------- ports/geckolib/glue.rs | 26 +-- tests/unit/style/keyframes.rs | 18 +- tests/unit/style/properties/serialization.rs | 186 +++++++++-------- tests/unit/style/properties/viewport.rs | 10 +- tests/unit/style/rule_tree/bench.rs | 6 +- tests/unit/style/stylesheets.rs | 60 +++--- tests/unit/style/stylist.rs | 6 +- 14 files changed, 378 insertions(+), 333 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 33b2ccb9b7f..dcafd4bf9d7 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -103,8 +103,7 @@ use style::context::{QuirksMode, ReflowGoal}; use style::element_state::*; use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes}; use style::parser::ParserContextExtraData; -use style::properties::{DeclaredValue, Importance}; -use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; +use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x}; use style::restyle_hints::RESTYLE_SELF; use style::rule_tree::CascadeLevel; @@ -409,8 +408,8 @@ impl LayoutElementHelpers for LayoutJS { if let Some(color) = bgcolor { hints.push(from_declaration( - PropertyDeclaration::BackgroundColor(DeclaredValue::Value( - CSSColor { parsed: Color::RGBA(color), authored: None })))); + PropertyDeclaration::BackgroundColor( + CSSColor { parsed: Color::RGBA(color), authored: None }))); } let background = if let Some(this) = self.downcast::() { @@ -421,12 +420,12 @@ impl LayoutElementHelpers for LayoutJS { if let Some(url) = background { hints.push(from_declaration( - PropertyDeclaration::BackgroundImage(DeclaredValue::Value( + PropertyDeclaration::BackgroundImage( background_image::SpecifiedValue(vec![ background_image::single_value::SpecifiedValue(Some( specified::Image::for_cascade(url.into(), specified::url::UrlExtraData { }) )) - ]))))); + ])))); } let color = if let Some(this) = self.downcast::() { @@ -443,12 +442,12 @@ impl LayoutElementHelpers for LayoutJS { if let Some(color) = color { hints.push(from_declaration( - PropertyDeclaration::Color(DeclaredValue::Value( + PropertyDeclaration::Color( longhands::color::SpecifiedValue(CSSColor { parsed: Color::RGBA(color), authored: None, }) - )) + ) )); } @@ -461,19 +460,16 @@ impl LayoutElementHelpers for LayoutJS { if let Some(font_family) = font_family { hints.push(from_declaration( PropertyDeclaration::FontFamily( - DeclaredValue::Value( font_family::computed_value::T(vec![ font_family::computed_value::FontFamily::from_atom( - font_family)]))))); + font_family)])))); } let font_size = self.downcast::().and_then(|this| this.get_size()); if let Some(font_size) = font_size { hints.push(from_declaration( - PropertyDeclaration::FontSize( - DeclaredValue::Value( - font_size::SpecifiedValue(font_size.into()))))) + PropertyDeclaration::FontSize(font_size::SpecifiedValue(font_size.into())))) } let cellspacing = if let Some(this) = self.downcast::() { @@ -485,11 +481,11 @@ impl LayoutElementHelpers for LayoutJS { if let Some(cellspacing) = cellspacing { let width_value = specified::Length::from_px(cellspacing as f32); hints.push(from_declaration( - PropertyDeclaration::BorderSpacing(DeclaredValue::Value( + PropertyDeclaration::BorderSpacing( Box::new(border_spacing::SpecifiedValue { horizontal: width_value.clone(), vertical: width_value, - }))))); + })))); } @@ -518,8 +514,8 @@ impl LayoutElementHelpers for LayoutJS { if let Some(size) = size { let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value( - specified::LengthOrPercentageOrAuto::Length(value))))); + PropertyDeclaration::Width( + specified::LengthOrPercentageOrAuto::Length(value)))); } let width = if let Some(this) = self.downcast::() { @@ -543,13 +539,13 @@ impl LayoutElementHelpers for LayoutJS { let width_value = specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); + PropertyDeclaration::Width(width_value))); } LengthOrPercentageOrAuto::Length(length) => { let width_value = specified::LengthOrPercentageOrAuto::Length( specified::NoCalcLength::Absolute(length)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); + PropertyDeclaration::Width(width_value))); } } @@ -568,13 +564,13 @@ impl LayoutElementHelpers for LayoutJS { let height_value = specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); hints.push(from_declaration( - PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); + PropertyDeclaration::Height(height_value))); } LengthOrPercentageOrAuto::Length(length) => { let height_value = specified::LengthOrPercentageOrAuto::Length( specified::NoCalcLength::Absolute(length)); hints.push(from_declaration( - PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); + PropertyDeclaration::Height(height_value))); } } @@ -596,8 +592,7 @@ impl LayoutElementHelpers for LayoutJS { // https://html.spec.whatwg.org/multipage/#textarea-effective-width let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols)); hints.push(from_declaration( - PropertyDeclaration::Width(DeclaredValue::Value( - specified::LengthOrPercentageOrAuto::Length(value))))); + PropertyDeclaration::Width(specified::LengthOrPercentageOrAuto::Length(value)))); } let rows = if let Some(this) = self.downcast::() { @@ -615,8 +610,7 @@ impl LayoutElementHelpers for LayoutJS { // https://html.spec.whatwg.org/multipage/#textarea-effective-height let value = specified::NoCalcLength::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat)); hints.push(from_declaration( - PropertyDeclaration::Height(DeclaredValue::Value( - specified::LengthOrPercentageOrAuto::Length(value))))); + PropertyDeclaration::Height(specified::LengthOrPercentageOrAuto::Length(value)))); } @@ -629,13 +623,13 @@ impl LayoutElementHelpers for LayoutJS { if let Some(border) = border { let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32)); hints.push(from_declaration( - PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(width_value.clone())))); + PropertyDeclaration::BorderTopWidth(width_value.clone()))); hints.push(from_declaration( - PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(width_value.clone())))); + PropertyDeclaration::BorderLeftWidth(width_value.clone()))); hints.push(from_declaration( - PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(width_value.clone())))); + PropertyDeclaration::BorderBottomWidth(width_value.clone()))); hints.push(from_declaration( - PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(width_value)))); + PropertyDeclaration::BorderRightWidth(width_value))); } } diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index d3d6e0aa6f7..95e43b46fdf 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -329,7 +329,7 @@ pub fn cascade<'a>(custom_properties: &mut Option>>, seen: &mut HashSet<&'a Name>, name: &'a Name, - specified_value: &'a DeclaredValue>) { + specified_value: DeclaredValue<'a, Box>) { let was_already_present = !seen.insert(name); if was_already_present { return; @@ -352,7 +352,7 @@ pub fn cascade<'a>(custom_properties: &mut Option { map.insert(name, BorrowedSpecifiedValue { css: &specified_value.css, diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 068dc169e9e..69aeb669dcc 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -11,7 +11,7 @@ use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule}; use parking_lot::RwLock; use parser::{ParserContext, ParserContextExtraData, log_css_error}; use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId}; -use properties::{PropertyDeclarationId, LonghandId, DeclaredValue, ParsedDeclaration}; +use properties::{PropertyDeclarationId, LonghandId, ParsedDeclaration}; use properties::LonghandIdSet; use properties::animated_properties::TransitionProperty; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; @@ -210,14 +210,11 @@ impl KeyframesStep { guard.get(PropertyDeclarationId::Longhand(LonghandId::AnimationTimingFunction)).unwrap(); match *declaration { PropertyDeclaration::AnimationTimingFunction(ref value) => { - match *value { - DeclaredValue::Value(ref value) => { - // Use the first value. - Some(value.0[0]) - }, - _ => None, - } + // Use the first value. + Some(value.0[0]) }, + PropertyDeclaration::CSSWideKeyword(..) => None, + PropertyDeclaration::WithVariables(..) => None, _ => panic!(), } }, diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 8d6ceeeb59c..421359c56d3 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -53,7 +53,7 @@ use gecko::values::GeckoStyleCoordConvertible; use gecko::values::round_border_to_device_pixels; use logical_geometry::WritingMode; use properties::longhands; -use properties::{DeclaredValue, Importance, LonghandId}; +use properties::{Importance, LonghandId}; use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId}; use std::fmt::{self, Debug}; use std::mem::{forget, transmute, zeroed}; @@ -169,7 +169,7 @@ impl ComputedValues { % if prop.animatable: PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => { PropertyDeclarationBlock::with_one( - PropertyDeclaration::${prop.camel_case}(DeclaredValue::Value( + PropertyDeclaration::${prop.camel_case}( % if prop.boxed: Box::new( % endif @@ -178,7 +178,7 @@ impl ComputedValues { % if prop.boxed: ) % endif - )), + ), Importance::Normal ) }, diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 48214966928..f6c5dd29994 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -70,7 +70,7 @@ pub mod single_value { use cssparser::Parser; use parser::{Parse, ParserContext, ParserContextExtraData}; - use properties::{DeclaredValue, ShorthandId}; + use properties::ShorthandId; use values::computed::{Context, ToComputedValue}; use values::{computed, specified}; use values::{Auto, Either, None_, Normal}; @@ -210,13 +210,13 @@ % if not property.derived_from: use cssparser::Parser; use parser::{Parse, ParserContext, ParserContextExtraData}; - use properties::{DeclaredValue, UnparsedValue, ShorthandId}; + use properties::{UnparsedValue, ShorthandId}; % endif use values::{Auto, Either, None_, Normal}; use cascade_info::CascadeInfo; use error_reporting::ParseErrorReporter; use properties::longhands; - use properties::LonghandIdSet; + use properties::{DeclaredValue, LonghandId, LonghandIdSet}; use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; use properties::style_structs; use std::boxed::Box as StdBox; @@ -235,9 +235,17 @@ cascade_info: &mut Option<<&mut CascadeInfo>, error_reporter: &ParseErrorReporter) { let declared_value = match *declaration { - PropertyDeclaration::${property.camel_case}(ref declared_value) => { - declared_value - } + PropertyDeclaration::${property.camel_case}(ref value) => { + DeclaredValue::Value(value) + }, + PropertyDeclaration::CSSWideKeyword(id, value) => { + debug_assert!(id == LonghandId::${property.camel_case}); + DeclaredValue::CSSWideKeyword(value) + }, + PropertyDeclaration::WithVariables(id, ref value) => { + debug_assert!(id == LonghandId::${property.camel_case}); + DeclaredValue::WithVariables(value) + }, _ => panic!("entered the wrong cascade_property() implementation"), }; @@ -245,7 +253,7 @@ { let custom_props = context.style().custom_properties(); ::properties::substitute_variables_${property.ident}( - declared_value, &custom_props, + &declared_value, &custom_props, |value| { if let Some(ref mut cascade_info) = *cascade_info { cascade_info.on_cascade_property(&declaration, @@ -312,21 +320,17 @@ % if not property.derived_from: pub fn parse_specified(context: &ParserContext, input: &mut Parser) % if property.boxed: - -> Result>, ()> { - parse(context, input).map(|result| DeclaredValue::Value(Box::new(result))) + -> Result, ()> { + parse(context, input).map(|result| Box::new(result)) % else: - -> Result, ()> { - parse(context, input).map(DeclaredValue::Value) + -> Result { + parse(context, input) % endif } pub fn parse_declared(context: &ParserContext, input: &mut Parser) - % if property.boxed: - -> Result>, ()> { - % else: - -> Result, ()> { - % endif + -> Result { match input.try(|i| CSSWideKeyword::parse(context, i)) { - Ok(keyword) => Ok(DeclaredValue::CSSWideKeyword(keyword)), + Ok(keyword) => Ok(PropertyDeclaration::CSSWideKeyword(LonghandId::${property.camel_case}, keyword)), Err(()) => { input.look_for_var_functions(); let start = input.position(); @@ -339,14 +343,15 @@ input.reset(start); let (first_token_type, css) = try!( ::custom_properties::parse_non_custom_with_var(input)); - return Ok(DeclaredValue::WithVariables(Arc::new(UnparsedValue { + return Ok(PropertyDeclaration::WithVariables(LonghandId::${property.camel_case}, + Arc::new(UnparsedValue { css: css.into_owned(), first_token_type: first_token_type, base_url: context.base_url.clone(), from_shorthand: None, }))) } - specified + specified.map(|s| PropertyDeclaration::${property.camel_case}(s)) } } } @@ -483,7 +488,7 @@ #[allow(unused_imports)] use cssparser::Parser; use parser::ParserContext; - use properties::{DeclaredValue, PropertyDeclaration, ParsedDeclaration}; + use properties::{PropertyDeclaration, ParsedDeclaration}; use properties::{ShorthandId, UnparsedValue, longhands}; use std::fmt; use std::sync::Arc; @@ -519,7 +524,7 @@ for longhand in iter { match *longhand { % for sub_property in shorthand.sub_properties: - PropertyDeclaration::${sub_property.camel_case}(DeclaredValue::Value(ref value)) => { + PropertyDeclaration::${sub_property.camel_case}(ref value) => { ${sub_property.ident} = Some(value) }, % endfor diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 3a94c383ca2..83c3f26c4ce 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::{CSSWideKeyword, DeclaredValue, PropertyDeclaration}; +use properties::{CSSWideKeyword, PropertyDeclaration}; use properties::longhands; use properties::longhands::background_size::computed_value::T as BackgroundSize; use properties::longhands::font_weight::computed_value::T as FontWeight; @@ -278,18 +278,17 @@ impl AnimationValue { /// "Uncompute" this animation value in order to be used inside the CSS /// cascade. pub fn uncompute(&self) -> PropertyDeclaration { - use properties::{longhands, DeclaredValue}; + use properties::longhands; match *self { % for prop in data.longhands: % if prop.animatable: AnimationValue::${prop.camel_case}(ref from) => { PropertyDeclaration::${prop.camel_case}( - DeclaredValue::Value( - % if prop.boxed: - Box::new(longhands::${prop.ident}::SpecifiedValue::from_computed_value(from)))) - % else: - longhands::${prop.ident}::SpecifiedValue::from_computed_value(from))) - % endif + % if prop.boxed: + Box::new(longhands::${prop.ident}::SpecifiedValue::from_computed_value(from))) + % else: + longhands::${prop.ident}::SpecifiedValue::from_computed_value(from)) + % endif } % endif % endfor @@ -298,36 +297,54 @@ impl AnimationValue { /// Construct an AnimationValue from a property declaration pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option { + use properties::LonghandId; match *decl { % for prop in data.longhands: - % if prop.animatable: - PropertyDeclaration::${prop.camel_case}(ref val) => { - let computed = match *val { - // https://bugzilla.mozilla.org/show_bug.cgi?id=1326131 - DeclaredValue::WithVariables(_) => unimplemented!(), - DeclaredValue::Value(ref val) => val.to_computed_value(context), - 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}() - }, - } + % if prop.animatable: + PropertyDeclaration::${prop.camel_case}(ref val) => { + Some(AnimationValue::${prop.camel_case}(val.to_computed_value(context))) + }, + % endif + % endfor + PropertyDeclaration::CSSWideKeyword(id, keyword) => { + match id { + // We put all the animatable properties first in the hopes + // that it might increase match locality. + % for prop in data.longhands: + % if prop.animatable: + LonghandId::${prop.camel_case} => { + let computed = 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)) - } - % endif - % endfor + }, + % endif + % endfor + % for prop in data.longhands: + % if not prop.animatable: + LonghandId::${prop.camel_case} => None, + % endif + % endfor + } + } + PropertyDeclaration::WithVariables(_, _) => { + // https://bugzilla.mozilla.org/show_bug.cgi?id=1326131 + unimplemented!() + }, _ => None // non animatable properties will get included because of shorthands. ignore. } } diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 59e91f6ce8c..b0d2b878bfc 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -342,7 +342,8 @@ impl PropertyDeclarationIdSet { Parser::new(&css).parse_entirely(|input| { match from_shorthand { None => { - longhands::${property.ident}::parse_specified(&context, input) + longhands::${property.ident} + ::parse_specified(&context, input).map(DeclaredValueOwned::Value) } % for shorthand in data.shorthands: % if property in shorthand.sub_properties: @@ -350,9 +351,9 @@ impl PropertyDeclarationIdSet { shorthands::${shorthand.ident}::parse_value(&context, input) .map(|result| { % if property.boxed: - DeclaredValue::Value(Box::new(result.${property.ident})) + DeclaredValueOwned::Value(Box::new(result.${property.ident})) % else: - DeclaredValue::Value(result.${property.ident}) + DeclaredValueOwned::Value(result.${property.ident}) % endif }) } @@ -364,14 +365,14 @@ impl PropertyDeclarationIdSet { }) .unwrap_or( // Invalid at computed-value time. - DeclaredValue::CSSWideKeyword( + DeclaredValueOwned::CSSWideKeyword( % if property.style_struct.inherited: CSSWideKeyword::Inherit % else: CSSWideKeyword::Initial % endif ) - ) + ).borrow() ); } % endif @@ -570,7 +571,21 @@ impl ShorthandId { /// Servo's representation of a declared value for a given `T`, which is the /// declared value for that property. #[derive(Clone, PartialEq, Eq, Debug)] -pub enum DeclaredValue { +pub enum DeclaredValue<'a, T: 'a> { + /// A known specified value from the stylesheet. + Value(&'a T), + /// An unparsed value that contains `var()` functions. + WithVariables(&'a Arc), + /// An CSS-wide keyword. + CSSWideKeyword(CSSWideKeyword), +} + +/// A variant of DeclaredValue that owns its data. This separation exists so +/// that PropertyDeclaration can avoid embedding a DeclaredValue (and its +/// extra discriminant word) and synthesize dependent DeclaredValues for +/// PropertyDeclaration instances as needed. +#[derive(Clone, PartialEq, Eq, Debug)] +pub enum DeclaredValueOwned { /// A known specified value from the stylesheet. Value(T), /// An unparsed value that contains `var()` functions. @@ -579,6 +594,17 @@ pub enum DeclaredValue { CSSWideKeyword(CSSWideKeyword), } +impl DeclaredValueOwned { + /// Creates a dependent DeclaredValue from this DeclaredValueOwned. + fn borrow(&self) -> DeclaredValue { + match *self { + DeclaredValueOwned::Value(ref v) => DeclaredValue::Value(v), + DeclaredValueOwned::WithVariables(ref v) => DeclaredValue::WithVariables(v), + DeclaredValueOwned::CSSWideKeyword(v) => DeclaredValue::CSSWideKeyword(v), + } + } +} + /// An unparsed property value that contains `var()` functions. #[derive(PartialEq, Eq, Debug)] pub struct UnparsedValue { @@ -592,7 +618,7 @@ pub struct UnparsedValue { from_shorthand: Option, } -impl HasViewportPercentage for DeclaredValue { +impl<'a, T: HasViewportPercentage> HasViewportPercentage for DeclaredValue<'a, T> { fn has_viewport_percentage(&self) -> bool { match *self { DeclaredValue::Value(ref v) => v.has_viewport_percentage(), @@ -605,7 +631,7 @@ impl HasViewportPercentage for DeclaredValue { } } -impl ToCss for DeclaredValue { +impl<'a, T: ToCss> ToCss for DeclaredValue<'a, T> { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write, { @@ -835,29 +861,25 @@ impl ParsedDeclaration { % for sub_property in shorthand.sub_properties: push(PropertyDeclaration::${sub_property.camel_case}( % if sub_property.boxed: - DeclaredValue::Value(Box::new(${sub_property.ident})) + Box::new(${sub_property.ident}) % else: - DeclaredValue::Value(${sub_property.ident}) + ${sub_property.ident} % endif )); % endfor - } + }, ParsedDeclaration::${shorthand.camel_case}CSSWideKeyword(keyword) => { % for sub_property in shorthand.sub_properties: - push(PropertyDeclaration::${sub_property.camel_case}( - DeclaredValue::CSSWideKeyword(keyword) - )); + push(PropertyDeclaration::CSSWideKeyword(LonghandId::${sub_property.camel_case}, keyword)); % endfor - } + }, ParsedDeclaration::${shorthand.camel_case}WithVariables(value) => { debug_assert_eq!( value.from_shorthand, Some(ShorthandId::${shorthand.camel_case}) ); % for sub_property in shorthand.sub_properties: - push(PropertyDeclaration::${sub_property.camel_case}( - DeclaredValue::WithVariables(value.clone()) - )); + push(PropertyDeclaration::WithVariables(LonghandId::${sub_property.camel_case}, value.clone())); % endfor } % endfor @@ -881,9 +903,9 @@ impl ParsedDeclaration { match id { PropertyId::Custom(name) => { let value = match input.try(|i| CSSWideKeyword::parse(context, i)) { - Ok(keyword) => DeclaredValue::CSSWideKeyword(keyword), + Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword), Err(()) => match ::custom_properties::SpecifiedValue::parse(context, input) { - Ok(value) => DeclaredValue::Value(value), + Ok(value) => DeclaredValueOwned::Value(value), Err(()) => return Err(PropertyDeclarationParseError::InvalidValue), } }; @@ -908,9 +930,7 @@ impl ParsedDeclaration { match longhands::${property.ident}::parse_declared(context, input) { Ok(value) => { - Ok(ParsedDeclaration::LonghandOrCustom( - PropertyDeclaration::${property.camel_case}(value) - )) + Ok(ParsedDeclaration::LonghandOrCustom(value)) }, Err(()) => Err(PropertyDeclarationParseError::InvalidValue), } @@ -958,14 +978,18 @@ pub enum PropertyDeclaration { % for property in data.longhands: /// ${property.name} % if property.boxed: - ${property.camel_case}(DeclaredValue>), + ${property.camel_case}(Box), % else: - ${property.camel_case}(DeclaredValue), + ${property.camel_case}(longhands::${property.ident}::SpecifiedValue), % endif % endfor + /// A css-wide keyword. + CSSWideKeyword(LonghandId, CSSWideKeyword), + /// An unparsed value that contains `var()` functions. + WithVariables(LonghandId, Arc), /// A custom property declaration, with the property name and the declared /// value. - Custom(::custom_properties::Name, DeclaredValue>), + Custom(::custom_properties::Name, DeclaredValueOwned>), } impl HasViewportPercentage for PropertyDeclaration { @@ -976,8 +1000,13 @@ impl HasViewportPercentage for PropertyDeclaration { val.has_viewport_percentage() }, % endfor + PropertyDeclaration::WithVariables(..) => { + panic!("DeclaredValue::has_viewport_percentage without \ + resolving variables!") + }, + PropertyDeclaration::CSSWideKeyword(..) => false, PropertyDeclaration::Custom(_, ref val) => { - val.has_viewport_percentage() + val.borrow().has_viewport_percentage() } } } @@ -1018,7 +1047,15 @@ impl ToCss for PropertyDeclaration { value.to_css(dest), % endif % endfor - PropertyDeclaration::Custom(_, ref value) => value.to_css(dest), + PropertyDeclaration::CSSWideKeyword(_, keyword) => keyword.to_css(dest), + PropertyDeclaration::WithVariables(_, ref with_variables) => { + // https://drafts.csswg.org/css-variables/#variables-in-shorthands + if with_variables.from_shorthand.is_none() { + dest.write_str(&*with_variables.css)? + } + Ok(()) + }, + PropertyDeclaration::Custom(_, ref value) => value.borrow().to_css(dest), % if any(property.derived_from for property in data.longhands): _ => Err(fmt::Error), % endif @@ -1062,6 +1099,8 @@ impl PropertyDeclaration { PropertyDeclarationId::Longhand(LonghandId::${property.camel_case}) } % endfor + PropertyDeclaration::CSSWideKeyword(id, _) => PropertyDeclarationId::Longhand(id), + PropertyDeclaration::WithVariables(id, _) => PropertyDeclarationId::Longhand(id), PropertyDeclaration::Custom(ref name, _) => { PropertyDeclarationId::Custom(name) } @@ -1070,35 +1109,22 @@ impl PropertyDeclaration { fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> { match *self { - % for property in data.longhands: - PropertyDeclaration::${property.camel_case}(ref value) => match *value { - DeclaredValue::WithVariables(ref with_variables) => { - if let Some(s) = with_variables.from_shorthand { - if s == shorthand { - Some(&*with_variables.css) - } else { None } - } else { None } - } - _ => None - }, - % endfor - PropertyDeclaration::Custom(..) => None, + PropertyDeclaration::WithVariables(_, ref with_variables) => { + if let Some(s) = with_variables.from_shorthand { + if s == shorthand { + Some(&*with_variables.css) + } else { None } + } else { None } + }, + _ => None, } } /// Returns a CSS-wide keyword if the declaration's value is one. pub fn get_css_wide_keyword(&self) -> Option { match *self { - % for property in data.longhands: - PropertyDeclaration::${property.camel_case}(ref value) => match *value { - DeclaredValue::CSSWideKeyword(keyword) => Some(keyword), - _ => None, - }, - % endfor - PropertyDeclaration::Custom(_, ref value) => match *value { - DeclaredValue::CSSWideKeyword(keyword) => Some(keyword), - _ => None, - } + PropertyDeclaration::CSSWideKeyword(_, keyword) => Some(keyword), + _ => None, } } @@ -1116,14 +1142,11 @@ impl PropertyDeclaration { /// the longhand declarations. pub fn may_serialize_as_part_of_shorthand(&self) -> bool { match *self { - % for property in data.longhands: - PropertyDeclaration::${property.camel_case}(ref value) => match *value { - DeclaredValue::Value(_) => true, - _ => false, - }, - % endfor + PropertyDeclaration::CSSWideKeyword(..) => false, + PropertyDeclaration::WithVariables(..) => false, PropertyDeclaration::Custom(..) => unreachable!("Serialize a custom property as part of shorthand?"), + _ => true, } } @@ -1135,12 +1158,9 @@ impl PropertyDeclaration { /// unsubstituted variables. pub fn value_is_unparsed(&self) -> bool { match *self { - % for property in data.longhands: - PropertyDeclaration::${property.camel_case}(ref value) => { - matches!(*value, DeclaredValue::WithVariables(_)) - }, - % endfor - PropertyDeclaration::Custom(..) => true + PropertyDeclaration::WithVariables(..) => true, + PropertyDeclaration::Custom(..) => true, + _ => false, } } @@ -1173,6 +1193,12 @@ impl PropertyDeclaration { % for property in data.longhands: PropertyDeclaration::${property.camel_case}(_) => ${property.ident.upper()}, % endfor + PropertyDeclaration::CSSWideKeyword(id, _) | + PropertyDeclaration::WithVariables(id, _) => match id { + % for property in data.longhands: + LonghandId::${property.camel_case} => ${property.ident.upper()}, + % endfor + }, PropertyDeclaration::Custom(_, _) => &[] } } @@ -1190,6 +1216,18 @@ impl PropertyDeclaration { % endif } % endfor + PropertyDeclaration::CSSWideKeyword(id, _) | + PropertyDeclaration::WithVariables(id, _) => match id { + % for property in data.longhands: + LonghandId::${property.camel_case} => { + % if property.animatable: + true + % else: + false + % endif + } + % endfor + }, PropertyDeclaration::Custom(..) => false, } } @@ -1877,7 +1915,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device, if let PropertyDeclaration::Custom(ref name, ref value) = *declaration { ::custom_properties::cascade( &mut custom_properties, &inherited_custom_properties, - &mut seen_custom, name, value) + &mut seen_custom, name, value.borrow()); } } @@ -1952,19 +1990,19 @@ pub fn apply_declarations<'a, F, I>(device: &Device, // // Unfortunately, it’s not easy to check that this // classification is correct. - let is_early_property = matches!(*declaration, - PropertyDeclaration::FontSize(_) | - PropertyDeclaration::FontFamily(_) | - PropertyDeclaration::Color(_) | - PropertyDeclaration::Position(_) | - PropertyDeclaration::Float(_) | - PropertyDeclaration::TextDecorationLine(_) | - PropertyDeclaration::WritingMode(_) | - PropertyDeclaration::Direction(_) + let is_early_property = matches!(longhand_id, + LonghandId::FontSize | + LonghandId::FontFamily | + LonghandId::Color | + LonghandId::Position | + LonghandId::Float | + LonghandId::TextDecorationLine | + LonghandId::WritingMode | + LonghandId::Direction % if product == 'gecko': - | PropertyDeclaration::TextOrientation(_) - | PropertyDeclaration::AnimationName(_) - | PropertyDeclaration::TransitionProperty(_) + | LonghandId::TextOrientation + | LonghandId::AnimationName + | LonghandId::TransitionProperty % endif ); if @@ -2395,7 +2433,7 @@ macro_rules! longhand_properties_idents { pub fn test_size_of_property_declaration() { use std::mem::size_of; - let old = 48; + let old = 40; let new = size_of::(); if new < old { panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \ diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 54b4e03d3a3..07be5c8fce3 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1008,7 +1008,7 @@ macro_rules! match_wrap_declared { ($longhand:ident, $($property:ident => $inner:expr,)*) => ( match $longhand { $( - LonghandId::$property => PropertyDeclaration::$property(DeclaredValue::Value($inner)), + LonghandId::$property => PropertyDeclaration::$property($inner), )* _ => { error!("stylo: Don't know how to handle presentation property {:?}", $longhand); @@ -1036,7 +1036,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(declarations: nsCSSPropertyID, value: *mut nsIAtom) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands::_x_lang::computed_value::T as Lang; let declarations = RwLock::::as_arc(&declarations); @@ -1053,7 +1053,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID, value: i32) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands; use style::values::specified::{BorderStyle, NoCalcLength}; @@ -1088,7 +1088,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations: pub extern "C" fn Servo_DeclarationBlock_SetIntValue(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID, value: i32) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands::_x_span::computed_value::T as Span; let declarations = RwLock::::as_arc(&declarations); @@ -1104,7 +1104,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID, value: f32) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing; use style::values::specified::BorderWidth; use style::values::specified::length::NoCalcLength; @@ -1143,7 +1143,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID, value: f32) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::values::specified::length::Percentage; let declarations = RwLock::::as_arc(&declarations); @@ -1165,7 +1165,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations: pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::values::specified::LengthOrPercentageOrAuto; let declarations = RwLock::::as_arc(&declarations); @@ -1187,7 +1187,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations: pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(declarations: RawServoDeclarationBlockBorrowed, property: nsCSSPropertyID) { - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::values::specified::{Color, CSSColor}; let declarations = RwLock::::as_arc(&declarations); @@ -1209,7 +1209,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetColorValue(declarations: property: nsCSSPropertyID, value: structs::nscolor) { use style::gecko::values::convert_nscolor_to_rgba; - use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; + use style::properties::{PropertyDeclaration, LonghandId}; use style::properties::longhands; use style::values::specified::{Color, CSSColor}; @@ -1234,7 +1234,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations: RawServoDeclarationBlockBorrowed, value: *const nsAString) { use cssparser::Parser; - use style::properties::{DeclaredValue, PropertyDeclaration}; + use style::properties::PropertyDeclaration; use style::properties::longhands::font_family::SpecifiedValue as FontFamily; let declarations = RwLock::::as_arc(&declarations); @@ -1242,7 +1242,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations: let mut parser = Parser::new(&string); if let Ok(family) = FontFamily::parse(&mut parser) { if parser.is_exhausted() { - let decl = PropertyDeclaration::FontFamily(DeclaredValue::Value(family)); + let decl = PropertyDeclaration::FontFamily(family); declarations.write().push(decl, Importance::Normal); } } @@ -1251,13 +1251,13 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations: #[no_mangle] pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations: RawServoDeclarationBlockBorrowed) { - use style::properties::{DeclaredValue, PropertyDeclaration}; + use style::properties::PropertyDeclaration; use style::properties::longhands::text_decoration_line; let declarations = RwLock::::as_arc(&declarations); let mut decoration = text_decoration_line::computed_value::none; decoration |= text_decoration_line::COLOR_OVERRIDE; - let decl = PropertyDeclaration::TextDecorationLine(DeclaredValue::Value(decoration)); + let decl = PropertyDeclaration::TextDecorationLine(decoration); declarations.write().push(decl, Importance::Normal); } diff --git a/tests/unit/style/keyframes.rs b/tests/unit/style/keyframes.rs index a1861754419..051ff9ca792 100644 --- a/tests/unit/style/keyframes.rs +++ b/tests/unit/style/keyframes.rs @@ -6,7 +6,7 @@ use parking_lot::RwLock; use std::sync::Arc; use style::keyframes::{Keyframe, KeyframesAnimation, KeyframePercentage, KeyframeSelector}; use style::keyframes::{KeyframesStep, KeyframesStepValue}; -use style::properties::{DeclaredValue, PropertyDeclaration, PropertyDeclarationBlock, Importance}; +use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, Importance}; use style::properties::animated_properties::TransitionProperty; use style::values::specified::{LengthOrPercentageOrAuto, NoCalcLength}; @@ -44,7 +44,7 @@ fn test_missing_property_in_initial_keyframe() { let declarations_on_initial_keyframe = Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( PropertyDeclaration::Width( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ))); @@ -53,12 +53,12 @@ fn test_missing_property_in_initial_keyframe() { let mut block = PropertyDeclarationBlock::new(); block.push( PropertyDeclaration::Width( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ); block.push( PropertyDeclaration::Height( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ); block @@ -102,12 +102,12 @@ fn test_missing_property_in_final_keyframe() { let mut block = PropertyDeclarationBlock::new(); block.push( PropertyDeclaration::Width( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ); block.push( PropertyDeclaration::Height( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ); block @@ -116,7 +116,7 @@ fn test_missing_property_in_final_keyframe() { let declarations_on_final_keyframe = Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( PropertyDeclaration::Height( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal, ))); @@ -158,12 +158,12 @@ fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() { let mut block = PropertyDeclarationBlock::new(); block.push( PropertyDeclaration::Width( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ); block.push( PropertyDeclaration::Height( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Normal ); block diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 26a8c9d0191..1eb5b75feb8 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -7,8 +7,7 @@ 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}; -use style::properties::{PropertyDeclarationBlock, Importance, PropertyId}; +use style::properties::{PropertyDeclaration, 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; @@ -34,27 +33,27 @@ fn property_declaration_block_should_serialize_correctly() { let declarations = vec![ (PropertyDeclaration::Width( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(70f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(70f32))), Importance::Normal), (PropertyDeclaration::MinHeight( - DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentage::Length(NoCalcLength::from_px(20f32))), Importance::Normal), (PropertyDeclaration::Height( - DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), + LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), Importance::Important), (PropertyDeclaration::Display( - DeclaredValue::Value(inline_block)), + inline_block), Importance::Normal), (PropertyDeclaration::OverflowX( - DeclaredValue::Value(OverflowXValue::auto)), + OverflowXValue::auto), Importance::Normal), (PropertyDeclaration::OverflowY( - DeclaredValue::Value(OverflowYContainer(OverflowXValue::auto))), + OverflowYContainer(OverflowXValue::auto)), Importance::Normal), ]; @@ -88,10 +87,10 @@ mod shorthand_serialization { fn equal_overflow_properties_should_serialize_to_single_value() { let mut properties = Vec::new(); - let overflow_x = DeclaredValue::Value(OverflowXValue::auto); + let overflow_x = OverflowXValue::auto; properties.push(PropertyDeclaration::OverflowX(overflow_x)); - let overflow_y = DeclaredValue::Value(OverflowYContainer(OverflowXValue::auto)); + let overflow_y = OverflowYContainer(OverflowXValue::auto); properties.push(PropertyDeclaration::OverflowY(overflow_y)); let serialization = shorthand_properties_to_string(properties); @@ -102,10 +101,10 @@ mod shorthand_serialization { fn different_overflow_properties_should_serialize_to_two_values() { let mut properties = Vec::new(); - let overflow_x = DeclaredValue::Value(OverflowXValue::scroll); + let overflow_x = OverflowXValue::scroll; properties.push(PropertyDeclaration::OverflowX(overflow_x)); - let overflow_y = DeclaredValue::Value(OverflowYContainer(OverflowXValue::auto)); + let overflow_y = OverflowYContainer(OverflowXValue::auto); properties.push(PropertyDeclaration::OverflowY(overflow_y)); let serialization = shorthand_properties_to_string(properties); @@ -122,12 +121,12 @@ mod shorthand_serialization { fn text_decoration_should_show_all_properties_when_set() { let mut properties = Vec::new(); - let line = DeclaredValue::Value(TextDecorationLine::OVERLINE); - let style = DeclaredValue::Value(TextDecorationStyle::dotted); - let color = DeclaredValue::Value(CSSColor { + let line = TextDecorationLine::OVERLINE; + let style = TextDecorationStyle::dotted; + let color = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(128, 0, 128, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::TextDecorationLine(line)); properties.push(PropertyDeclaration::TextDecorationStyle(style)); @@ -141,9 +140,9 @@ mod shorthand_serialization { fn text_decoration_should_not_serialize_initial_style_value() { let mut properties = Vec::new(); - let line = DeclaredValue::Value(TextDecorationLine::UNDERLINE); - let style = DeclaredValue::Value(TextDecorationStyle::solid); - let color = DeclaredValue::Value(CSSColor::currentcolor()); + let line = TextDecorationLine::UNDERLINE; + let style = TextDecorationStyle::solid; + let color = CSSColor::currentcolor(); properties.push(PropertyDeclaration::TextDecorationLine(line)); properties.push(PropertyDeclaration::TextDecorationStyle(style)); @@ -163,7 +162,7 @@ mod shorthand_serialization { fn all_equal_properties_should_serialize_to_one_value() { let mut properties = Vec::new(); - let px_70 = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(70f32))); + let px_70 = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(70f32)); properties.push(PropertyDeclaration::MarginTop(px_70.clone())); properties.push(PropertyDeclaration::MarginRight(px_70.clone())); properties.push(PropertyDeclaration::MarginBottom(px_70.clone())); @@ -177,8 +176,8 @@ mod shorthand_serialization { fn equal_vertical_and_equal_horizontal_properties_should_serialize_to_two_value() { let mut properties = Vec::new(); - let vertical_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32))); - let horizontal_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32))); + let vertical_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32)); + let horizontal_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32)); properties.push(PropertyDeclaration::MarginTop(vertical_px.clone())); properties.push(PropertyDeclaration::MarginRight(horizontal_px.clone())); @@ -193,9 +192,9 @@ mod shorthand_serialization { fn different_vertical_and_equal_horizontal_properties_should_serialize_to_three_values() { let mut properties = Vec::new(); - let top_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32))); - let bottom_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32))); - let horizontal_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32))); + let top_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32)); + let bottom_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32)); + let horizontal_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32)); properties.push(PropertyDeclaration::MarginTop(top_px)); properties.push(PropertyDeclaration::MarginRight(horizontal_px.clone())); @@ -210,10 +209,10 @@ mod shorthand_serialization { fn different_properties_should_serialize_to_four_values() { let mut properties = Vec::new(); - let top_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32))); - let right_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(12f32))); - let bottom_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32))); - let left_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(14f32))); + let top_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32)); + let right_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(12f32)); + let bottom_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32)); + let left_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(14f32)); properties.push(PropertyDeclaration::MarginTop(top_px)); properties.push(PropertyDeclaration::MarginRight(right_px)); @@ -228,25 +227,25 @@ mod shorthand_serialization { fn different_longhands_should_serialize_to_long_form() { let mut properties = Vec::new(); - let solid = DeclaredValue::Value(BorderStyle::solid); + let solid = BorderStyle::solid; properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(solid.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone())); properties.push(PropertyDeclaration::BorderLeftStyle(solid.clone())); - let px_30 = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(30f32))); - let px_10 = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(10f32))); + let px_30 = BorderWidth::from_length(Length::from_px(30f32)); + let px_10 = BorderWidth::from_length(Length::from_px(10f32)); properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderLeftWidth(px_10.clone())); - let blue = DeclaredValue::Value(CSSColor { + let blue = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::BorderTopColor(blue.clone())); properties.push(PropertyDeclaration::BorderRightColor(blue.clone())); @@ -262,24 +261,24 @@ mod shorthand_serialization { fn same_longhands_should_serialize_correctly() { let mut properties = Vec::new(); - let solid = DeclaredValue::Value(BorderStyle::solid); + let solid = BorderStyle::solid; properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(solid.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone())); properties.push(PropertyDeclaration::BorderLeftStyle(solid.clone())); - let px_30 = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(30f32))); + let px_30 = BorderWidth::from_length(Length::from_px(30f32)); properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderLeftWidth(px_30.clone())); - let blue = DeclaredValue::Value(CSSColor { + let blue = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::BorderTopColor(blue.clone())); properties.push(PropertyDeclaration::BorderRightColor(blue.clone())); @@ -294,8 +293,8 @@ mod shorthand_serialization { fn padding_should_serialize_correctly() { let mut properties = Vec::new(); - let px_10 = DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(10f32))); - let px_15 = DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(15f32))); + let px_10 = LengthOrPercentage::Length(NoCalcLength::from_px(10f32)); + let px_15 = LengthOrPercentage::Length(NoCalcLength::from_px(15f32)); properties.push(PropertyDeclaration::PaddingTop(px_10.clone())); properties.push(PropertyDeclaration::PaddingRight(px_15.clone())); properties.push(PropertyDeclaration::PaddingBottom(px_10)); @@ -309,11 +308,11 @@ mod shorthand_serialization { fn border_width_should_serialize_correctly() { let mut properties = Vec::new(); - let top_px = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(10f32))); - let bottom_px = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(10f32))); + let top_px = BorderWidth::from_length(Length::from_px(10f32)); + let bottom_px = BorderWidth::from_length(Length::from_px(10f32)); - let right_px = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(15f32))); - let left_px = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(15f32))); + let right_px = BorderWidth::from_length(Length::from_px(15f32)); + let left_px = BorderWidth::from_length(Length::from_px(15f32)); properties.push(PropertyDeclaration::BorderTopWidth(top_px)); properties.push(PropertyDeclaration::BorderRightWidth(right_px)); @@ -328,10 +327,10 @@ mod shorthand_serialization { fn border_width_with_keywords_should_serialize_correctly() { let mut properties = Vec::new(); - let top_px = DeclaredValue::Value(BorderWidth::Thin); - let right_px = DeclaredValue::Value(BorderWidth::Medium); - let bottom_px = DeclaredValue::Value(BorderWidth::Thick); - let left_px = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(15f32))); + let top_px = BorderWidth::Thin; + let right_px = BorderWidth::Medium; + let bottom_px = BorderWidth::Thick; + let left_px = BorderWidth::from_length(Length::from_px(15f32)); properties.push(PropertyDeclaration::BorderTopWidth(top_px)); properties.push(PropertyDeclaration::BorderRightWidth(right_px)); @@ -346,15 +345,15 @@ mod shorthand_serialization { fn border_color_should_serialize_correctly() { let mut properties = Vec::new(); - let red = DeclaredValue::Value(CSSColor { + let red = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), authored: None - }); + }; - let blue = DeclaredValue::Value(CSSColor { + let blue = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::BorderTopColor(blue.clone())); properties.push(PropertyDeclaration::BorderRightColor(red.clone())); @@ -371,8 +370,8 @@ mod shorthand_serialization { fn border_style_should_serialize_correctly() { let mut properties = Vec::new(); - let solid = DeclaredValue::Value(BorderStyle::solid); - let dotted = DeclaredValue::Value(BorderStyle::dotted); + let solid = BorderStyle::solid; + let dotted = BorderStyle::dotted; properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(dotted.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(solid)); @@ -394,12 +393,12 @@ mod shorthand_serialization { fn directional_border_should_show_all_properties_when_values_are_set() { let mut properties = Vec::new(); - let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); - let style = DeclaredValue::Value(BorderStyle::solid); - let color = DeclaredValue::Value(CSSColor { + let width = BorderWidth::from_length(Length::from_px(4f32)); + let style = BorderStyle::solid; + let color = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopStyle(style)); @@ -409,12 +408,10 @@ mod shorthand_serialization { assert_eq!(serialization, "border-top: 4px solid rgb(255, 0, 0);"); } - fn get_border_property_values() -> (DeclaredValue, - DeclaredValue, - DeclaredValue) { - (DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))), - DeclaredValue::Value(BorderStyle::solid), - DeclaredValue::Value(CSSColor::currentcolor())) + fn get_border_property_values() -> (BorderWidth, BorderStyle, CSSColor) { + (BorderWidth::from_length(Length::from_px(4f32)), + BorderStyle::solid, + CSSColor::currentcolor()) } #[test] @@ -501,10 +498,10 @@ mod shorthand_serialization { fn list_style_should_show_all_properties_when_values_are_set() { let mut properties = Vec::new(); - let position = DeclaredValue::Value(ListStylePosition::inside); - let image = DeclaredValue::Value(Either::First( - SpecifiedUrl::new_for_testing("http://servo/test.png"))); - let style_type = DeclaredValue::Value(ListStyleType::disc); + let position = ListStylePosition::inside; + let image = Either::First( + SpecifiedUrl::new_for_testing("http://servo/test.png")); + let style_type = ListStyleType::disc; properties.push(PropertyDeclaration::ListStylePosition(position)); properties.push(PropertyDeclaration::ListStyleImage(image)); @@ -524,12 +521,12 @@ mod shorthand_serialization { fn outline_should_show_all_properties_when_set() { let mut properties = Vec::new(); - let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32))); - let style = DeclaredValue::Value(Either::Second(BorderStyle::solid)); - let color = DeclaredValue::Value(CSSColor { + let width = WidthContainer(Length::from_px(4f32)); + let style = Either::Second(BorderStyle::solid); + let color = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::OutlineWidth(width)); properties.push(PropertyDeclaration::OutlineStyle(style)); @@ -543,12 +540,12 @@ mod shorthand_serialization { fn outline_should_serialize_correctly_when_style_is_auto() { let mut properties = Vec::new(); - let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32))); - let style = DeclaredValue::Value(Either::First(Auto)); - let color = DeclaredValue::Value(CSSColor { + let width = WidthContainer(Length::from_px(4f32)); + let style = Either::First(Auto); + let color = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), authored: None - }); + }; properties.push(PropertyDeclaration::OutlineWidth(width)); properties.push(PropertyDeclaration::OutlineStyle(style)); properties.push(PropertyDeclaration::OutlineColor(color)); @@ -565,8 +562,8 @@ mod shorthand_serialization { let mut properties = Vec::new(); - let width = DeclaredValue::Value(Either::Second(Auto)); - let count = DeclaredValue::Value(ColumnCount::Auto); + let width = Either::Second(Auto); + let count = ColumnCount::Auto; properties.push(PropertyDeclaration::ColumnWidth(width)); properties.push(PropertyDeclaration::ColumnCount(count)); @@ -582,11 +579,10 @@ mod shorthand_serialization { let mut properties = Vec::new(); - let grow = DeclaredValue::Value(NumberContainer(2f32)); - let shrink = DeclaredValue::Value(NumberContainer(3f32)); - let basis = DeclaredValue::Value( - LengthOrPercentageOrAutoOrContent::Percentage(PercentageContainer(0.5f32)) - ); + let grow = NumberContainer(2f32); + let shrink = NumberContainer(3f32); + let basis = + LengthOrPercentageOrAutoOrContent::Percentage(PercentageContainer(0.5f32)); properties.push(PropertyDeclaration::FlexGrow(grow)); properties.push(PropertyDeclaration::FlexShrink(shrink)); @@ -603,8 +599,8 @@ mod shorthand_serialization { let mut properties = Vec::new(); - let direction = DeclaredValue::Value(FlexDirection::row); - let wrap = DeclaredValue::Value(FlexWrap::wrap); + let direction = FlexDirection::row; + let wrap = FlexWrap::wrap; properties.push(PropertyDeclaration::FlexDirection(direction)); properties.push(PropertyDeclaration::FlexWrap(wrap)); @@ -774,23 +770,23 @@ mod shorthand_serialization { macro_rules! single_vec_value_typedef { ($name:ident, $path:expr) => { - DeclaredValue::Value($name::SpecifiedValue( + $name::SpecifiedValue( vec![$path] - )) + ) }; } macro_rules! single_vec_keyword_value { ($name:ident, $kw:ident) => { - DeclaredValue::Value($name::SpecifiedValue( + $name::SpecifiedValue( vec![$name::single_value::SpecifiedValue::$kw] - )) + ) }; } macro_rules! single_vec_variant_value { ($name:ident, $variant:expr) => { - DeclaredValue::Value($name::SpecifiedValue( + $name::SpecifiedValue( vec![$variant] - )) + ) }; } @@ -913,9 +909,9 @@ mod shorthand_serialization { #[test] fn should_serialize_to_empty_string_if_sub_types_not_equal() { let declarations = vec![ - (PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)), + (PropertyDeclaration::ScrollSnapTypeX(ScrollSnapTypeXValue::mandatory), Importance::Normal), - (PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::none)), + (PropertyDeclaration::ScrollSnapTypeY(ScrollSnapTypeXValue::none), Importance::Normal) ]; @@ -933,9 +929,9 @@ mod shorthand_serialization { #[test] fn should_serialize_to_single_value_if_sub_types_are_equal() { let declarations = vec![ - (PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)), + (PropertyDeclaration::ScrollSnapTypeX(ScrollSnapTypeXValue::mandatory), Importance::Normal), - (PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)), + (PropertyDeclaration::ScrollSnapTypeY(ScrollSnapTypeXValue::mandatory), Importance::Normal) ]; diff --git a/tests/unit/style/properties/viewport.rs b/tests/unit/style/properties/viewport.rs index 7e036a6e95d..b217a413665 100644 --- a/tests/unit/style/properties/viewport.rs +++ b/tests/unit/style/properties/viewport.rs @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use app_units::Au; -use style::properties::{DeclaredValue, PropertyDeclaration}; +use style::properties::PropertyDeclaration; use style::properties::longhands::border_top_width; use style::values::HasViewportPercentage; use style::values::specified::{Length, NoCalcLength, ViewportPercentageLength}; @@ -12,16 +12,16 @@ use style::values::specified::{Length, NoCalcLength, ViewportPercentageLength}; fn has_viewport_percentage_for_specified_value() { //TODO: test all specified value with a HasViewportPercentage impl let pvw = PropertyDeclaration::BorderTopWidth( - DeclaredValue::Value(border_top_width::SpecifiedValue::from_length( + border_top_width::SpecifiedValue::from_length( Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.))) - )) + ) ); assert!(pvw.has_viewport_percentage()); let pabs = PropertyDeclaration::BorderTopWidth( - DeclaredValue::Value(border_top_width::SpecifiedValue::from_length( + border_top_width::SpecifiedValue::from_length( Length::NoCalc(NoCalcLength::Absolute(Au(100))) - )) + ) ); assert!(!pabs.has_viewport_percentage()); } diff --git a/tests/unit/style/rule_tree/bench.rs b/tests/unit/style/rule_tree/bench.rs index bec7018215f..37bef590a64 100644 --- a/tests/unit/style/rule_tree/bench.rs +++ b/tests/unit/style/rule_tree/bench.rs @@ -10,7 +10,7 @@ use std::sync::Arc; use style::error_reporting::ParseErrorReporter; use style::media_queries::MediaList; use style::parser::ParserContextExtraData; -use style::properties::{longhands, DeclaredValue, Importance, PropertyDeclaration, PropertyDeclarationBlock}; +use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock}; use style::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource}; use style::stylesheets::{Origin, Stylesheet, CssRule}; use test::{self, Bencher}; @@ -65,8 +65,8 @@ fn test_insertion(rule_tree: &RuleTree, rules: Vec<(StyleSource, CascadeLevel)>) fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)]) -> StrongRuleNode { let mut rules = rules.to_vec(); rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( - PropertyDeclaration::Display(DeclaredValue::Value( - longhands::display::SpecifiedValue::block)), + PropertyDeclaration::Display( + longhands::display::SpecifiedValue::block), Importance::Normal )))), CascadeLevel::UserNormal)); test_insertion(rule_tree, rules) diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index 892bcb53980..a1d649c099c 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -17,8 +17,8 @@ use style::error_reporting::ParseErrorReporter; use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage}; use style::parser::ParserContextExtraData; use style::properties::Importance; -use style::properties::{CSSWideKeyword, PropertyDeclaration, PropertyDeclarationBlock}; -use style::properties::{DeclaredValue, longhands}; +use style::properties::{CSSWideKeyword, DeclaredValueOwned, PropertyDeclaration, PropertyDeclarationBlock}; +use style::properties::longhands; use style::properties::longhands::animation_play_state; use style::stylesheets::{Origin, Namespaces}; use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule}; @@ -108,11 +108,10 @@ fn test_parse_stylesheet() { }, ]), block: Arc::new(RwLock::new(block_from(vec![ - (PropertyDeclaration::Display(DeclaredValue::Value( - longhands::display::SpecifiedValue::none)), + (PropertyDeclaration::Display(longhands::display::SpecifiedValue::none), Importance::Important), (PropertyDeclaration::Custom(Atom::from("a"), - DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)), + DeclaredValueOwned::CSSWideKeyword(CSSWideKeyword::Inherit)), Importance::Important), ]))), }))), @@ -154,8 +153,7 @@ fn test_parse_stylesheet() { }, ]), block: Arc::new(RwLock::new(block_from(vec![ - (PropertyDeclaration::Display(DeclaredValue::Value( - longhands::display::SpecifiedValue::block)), + (PropertyDeclaration::Display(longhands::display::SpecifiedValue::block), Importance::Normal), ]))), }))), @@ -186,52 +184,52 @@ fn test_parse_stylesheet() { }, ]), block: Arc::new(RwLock::new(block_from(vec![ - (PropertyDeclaration::BackgroundColor(DeclaredValue::Value( + (PropertyDeclaration::BackgroundColor( longhands::background_color::SpecifiedValue { authored: Some("blue".to_owned().into_boxed_str()), parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)), } - )), + ), Importance::Normal), - (PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value( + (PropertyDeclaration::BackgroundPositionX( longhands::background_position_x::SpecifiedValue( vec![longhands::background_position_x::single_value - ::get_initial_position_value()]))), + ::get_initial_position_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value( + (PropertyDeclaration::BackgroundPositionY( longhands::background_position_y::SpecifiedValue( vec![longhands::background_position_y::single_value - ::get_initial_position_value()]))), + ::get_initial_position_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value( + (PropertyDeclaration::BackgroundRepeat( longhands::background_repeat::SpecifiedValue( vec![longhands::background_repeat::single_value - ::get_initial_specified_value()]))), + ::get_initial_specified_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundAttachment(DeclaredValue::Value( + (PropertyDeclaration::BackgroundAttachment( longhands::background_attachment::SpecifiedValue( vec![longhands::background_attachment::single_value - ::get_initial_specified_value()]))), + ::get_initial_specified_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundImage(DeclaredValue::Value( + (PropertyDeclaration::BackgroundImage( longhands::background_image::SpecifiedValue( vec![longhands::background_image::single_value - ::get_initial_specified_value()]))), + ::get_initial_specified_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundSize(DeclaredValue::Value( + (PropertyDeclaration::BackgroundSize( longhands::background_size::SpecifiedValue( vec![longhands::background_size::single_value - ::get_initial_specified_value()]))), + ::get_initial_specified_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundOrigin(DeclaredValue::Value( + (PropertyDeclaration::BackgroundOrigin( longhands::background_origin::SpecifiedValue( vec![longhands::background_origin::single_value - ::get_initial_specified_value()]))), + ::get_initial_specified_value()])), Importance::Normal), - (PropertyDeclaration::BackgroundClip(DeclaredValue::Value( + (PropertyDeclaration::BackgroundClip( longhands::background_clip::SpecifiedValue( vec![longhands::background_clip::single_value - ::get_initial_specified_value()]))), + ::get_initial_specified_value()])), Importance::Normal), ]))), }))), @@ -242,8 +240,8 @@ fn test_parse_stylesheet() { selector: KeyframeSelector::new_for_unit_testing( vec![KeyframePercentage::new(0.)]), block: Arc::new(RwLock::new(block_from(vec![ - (PropertyDeclaration::Width(DeclaredValue::Value( - LengthOrPercentageOrAuto::Percentage(Percentage(0.)))), + (PropertyDeclaration::Width( + LengthOrPercentageOrAuto::Percentage(Percentage(0.))), Importance::Normal), ]))) })), @@ -251,12 +249,12 @@ fn test_parse_stylesheet() { selector: KeyframeSelector::new_for_unit_testing( vec![KeyframePercentage::new(1.)]), block: Arc::new(RwLock::new(block_from(vec![ - (PropertyDeclaration::Width(DeclaredValue::Value( - LengthOrPercentageOrAuto::Percentage(Percentage(1.)))), + (PropertyDeclaration::Width( + LengthOrPercentageOrAuto::Percentage(Percentage(1.))), Importance::Normal), - (PropertyDeclaration::AnimationPlayState(DeclaredValue::Value( + (PropertyDeclaration::AnimationPlayState( animation_play_state::SpecifiedValue( - vec![animation_play_state::SingleSpecifiedValue::running]))), + vec![animation_play_state::SingleSpecifiedValue::running])), Importance::Normal), ]))), })), diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs index 46fb3eef164..ab04f2e5dd5 100644 --- a/tests/unit/style/stylist.rs +++ b/tests/unit/style/stylist.rs @@ -7,7 +7,7 @@ use parking_lot::RwLock; use selectors::parser::LocalName as LocalNameSelector; use servo_atoms::Atom; use std::sync::Arc; -use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, DeclaredValue}; +use style::properties::{PropertyDeclarationBlock, PropertyDeclaration}; use style::properties::{longhands, Importance}; use style::rule_tree::CascadeLevel; use style::selector_parser::SelectorParser; @@ -24,8 +24,8 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec> { let rule = Arc::new(RwLock::new(StyleRule { selectors: selectors, block: Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( - PropertyDeclaration::Display(DeclaredValue::Value( - longhands::display::SpecifiedValue::block)), + PropertyDeclaration::Display( + longhands::display::SpecifiedValue::block), Importance::Normal ))), }));