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
This commit is contained in:
Bobby Holley 2017-03-15 11:59:53 -07:00
parent e34aac03ff
commit 8cf331a498
14 changed files with 378 additions and 333 deletions

View file

@ -103,8 +103,7 @@ use style::context::{QuirksMode, ReflowGoal};
use style::element_state::*; use style::element_state::*;
use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes}; use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
use style::parser::ParserContextExtraData; use style::parser::ParserContextExtraData;
use style::properties::{DeclaredValue, Importance}; use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute};
use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x}; use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x};
use style::restyle_hints::RESTYLE_SELF; use style::restyle_hints::RESTYLE_SELF;
use style::rule_tree::CascadeLevel; use style::rule_tree::CascadeLevel;
@ -409,8 +408,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(color) = bgcolor { if let Some(color) = bgcolor {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BackgroundColor(DeclaredValue::Value( PropertyDeclaration::BackgroundColor(
CSSColor { parsed: Color::RGBA(color), authored: None })))); CSSColor { parsed: Color::RGBA(color), authored: None })));
} }
let background = if let Some(this) = self.downcast::<HTMLBodyElement>() { let background = if let Some(this) = self.downcast::<HTMLBodyElement>() {
@ -421,12 +420,12 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(url) = background { if let Some(url) = background {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BackgroundImage(DeclaredValue::Value( PropertyDeclaration::BackgroundImage(
background_image::SpecifiedValue(vec![ background_image::SpecifiedValue(vec![
background_image::single_value::SpecifiedValue(Some( background_image::single_value::SpecifiedValue(Some(
specified::Image::for_cascade(url.into(), specified::url::UrlExtraData { }) specified::Image::for_cascade(url.into(), specified::url::UrlExtraData { })
)) ))
]))))); ]))));
} }
let color = if let Some(this) = self.downcast::<HTMLFontElement>() { let color = if let Some(this) = self.downcast::<HTMLFontElement>() {
@ -443,12 +442,12 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(color) = color { if let Some(color) = color {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Color(DeclaredValue::Value( PropertyDeclaration::Color(
longhands::color::SpecifiedValue(CSSColor { longhands::color::SpecifiedValue(CSSColor {
parsed: Color::RGBA(color), parsed: Color::RGBA(color),
authored: None, authored: None,
}) })
)) )
)); ));
} }
@ -461,19 +460,16 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(font_family) = font_family { if let Some(font_family) = font_family {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::FontFamily( PropertyDeclaration::FontFamily(
DeclaredValue::Value(
font_family::computed_value::T(vec![ font_family::computed_value::T(vec![
font_family::computed_value::FontFamily::from_atom( font_family::computed_value::FontFamily::from_atom(
font_family)]))))); font_family)]))));
} }
let font_size = self.downcast::<HTMLFontElement>().and_then(|this| this.get_size()); let font_size = self.downcast::<HTMLFontElement>().and_then(|this| this.get_size());
if let Some(font_size) = font_size { if let Some(font_size) = font_size {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::FontSize( PropertyDeclaration::FontSize(font_size::SpecifiedValue(font_size.into()))))
DeclaredValue::Value(
font_size::SpecifiedValue(font_size.into())))))
} }
let cellspacing = if let Some(this) = self.downcast::<HTMLTableElement>() { let cellspacing = if let Some(this) = self.downcast::<HTMLTableElement>() {
@ -485,11 +481,11 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(cellspacing) = cellspacing { if let Some(cellspacing) = cellspacing {
let width_value = specified::Length::from_px(cellspacing as f32); let width_value = specified::Length::from_px(cellspacing as f32);
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderSpacing(DeclaredValue::Value( PropertyDeclaration::BorderSpacing(
Box::new(border_spacing::SpecifiedValue { Box::new(border_spacing::SpecifiedValue {
horizontal: width_value.clone(), horizontal: width_value.clone(),
vertical: width_value, vertical: width_value,
}))))); }))));
} }
@ -518,8 +514,8 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(size) = size { if let Some(size) = size {
let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size)); let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(size));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value( PropertyDeclaration::Width(
specified::LengthOrPercentageOrAuto::Length(value))))); specified::LengthOrPercentageOrAuto::Length(value))));
} }
let width = if let Some(this) = self.downcast::<HTMLIFrameElement>() { let width = if let Some(this) = self.downcast::<HTMLIFrameElement>() {
@ -543,13 +539,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
let width_value = let width_value =
specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); PropertyDeclaration::Width(width_value)));
} }
LengthOrPercentageOrAuto::Length(length) => { LengthOrPercentageOrAuto::Length(length) => {
let width_value = specified::LengthOrPercentageOrAuto::Length( let width_value = specified::LengthOrPercentageOrAuto::Length(
specified::NoCalcLength::Absolute(length)); specified::NoCalcLength::Absolute(length));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value(width_value)))); PropertyDeclaration::Width(width_value)));
} }
} }
@ -568,13 +564,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
let height_value = let height_value =
specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage)); specified::LengthOrPercentageOrAuto::Percentage(specified::Percentage(percentage));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); PropertyDeclaration::Height(height_value)));
} }
LengthOrPercentageOrAuto::Length(length) => { LengthOrPercentageOrAuto::Length(length) => {
let height_value = specified::LengthOrPercentageOrAuto::Length( let height_value = specified::LengthOrPercentageOrAuto::Length(
specified::NoCalcLength::Absolute(length)); specified::NoCalcLength::Absolute(length));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Height(DeclaredValue::Value(height_value)))); PropertyDeclaration::Height(height_value)));
} }
} }
@ -596,8 +592,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// https://html.spec.whatwg.org/multipage/#textarea-effective-width // https://html.spec.whatwg.org/multipage/#textarea-effective-width
let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols)); let value = specified::NoCalcLength::ServoCharacterWidth(specified::CharacterWidth(cols));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(DeclaredValue::Value( PropertyDeclaration::Width(specified::LengthOrPercentageOrAuto::Length(value))));
specified::LengthOrPercentageOrAuto::Length(value)))));
} }
let rows = if let Some(this) = self.downcast::<HTMLTextAreaElement>() { let rows = if let Some(this) = self.downcast::<HTMLTextAreaElement>() {
@ -615,8 +610,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
// https://html.spec.whatwg.org/multipage/#textarea-effective-height // https://html.spec.whatwg.org/multipage/#textarea-effective-height
let value = specified::NoCalcLength::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat)); let value = specified::NoCalcLength::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Height(DeclaredValue::Value( PropertyDeclaration::Height(specified::LengthOrPercentageOrAuto::Length(value))));
specified::LengthOrPercentageOrAuto::Length(value)))));
} }
@ -629,13 +623,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(border) = border { if let Some(border) = border {
let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32)); let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(width_value.clone())))); PropertyDeclaration::BorderTopWidth(width_value.clone())));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(width_value.clone())))); PropertyDeclaration::BorderLeftWidth(width_value.clone())));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(width_value.clone())))); PropertyDeclaration::BorderBottomWidth(width_value.clone())));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(width_value)))); PropertyDeclaration::BorderRightWidth(width_value)));
} }
} }

View file

@ -329,7 +329,7 @@ pub fn cascade<'a>(custom_properties: &mut Option<HashMap<&'a Name, BorrowedSpec
inherited: &'a Option<Arc<HashMap<Name, ComputedValue>>>, inherited: &'a Option<Arc<HashMap<Name, ComputedValue>>>,
seen: &mut HashSet<&'a Name>, seen: &mut HashSet<&'a Name>,
name: &'a Name, name: &'a Name,
specified_value: &'a DeclaredValue<Box<SpecifiedValue>>) { specified_value: DeclaredValue<'a, Box<SpecifiedValue>>) {
let was_already_present = !seen.insert(name); let was_already_present = !seen.insert(name);
if was_already_present { if was_already_present {
return; return;
@ -352,7 +352,7 @@ pub fn cascade<'a>(custom_properties: &mut Option<HashMap<&'a Name, BorrowedSpec
custom_properties.as_mut().unwrap() custom_properties.as_mut().unwrap()
} }
}; };
match *specified_value { match specified_value {
DeclaredValue::Value(ref specified_value) => { DeclaredValue::Value(ref specified_value) => {
map.insert(name, BorrowedSpecifiedValue { map.insert(name, BorrowedSpecifiedValue {
css: &specified_value.css, css: &specified_value.css,

View file

@ -11,7 +11,7 @@ use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule};
use parking_lot::RwLock; use parking_lot::RwLock;
use parser::{ParserContext, ParserContextExtraData, log_css_error}; use parser::{ParserContext, ParserContextExtraData, log_css_error};
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId}; use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
use properties::{PropertyDeclarationId, LonghandId, DeclaredValue, ParsedDeclaration}; use properties::{PropertyDeclarationId, LonghandId, ParsedDeclaration};
use properties::LonghandIdSet; use properties::LonghandIdSet;
use properties::animated_properties::TransitionProperty; use properties::animated_properties::TransitionProperty;
use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction;
@ -210,14 +210,11 @@ impl KeyframesStep {
guard.get(PropertyDeclarationId::Longhand(LonghandId::AnimationTimingFunction)).unwrap(); guard.get(PropertyDeclarationId::Longhand(LonghandId::AnimationTimingFunction)).unwrap();
match *declaration { match *declaration {
PropertyDeclaration::AnimationTimingFunction(ref value) => { PropertyDeclaration::AnimationTimingFunction(ref value) => {
match *value {
DeclaredValue::Value(ref value) => {
// Use the first value. // Use the first value.
Some(value.0[0]) Some(value.0[0])
}, },
_ => None, PropertyDeclaration::CSSWideKeyword(..) => None,
} PropertyDeclaration::WithVariables(..) => None,
},
_ => panic!(), _ => panic!(),
} }
}, },

View file

@ -53,7 +53,7 @@ use gecko::values::GeckoStyleCoordConvertible;
use gecko::values::round_border_to_device_pixels; use gecko::values::round_border_to_device_pixels;
use logical_geometry::WritingMode; use logical_geometry::WritingMode;
use properties::longhands; use properties::longhands;
use properties::{DeclaredValue, Importance, LonghandId}; use properties::{Importance, LonghandId};
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId}; use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
use std::mem::{forget, transmute, zeroed}; use std::mem::{forget, transmute, zeroed};
@ -169,7 +169,7 @@ impl ComputedValues {
% if prop.animatable: % if prop.animatable:
PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => { PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => {
PropertyDeclarationBlock::with_one( PropertyDeclarationBlock::with_one(
PropertyDeclaration::${prop.camel_case}(DeclaredValue::Value( PropertyDeclaration::${prop.camel_case}(
% if prop.boxed: % if prop.boxed:
Box::new( Box::new(
% endif % endif
@ -178,7 +178,7 @@ impl ComputedValues {
% if prop.boxed: % if prop.boxed:
) )
% endif % endif
)), ),
Importance::Normal Importance::Normal
) )
}, },

View file

@ -70,7 +70,7 @@
pub mod single_value { pub mod single_value {
use cssparser::Parser; use cssparser::Parser;
use parser::{Parse, ParserContext, ParserContextExtraData}; use parser::{Parse, ParserContext, ParserContextExtraData};
use properties::{DeclaredValue, ShorthandId}; use properties::ShorthandId;
use values::computed::{Context, ToComputedValue}; use values::computed::{Context, ToComputedValue};
use values::{computed, specified}; use values::{computed, specified};
use values::{Auto, Either, None_, Normal}; use values::{Auto, Either, None_, Normal};
@ -210,13 +210,13 @@
% if not property.derived_from: % if not property.derived_from:
use cssparser::Parser; use cssparser::Parser;
use parser::{Parse, ParserContext, ParserContextExtraData}; use parser::{Parse, ParserContext, ParserContextExtraData};
use properties::{DeclaredValue, UnparsedValue, ShorthandId}; use properties::{UnparsedValue, ShorthandId};
% endif % endif
use values::{Auto, Either, None_, Normal}; use values::{Auto, Either, None_, Normal};
use cascade_info::CascadeInfo; use cascade_info::CascadeInfo;
use error_reporting::ParseErrorReporter; use error_reporting::ParseErrorReporter;
use properties::longhands; use properties::longhands;
use properties::LonghandIdSet; use properties::{DeclaredValue, LonghandId, LonghandIdSet};
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
use properties::style_structs; use properties::style_structs;
use std::boxed::Box as StdBox; use std::boxed::Box as StdBox;
@ -235,9 +235,17 @@
cascade_info: &mut Option<<&mut CascadeInfo>, cascade_info: &mut Option<<&mut CascadeInfo>,
error_reporter: &ParseErrorReporter) { error_reporter: &ParseErrorReporter) {
let declared_value = match *declaration { let declared_value = match *declaration {
PropertyDeclaration::${property.camel_case}(ref declared_value) => { PropertyDeclaration::${property.camel_case}(ref value) => {
declared_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"), _ => panic!("entered the wrong cascade_property() implementation"),
}; };
@ -245,7 +253,7 @@
{ {
let custom_props = context.style().custom_properties(); let custom_props = context.style().custom_properties();
::properties::substitute_variables_${property.ident}( ::properties::substitute_variables_${property.ident}(
declared_value, &custom_props, &declared_value, &custom_props,
|value| { |value| {
if let Some(ref mut cascade_info) = *cascade_info { if let Some(ref mut cascade_info) = *cascade_info {
cascade_info.on_cascade_property(&declaration, cascade_info.on_cascade_property(&declaration,
@ -312,21 +320,17 @@
% if not property.derived_from: % if not property.derived_from:
pub fn parse_specified(context: &ParserContext, input: &mut Parser) pub fn parse_specified(context: &ParserContext, input: &mut Parser)
% if property.boxed: % if property.boxed:
-> Result<DeclaredValue<Box<SpecifiedValue>>, ()> { -> Result<Box<SpecifiedValue>, ()> {
parse(context, input).map(|result| DeclaredValue::Value(Box::new(result))) parse(context, input).map(|result| Box::new(result))
% else: % else:
-> Result<DeclaredValue<SpecifiedValue>, ()> { -> Result<SpecifiedValue, ()> {
parse(context, input).map(DeclaredValue::Value) parse(context, input)
% endif % endif
} }
pub fn parse_declared(context: &ParserContext, input: &mut Parser) pub fn parse_declared(context: &ParserContext, input: &mut Parser)
% if property.boxed: -> Result<PropertyDeclaration, ()> {
-> Result<DeclaredValue<Box<SpecifiedValue>>, ()> {
% else:
-> Result<DeclaredValue<SpecifiedValue>, ()> {
% endif
match input.try(|i| CSSWideKeyword::parse(context, i)) { 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(()) => { Err(()) => {
input.look_for_var_functions(); input.look_for_var_functions();
let start = input.position(); let start = input.position();
@ -339,14 +343,15 @@
input.reset(start); input.reset(start);
let (first_token_type, css) = try!( let (first_token_type, css) = try!(
::custom_properties::parse_non_custom_with_var(input)); ::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(), css: css.into_owned(),
first_token_type: first_token_type, first_token_type: first_token_type,
base_url: context.base_url.clone(), base_url: context.base_url.clone(),
from_shorthand: None, from_shorthand: None,
}))) })))
} }
specified specified.map(|s| PropertyDeclaration::${property.camel_case}(s))
} }
} }
} }
@ -483,7 +488,7 @@
#[allow(unused_imports)] #[allow(unused_imports)]
use cssparser::Parser; use cssparser::Parser;
use parser::ParserContext; use parser::ParserContext;
use properties::{DeclaredValue, PropertyDeclaration, ParsedDeclaration}; use properties::{PropertyDeclaration, ParsedDeclaration};
use properties::{ShorthandId, UnparsedValue, longhands}; use properties::{ShorthandId, UnparsedValue, longhands};
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
@ -519,7 +524,7 @@
for longhand in iter { for longhand in iter {
match *longhand { match *longhand {
% for sub_property in shorthand.sub_properties: % 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) ${sub_property.ident} = Some(value)
}, },
% endfor % endfor

View file

@ -8,7 +8,7 @@ use app_units::Au;
use cssparser::{Color as CSSParserColor, Parser, RGBA}; use cssparser::{Color as CSSParserColor, Parser, RGBA};
use euclid::{Point2D, Size2D}; use euclid::{Point2D, Size2D};
#[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID; #[cfg(feature = "gecko")] use gecko_bindings::structs::nsCSSPropertyID;
use properties::{CSSWideKeyword, DeclaredValue, PropertyDeclaration}; use properties::{CSSWideKeyword, PropertyDeclaration};
use properties::longhands; use properties::longhands;
use properties::longhands::background_size::computed_value::T as BackgroundSize; use properties::longhands::background_size::computed_value::T as BackgroundSize;
use properties::longhands::font_weight::computed_value::T as FontWeight; use properties::longhands::font_weight::computed_value::T as FontWeight;
@ -278,17 +278,16 @@ impl AnimationValue {
/// "Uncompute" this animation value in order to be used inside the CSS /// "Uncompute" this animation value in order to be used inside the CSS
/// cascade. /// cascade.
pub fn uncompute(&self) -> PropertyDeclaration { pub fn uncompute(&self) -> PropertyDeclaration {
use properties::{longhands, DeclaredValue}; use properties::longhands;
match *self { match *self {
% for prop in data.longhands: % for prop in data.longhands:
% if prop.animatable: % if prop.animatable:
AnimationValue::${prop.camel_case}(ref from) => { AnimationValue::${prop.camel_case}(ref from) => {
PropertyDeclaration::${prop.camel_case}( PropertyDeclaration::${prop.camel_case}(
DeclaredValue::Value(
% if prop.boxed: % if prop.boxed:
Box::new(longhands::${prop.ident}::SpecifiedValue::from_computed_value(from)))) Box::new(longhands::${prop.ident}::SpecifiedValue::from_computed_value(from)))
% else: % else:
longhands::${prop.ident}::SpecifiedValue::from_computed_value(from))) longhands::${prop.ident}::SpecifiedValue::from_computed_value(from))
% endif % endif
} }
% endif % endif
@ -298,15 +297,23 @@ impl AnimationValue {
/// Construct an AnimationValue from a property declaration /// Construct an AnimationValue from a property declaration
pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option<Self> { pub fn from_declaration(decl: &PropertyDeclaration, context: &Context, initial: &ComputedValues) -> Option<Self> {
use properties::LonghandId;
match *decl { match *decl {
% for prop in data.longhands: % for prop in data.longhands:
% if prop.animatable: % if prop.animatable:
PropertyDeclaration::${prop.camel_case}(ref val) => { PropertyDeclaration::${prop.camel_case}(ref val) => {
let computed = match *val { Some(AnimationValue::${prop.camel_case}(val.to_computed_value(context)))
// https://bugzilla.mozilla.org/show_bug.cgi?id=1326131 },
DeclaredValue::WithVariables(_) => unimplemented!(), % endif
DeclaredValue::Value(ref val) => val.to_computed_value(context), % endfor
DeclaredValue::CSSWideKeyword(keyword) => match keyword { 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: % if not prop.style_struct.inherited:
CSSWideKeyword::Unset | CSSWideKeyword::Unset |
% endif % endif
@ -322,12 +329,22 @@ impl AnimationValue {
.get_${prop.style_struct.name_lower}(); .get_${prop.style_struct.name_lower}();
inherit_struct.clone_${prop.ident}() inherit_struct.clone_${prop.ident}()
}, },
}
}; };
Some(AnimationValue::${prop.camel_case}(computed)) Some(AnimationValue::${prop.camel_case}(computed))
} },
% endif % endif
% endfor % 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. _ => None // non animatable properties will get included because of shorthands. ignore.
} }
} }

View file

@ -342,7 +342,8 @@ impl PropertyDeclarationIdSet {
Parser::new(&css).parse_entirely(|input| { Parser::new(&css).parse_entirely(|input| {
match from_shorthand { match from_shorthand {
None => { None => {
longhands::${property.ident}::parse_specified(&context, input) longhands::${property.ident}
::parse_specified(&context, input).map(DeclaredValueOwned::Value)
} }
% for shorthand in data.shorthands: % for shorthand in data.shorthands:
% if property in shorthand.sub_properties: % if property in shorthand.sub_properties:
@ -350,9 +351,9 @@ impl PropertyDeclarationIdSet {
shorthands::${shorthand.ident}::parse_value(&context, input) shorthands::${shorthand.ident}::parse_value(&context, input)
.map(|result| { .map(|result| {
% if property.boxed: % if property.boxed:
DeclaredValue::Value(Box::new(result.${property.ident})) DeclaredValueOwned::Value(Box::new(result.${property.ident}))
% else: % else:
DeclaredValue::Value(result.${property.ident}) DeclaredValueOwned::Value(result.${property.ident})
% endif % endif
}) })
} }
@ -364,14 +365,14 @@ impl PropertyDeclarationIdSet {
}) })
.unwrap_or( .unwrap_or(
// Invalid at computed-value time. // Invalid at computed-value time.
DeclaredValue::CSSWideKeyword( DeclaredValueOwned::CSSWideKeyword(
% if property.style_struct.inherited: % if property.style_struct.inherited:
CSSWideKeyword::Inherit CSSWideKeyword::Inherit
% else: % else:
CSSWideKeyword::Initial CSSWideKeyword::Initial
% endif % endif
) )
) ).borrow()
); );
} }
% endif % endif
@ -570,7 +571,21 @@ impl ShorthandId {
/// Servo's representation of a declared value for a given `T`, which is the /// Servo's representation of a declared value for a given `T`, which is the
/// declared value for that property. /// declared value for that property.
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Debug)]
pub enum DeclaredValue<T> { 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<UnparsedValue>),
/// 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<T> {
/// A known specified value from the stylesheet. /// A known specified value from the stylesheet.
Value(T), Value(T),
/// An unparsed value that contains `var()` functions. /// An unparsed value that contains `var()` functions.
@ -579,6 +594,17 @@ pub enum DeclaredValue<T> {
CSSWideKeyword(CSSWideKeyword), CSSWideKeyword(CSSWideKeyword),
} }
impl<T> DeclaredValueOwned<T> {
/// Creates a dependent DeclaredValue from this DeclaredValueOwned.
fn borrow(&self) -> DeclaredValue<T> {
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. /// An unparsed property value that contains `var()` functions.
#[derive(PartialEq, Eq, Debug)] #[derive(PartialEq, Eq, Debug)]
pub struct UnparsedValue { pub struct UnparsedValue {
@ -592,7 +618,7 @@ pub struct UnparsedValue {
from_shorthand: Option<ShorthandId>, from_shorthand: Option<ShorthandId>,
} }
impl<T: HasViewportPercentage> HasViewportPercentage for DeclaredValue<T> { impl<'a, T: HasViewportPercentage> HasViewportPercentage for DeclaredValue<'a, T> {
fn has_viewport_percentage(&self) -> bool { fn has_viewport_percentage(&self) -> bool {
match *self { match *self {
DeclaredValue::Value(ref v) => v.has_viewport_percentage(), DeclaredValue::Value(ref v) => v.has_viewport_percentage(),
@ -605,7 +631,7 @@ impl<T: HasViewportPercentage> HasViewportPercentage for DeclaredValue<T> {
} }
} }
impl<T: ToCss> ToCss for DeclaredValue<T> { impl<'a, T: ToCss> ToCss for DeclaredValue<'a, T> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write, where W: fmt::Write,
{ {
@ -835,29 +861,25 @@ impl ParsedDeclaration {
% for sub_property in shorthand.sub_properties: % for sub_property in shorthand.sub_properties:
push(PropertyDeclaration::${sub_property.camel_case}( push(PropertyDeclaration::${sub_property.camel_case}(
% if sub_property.boxed: % if sub_property.boxed:
DeclaredValue::Value(Box::new(${sub_property.ident})) Box::new(${sub_property.ident})
% else: % else:
DeclaredValue::Value(${sub_property.ident}) ${sub_property.ident}
% endif % endif
)); ));
% endfor % endfor
} },
ParsedDeclaration::${shorthand.camel_case}CSSWideKeyword(keyword) => { ParsedDeclaration::${shorthand.camel_case}CSSWideKeyword(keyword) => {
% for sub_property in shorthand.sub_properties: % for sub_property in shorthand.sub_properties:
push(PropertyDeclaration::${sub_property.camel_case}( push(PropertyDeclaration::CSSWideKeyword(LonghandId::${sub_property.camel_case}, keyword));
DeclaredValue::CSSWideKeyword(keyword)
));
% endfor % endfor
} },
ParsedDeclaration::${shorthand.camel_case}WithVariables(value) => { ParsedDeclaration::${shorthand.camel_case}WithVariables(value) => {
debug_assert_eq!( debug_assert_eq!(
value.from_shorthand, value.from_shorthand,
Some(ShorthandId::${shorthand.camel_case}) Some(ShorthandId::${shorthand.camel_case})
); );
% for sub_property in shorthand.sub_properties: % for sub_property in shorthand.sub_properties:
push(PropertyDeclaration::${sub_property.camel_case}( push(PropertyDeclaration::WithVariables(LonghandId::${sub_property.camel_case}, value.clone()));
DeclaredValue::WithVariables(value.clone())
));
% endfor % endfor
} }
% endfor % endfor
@ -881,9 +903,9 @@ impl ParsedDeclaration {
match id { match id {
PropertyId::Custom(name) => { PropertyId::Custom(name) => {
let value = match input.try(|i| CSSWideKeyword::parse(context, i)) { 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) { Err(()) => match ::custom_properties::SpecifiedValue::parse(context, input) {
Ok(value) => DeclaredValue::Value(value), Ok(value) => DeclaredValueOwned::Value(value),
Err(()) => return Err(PropertyDeclarationParseError::InvalidValue), Err(()) => return Err(PropertyDeclarationParseError::InvalidValue),
} }
}; };
@ -908,9 +930,7 @@ impl ParsedDeclaration {
match longhands::${property.ident}::parse_declared(context, input) { match longhands::${property.ident}::parse_declared(context, input) {
Ok(value) => { Ok(value) => {
Ok(ParsedDeclaration::LonghandOrCustom( Ok(ParsedDeclaration::LonghandOrCustom(value))
PropertyDeclaration::${property.camel_case}(value)
))
}, },
Err(()) => Err(PropertyDeclarationParseError::InvalidValue), Err(()) => Err(PropertyDeclarationParseError::InvalidValue),
} }
@ -958,14 +978,18 @@ pub enum PropertyDeclaration {
% for property in data.longhands: % for property in data.longhands:
/// ${property.name} /// ${property.name}
% if property.boxed: % if property.boxed:
${property.camel_case}(DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>), ${property.camel_case}(Box<longhands::${property.ident}::SpecifiedValue>),
% else: % else:
${property.camel_case}(DeclaredValue<longhands::${property.ident}::SpecifiedValue>), ${property.camel_case}(longhands::${property.ident}::SpecifiedValue),
% endif % endif
% endfor % endfor
/// A css-wide keyword.
CSSWideKeyword(LonghandId, CSSWideKeyword),
/// An unparsed value that contains `var()` functions.
WithVariables(LonghandId, Arc<UnparsedValue>),
/// A custom property declaration, with the property name and the declared /// A custom property declaration, with the property name and the declared
/// value. /// value.
Custom(::custom_properties::Name, DeclaredValue<Box<::custom_properties::SpecifiedValue>>), Custom(::custom_properties::Name, DeclaredValueOwned<Box<::custom_properties::SpecifiedValue>>),
} }
impl HasViewportPercentage for PropertyDeclaration { impl HasViewportPercentage for PropertyDeclaration {
@ -976,8 +1000,13 @@ impl HasViewportPercentage for PropertyDeclaration {
val.has_viewport_percentage() val.has_viewport_percentage()
}, },
% endfor % endfor
PropertyDeclaration::WithVariables(..) => {
panic!("DeclaredValue::has_viewport_percentage without \
resolving variables!")
},
PropertyDeclaration::CSSWideKeyword(..) => false,
PropertyDeclaration::Custom(_, ref val) => { 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), value.to_css(dest),
% endif % endif
% endfor % 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): % if any(property.derived_from for property in data.longhands):
_ => Err(fmt::Error), _ => Err(fmt::Error),
% endif % endif
@ -1062,6 +1099,8 @@ impl PropertyDeclaration {
PropertyDeclarationId::Longhand(LonghandId::${property.camel_case}) PropertyDeclarationId::Longhand(LonghandId::${property.camel_case})
} }
% endfor % endfor
PropertyDeclaration::CSSWideKeyword(id, _) => PropertyDeclarationId::Longhand(id),
PropertyDeclaration::WithVariables(id, _) => PropertyDeclarationId::Longhand(id),
PropertyDeclaration::Custom(ref name, _) => { PropertyDeclaration::Custom(ref name, _) => {
PropertyDeclarationId::Custom(name) PropertyDeclarationId::Custom(name)
} }
@ -1070,35 +1109,22 @@ impl PropertyDeclaration {
fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> { fn with_variables_from_shorthand(&self, shorthand: ShorthandId) -> Option< &str> {
match *self { match *self {
% for property in data.longhands: PropertyDeclaration::WithVariables(_, ref with_variables) => {
PropertyDeclaration::${property.camel_case}(ref value) => match *value {
DeclaredValue::WithVariables(ref with_variables) => {
if let Some(s) = with_variables.from_shorthand { if let Some(s) = with_variables.from_shorthand {
if s == shorthand { if s == shorthand {
Some(&*with_variables.css) Some(&*with_variables.css)
} else { None } } else { None }
} else { None } } else { None }
}
_ => None
}, },
% endfor _ => None,
PropertyDeclaration::Custom(..) => None,
} }
} }
/// Returns a CSS-wide keyword if the declaration's value is one. /// Returns a CSS-wide keyword if the declaration's value is one.
pub fn get_css_wide_keyword(&self) -> Option<CSSWideKeyword> { pub fn get_css_wide_keyword(&self) -> Option<CSSWideKeyword> {
match *self { match *self {
% for property in data.longhands: PropertyDeclaration::CSSWideKeyword(_, keyword) => Some(keyword),
PropertyDeclaration::${property.camel_case}(ref value) => match *value {
DeclaredValue::CSSWideKeyword(keyword) => Some(keyword),
_ => None, _ => None,
},
% endfor
PropertyDeclaration::Custom(_, ref value) => match *value {
DeclaredValue::CSSWideKeyword(keyword) => Some(keyword),
_ => None,
}
} }
} }
@ -1116,14 +1142,11 @@ impl PropertyDeclaration {
/// the longhand declarations. /// the longhand declarations.
pub fn may_serialize_as_part_of_shorthand(&self) -> bool { pub fn may_serialize_as_part_of_shorthand(&self) -> bool {
match *self { match *self {
% for property in data.longhands: PropertyDeclaration::CSSWideKeyword(..) => false,
PropertyDeclaration::${property.camel_case}(ref value) => match *value { PropertyDeclaration::WithVariables(..) => false,
DeclaredValue::Value(_) => true,
_ => false,
},
% endfor
PropertyDeclaration::Custom(..) => PropertyDeclaration::Custom(..) =>
unreachable!("Serialize a custom property as part of shorthand?"), unreachable!("Serialize a custom property as part of shorthand?"),
_ => true,
} }
} }
@ -1135,12 +1158,9 @@ impl PropertyDeclaration {
/// unsubstituted variables. /// unsubstituted variables.
pub fn value_is_unparsed(&self) -> bool { pub fn value_is_unparsed(&self) -> bool {
match *self { match *self {
% for property in data.longhands: PropertyDeclaration::WithVariables(..) => true,
PropertyDeclaration::${property.camel_case}(ref value) => { PropertyDeclaration::Custom(..) => true,
matches!(*value, DeclaredValue::WithVariables(_)) _ => false,
},
% endfor
PropertyDeclaration::Custom(..) => true
} }
} }
@ -1173,6 +1193,12 @@ impl PropertyDeclaration {
% for property in data.longhands: % for property in data.longhands:
PropertyDeclaration::${property.camel_case}(_) => ${property.ident.upper()}, PropertyDeclaration::${property.camel_case}(_) => ${property.ident.upper()},
% endfor % endfor
PropertyDeclaration::CSSWideKeyword(id, _) |
PropertyDeclaration::WithVariables(id, _) => match id {
% for property in data.longhands:
LonghandId::${property.camel_case} => ${property.ident.upper()},
% endfor
},
PropertyDeclaration::Custom(_, _) => &[] PropertyDeclaration::Custom(_, _) => &[]
} }
} }
@ -1190,6 +1216,18 @@ impl PropertyDeclaration {
% endif % endif
} }
% endfor % 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, 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 { if let PropertyDeclaration::Custom(ref name, ref value) = *declaration {
::custom_properties::cascade( ::custom_properties::cascade(
&mut custom_properties, &inherited_custom_properties, &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, its not easy to check that this // Unfortunately, its not easy to check that this
// classification is correct. // classification is correct.
let is_early_property = matches!(*declaration, let is_early_property = matches!(longhand_id,
PropertyDeclaration::FontSize(_) | LonghandId::FontSize |
PropertyDeclaration::FontFamily(_) | LonghandId::FontFamily |
PropertyDeclaration::Color(_) | LonghandId::Color |
PropertyDeclaration::Position(_) | LonghandId::Position |
PropertyDeclaration::Float(_) | LonghandId::Float |
PropertyDeclaration::TextDecorationLine(_) | LonghandId::TextDecorationLine |
PropertyDeclaration::WritingMode(_) | LonghandId::WritingMode |
PropertyDeclaration::Direction(_) LonghandId::Direction
% if product == 'gecko': % if product == 'gecko':
| PropertyDeclaration::TextOrientation(_) | LonghandId::TextOrientation
| PropertyDeclaration::AnimationName(_) | LonghandId::AnimationName
| PropertyDeclaration::TransitionProperty(_) | LonghandId::TransitionProperty
% endif % endif
); );
if if
@ -2395,7 +2433,7 @@ macro_rules! longhand_properties_idents {
pub fn test_size_of_property_declaration() { pub fn test_size_of_property_declaration() {
use std::mem::size_of; use std::mem::size_of;
let old = 48; let old = 40;
let new = size_of::<PropertyDeclaration>(); let new = size_of::<PropertyDeclaration>();
if new < old { if new < old {
panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \ panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \

View file

@ -1008,7 +1008,7 @@ macro_rules! match_wrap_declared {
($longhand:ident, $($property:ident => $inner:expr,)*) => ( ($longhand:ident, $($property:ident => $inner:expr,)*) => (
match $longhand { 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); error!("stylo: Don't know how to handle presentation property {:?}", $longhand);
@ -1036,7 +1036,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetIdentStringValue(declarations:
nsCSSPropertyID, nsCSSPropertyID,
value: value:
*mut nsIAtom) { *mut nsIAtom) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands::_x_lang::computed_value::T as Lang; use style::properties::longhands::_x_lang::computed_value::T as Lang;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -1053,7 +1053,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetKeywordValue(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID, property: nsCSSPropertyID,
value: i32) { value: i32) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands; use style::properties::longhands;
use style::values::specified::{BorderStyle, NoCalcLength}; 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, pub extern "C" fn Servo_DeclarationBlock_SetIntValue(declarations: RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID, property: nsCSSPropertyID,
value: i32) { value: i32) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands::_x_span::computed_value::T as Span; use style::properties::longhands::_x_span::computed_value::T as Span;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -1104,7 +1104,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID, property: nsCSSPropertyID,
value: f32) { value: f32) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing; use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing;
use style::values::specified::BorderWidth; use style::values::specified::BorderWidth;
use style::values::specified::length::NoCalcLength; use style::values::specified::length::NoCalcLength;
@ -1143,7 +1143,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID, property: nsCSSPropertyID,
value: f32) { value: f32) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::values::specified::length::Percentage; use style::values::specified::length::Percentage;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -1165,7 +1165,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPercentValue(declarations:
pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations: pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID) { property: nsCSSPropertyID) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::values::specified::LengthOrPercentageOrAuto; use style::values::specified::LengthOrPercentageOrAuto;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -1187,7 +1187,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetAutoValue(declarations:
pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(declarations: pub extern "C" fn Servo_DeclarationBlock_SetCurrentColor(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID) { property: nsCSSPropertyID) {
use style::properties::{DeclaredValue, PropertyDeclaration, LonghandId}; use style::properties::{PropertyDeclaration, LonghandId};
use style::values::specified::{Color, CSSColor}; use style::values::specified::{Color, CSSColor};
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -1209,7 +1209,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetColorValue(declarations:
property: nsCSSPropertyID, property: nsCSSPropertyID,
value: structs::nscolor) { value: structs::nscolor) {
use style::gecko::values::convert_nscolor_to_rgba; 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::properties::longhands;
use style::values::specified::{Color, CSSColor}; use style::values::specified::{Color, CSSColor};
@ -1234,7 +1234,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations:
RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockBorrowed,
value: *const nsAString) { value: *const nsAString) {
use cssparser::Parser; use cssparser::Parser;
use style::properties::{DeclaredValue, PropertyDeclaration}; use style::properties::PropertyDeclaration;
use style::properties::longhands::font_family::SpecifiedValue as FontFamily; use style::properties::longhands::font_family::SpecifiedValue as FontFamily;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
@ -1242,7 +1242,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations:
let mut parser = Parser::new(&string); let mut parser = Parser::new(&string);
if let Ok(family) = FontFamily::parse(&mut parser) { if let Ok(family) = FontFamily::parse(&mut parser) {
if parser.is_exhausted() { if parser.is_exhausted() {
let decl = PropertyDeclaration::FontFamily(DeclaredValue::Value(family)); let decl = PropertyDeclaration::FontFamily(family);
declarations.write().push(decl, Importance::Normal); declarations.write().push(decl, Importance::Normal);
} }
} }
@ -1251,13 +1251,13 @@ pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations:
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations: pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarations:
RawServoDeclarationBlockBorrowed) { RawServoDeclarationBlockBorrowed) {
use style::properties::{DeclaredValue, PropertyDeclaration}; use style::properties::PropertyDeclaration;
use style::properties::longhands::text_decoration_line; use style::properties::longhands::text_decoration_line;
let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations); let declarations = RwLock::<PropertyDeclarationBlock>::as_arc(&declarations);
let mut decoration = text_decoration_line::computed_value::none; let mut decoration = text_decoration_line::computed_value::none;
decoration |= text_decoration_line::COLOR_OVERRIDE; decoration |= text_decoration_line::COLOR_OVERRIDE;
let decl = PropertyDeclaration::TextDecorationLine(DeclaredValue::Value(decoration)); let decl = PropertyDeclaration::TextDecorationLine(decoration);
declarations.write().push(decl, Importance::Normal); declarations.write().push(decl, Importance::Normal);
} }

View file

@ -6,7 +6,7 @@ use parking_lot::RwLock;
use std::sync::Arc; use std::sync::Arc;
use style::keyframes::{Keyframe, KeyframesAnimation, KeyframePercentage, KeyframeSelector}; use style::keyframes::{Keyframe, KeyframesAnimation, KeyframePercentage, KeyframeSelector};
use style::keyframes::{KeyframesStep, KeyframesStepValue}; 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::properties::animated_properties::TransitionProperty;
use style::values::specified::{LengthOrPercentageOrAuto, NoCalcLength}; use style::values::specified::{LengthOrPercentageOrAuto, NoCalcLength};
@ -44,7 +44,7 @@ fn test_missing_property_in_initial_keyframe() {
let declarations_on_initial_keyframe = let declarations_on_initial_keyframe =
Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Width( PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
))); )));
@ -53,12 +53,12 @@ fn test_missing_property_in_initial_keyframe() {
let mut block = PropertyDeclarationBlock::new(); let mut block = PropertyDeclarationBlock::new();
block.push( block.push(
PropertyDeclaration::Width( PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
); );
block.push( block.push(
PropertyDeclaration::Height( PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
); );
block block
@ -102,12 +102,12 @@ fn test_missing_property_in_final_keyframe() {
let mut block = PropertyDeclarationBlock::new(); let mut block = PropertyDeclarationBlock::new();
block.push( block.push(
PropertyDeclaration::Width( PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
); );
block.push( block.push(
PropertyDeclaration::Height( PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
); );
block block
@ -116,7 +116,7 @@ fn test_missing_property_in_final_keyframe() {
let declarations_on_final_keyframe = let declarations_on_final_keyframe =
Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Height( PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal, Importance::Normal,
))); )));
@ -158,12 +158,12 @@ fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
let mut block = PropertyDeclarationBlock::new(); let mut block = PropertyDeclarationBlock::new();
block.push( block.push(
PropertyDeclaration::Width( PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
); );
block.push( block.push(
PropertyDeclaration::Height( PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Normal Importance::Normal
); );
block block

View file

@ -7,8 +7,7 @@ use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use style::computed_values::display::T::inline_block; use style::computed_values::display::T::inline_block;
use style::parser::ParserContext; use style::parser::ParserContext;
use style::properties::{DeclaredValue, PropertyDeclaration}; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, Importance, PropertyId};
use style::properties::{PropertyDeclarationBlock, Importance, PropertyId};
use style::properties::longhands::outline_color::computed_value::T as ComputedColor; use style::properties::longhands::outline_color::computed_value::T as ComputedColor;
use style::properties::parse_property_declaration_list; use style::properties::parse_property_declaration_list;
use style::stylesheets::Origin; use style::stylesheets::Origin;
@ -34,27 +33,27 @@ fn property_declaration_block_should_serialize_correctly() {
let declarations = vec![ let declarations = vec![
(PropertyDeclaration::Width( (PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(70f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(70f32))),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::MinHeight( (PropertyDeclaration::MinHeight(
DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentage::Length(NoCalcLength::from_px(20f32))),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::Height( (PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Important), Importance::Important),
(PropertyDeclaration::Display( (PropertyDeclaration::Display(
DeclaredValue::Value(inline_block)), inline_block),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::OverflowX( (PropertyDeclaration::OverflowX(
DeclaredValue::Value(OverflowXValue::auto)), OverflowXValue::auto),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::OverflowY( (PropertyDeclaration::OverflowY(
DeclaredValue::Value(OverflowYContainer(OverflowXValue::auto))), OverflowYContainer(OverflowXValue::auto)),
Importance::Normal), Importance::Normal),
]; ];
@ -88,10 +87,10 @@ mod shorthand_serialization {
fn equal_overflow_properties_should_serialize_to_single_value() { fn equal_overflow_properties_should_serialize_to_single_value() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let overflow_x = DeclaredValue::Value(OverflowXValue::auto); let overflow_x = OverflowXValue::auto;
properties.push(PropertyDeclaration::OverflowX(overflow_x)); 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)); properties.push(PropertyDeclaration::OverflowY(overflow_y));
let serialization = shorthand_properties_to_string(properties); let serialization = shorthand_properties_to_string(properties);
@ -102,10 +101,10 @@ mod shorthand_serialization {
fn different_overflow_properties_should_serialize_to_two_values() { fn different_overflow_properties_should_serialize_to_two_values() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let overflow_x = DeclaredValue::Value(OverflowXValue::scroll); let overflow_x = OverflowXValue::scroll;
properties.push(PropertyDeclaration::OverflowX(overflow_x)); 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)); properties.push(PropertyDeclaration::OverflowY(overflow_y));
let serialization = shorthand_properties_to_string(properties); let serialization = shorthand_properties_to_string(properties);
@ -122,12 +121,12 @@ mod shorthand_serialization {
fn text_decoration_should_show_all_properties_when_set() { fn text_decoration_should_show_all_properties_when_set() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let line = DeclaredValue::Value(TextDecorationLine::OVERLINE); let line = TextDecorationLine::OVERLINE;
let style = DeclaredValue::Value(TextDecorationStyle::dotted); let style = TextDecorationStyle::dotted;
let color = DeclaredValue::Value(CSSColor { let color = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(128, 0, 128, 255)), parsed: ComputedColor::RGBA(RGBA::new(128, 0, 128, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::TextDecorationLine(line)); properties.push(PropertyDeclaration::TextDecorationLine(line));
properties.push(PropertyDeclaration::TextDecorationStyle(style)); properties.push(PropertyDeclaration::TextDecorationStyle(style));
@ -141,9 +140,9 @@ mod shorthand_serialization {
fn text_decoration_should_not_serialize_initial_style_value() { fn text_decoration_should_not_serialize_initial_style_value() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let line = DeclaredValue::Value(TextDecorationLine::UNDERLINE); let line = TextDecorationLine::UNDERLINE;
let style = DeclaredValue::Value(TextDecorationStyle::solid); let style = TextDecorationStyle::solid;
let color = DeclaredValue::Value(CSSColor::currentcolor()); let color = CSSColor::currentcolor();
properties.push(PropertyDeclaration::TextDecorationLine(line)); properties.push(PropertyDeclaration::TextDecorationLine(line));
properties.push(PropertyDeclaration::TextDecorationStyle(style)); properties.push(PropertyDeclaration::TextDecorationStyle(style));
@ -163,7 +162,7 @@ mod shorthand_serialization {
fn all_equal_properties_should_serialize_to_one_value() { fn all_equal_properties_should_serialize_to_one_value() {
let mut properties = Vec::new(); 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::MarginTop(px_70.clone()));
properties.push(PropertyDeclaration::MarginRight(px_70.clone())); properties.push(PropertyDeclaration::MarginRight(px_70.clone()));
properties.push(PropertyDeclaration::MarginBottom(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() { fn equal_vertical_and_equal_horizontal_properties_should_serialize_to_two_value() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let vertical_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32))); let vertical_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32));
let horizontal_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32))); let horizontal_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32));
properties.push(PropertyDeclaration::MarginTop(vertical_px.clone())); properties.push(PropertyDeclaration::MarginTop(vertical_px.clone()));
properties.push(PropertyDeclaration::MarginRight(horizontal_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() { fn different_vertical_and_equal_horizontal_properties_should_serialize_to_three_values() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let top_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32))); let top_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32));
let bottom_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32))); let bottom_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32));
let horizontal_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32))); let horizontal_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(5f32));
properties.push(PropertyDeclaration::MarginTop(top_px)); properties.push(PropertyDeclaration::MarginTop(top_px));
properties.push(PropertyDeclaration::MarginRight(horizontal_px.clone())); properties.push(PropertyDeclaration::MarginRight(horizontal_px.clone()));
@ -210,10 +209,10 @@ mod shorthand_serialization {
fn different_properties_should_serialize_to_four_values() { fn different_properties_should_serialize_to_four_values() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let top_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32))); let top_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(8f32));
let right_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(12f32))); let right_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(12f32));
let bottom_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32))); let bottom_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(10f32));
let left_px = DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(14f32))); let left_px = LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(14f32));
properties.push(PropertyDeclaration::MarginTop(top_px)); properties.push(PropertyDeclaration::MarginTop(top_px));
properties.push(PropertyDeclaration::MarginRight(right_px)); properties.push(PropertyDeclaration::MarginRight(right_px));
@ -228,25 +227,25 @@ mod shorthand_serialization {
fn different_longhands_should_serialize_to_long_form() { fn different_longhands_should_serialize_to_long_form() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let solid = DeclaredValue::Value(BorderStyle::solid); let solid = BorderStyle::solid;
properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderTopStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderLeftStyle(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));
let px_10 = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(10f32))); let px_10 = BorderWidth::from_length(Length::from_px(10f32));
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(px_10.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)), parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::BorderTopColor(blue.clone())); properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
properties.push(PropertyDeclaration::BorderRightColor(blue.clone())); properties.push(PropertyDeclaration::BorderRightColor(blue.clone()));
@ -262,24 +261,24 @@ mod shorthand_serialization {
fn same_longhands_should_serialize_correctly() { fn same_longhands_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let solid = DeclaredValue::Value(BorderStyle::solid); let solid = BorderStyle::solid;
properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderTopStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderLeftStyle(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::BorderTopWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(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)), parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::BorderTopColor(blue.clone())); properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
properties.push(PropertyDeclaration::BorderRightColor(blue.clone())); properties.push(PropertyDeclaration::BorderRightColor(blue.clone()));
@ -294,8 +293,8 @@ mod shorthand_serialization {
fn padding_should_serialize_correctly() { fn padding_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let px_10 = DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(10f32))); let px_10 = LengthOrPercentage::Length(NoCalcLength::from_px(10f32));
let px_15 = DeclaredValue::Value(LengthOrPercentage::Length(NoCalcLength::from_px(15f32))); let px_15 = LengthOrPercentage::Length(NoCalcLength::from_px(15f32));
properties.push(PropertyDeclaration::PaddingTop(px_10.clone())); properties.push(PropertyDeclaration::PaddingTop(px_10.clone()));
properties.push(PropertyDeclaration::PaddingRight(px_15.clone())); properties.push(PropertyDeclaration::PaddingRight(px_15.clone()));
properties.push(PropertyDeclaration::PaddingBottom(px_10)); properties.push(PropertyDeclaration::PaddingBottom(px_10));
@ -309,11 +308,11 @@ mod shorthand_serialization {
fn border_width_should_serialize_correctly() { fn border_width_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let top_px = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(10f32))); let top_px = BorderWidth::from_length(Length::from_px(10f32));
let bottom_px = DeclaredValue::Value(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 right_px = BorderWidth::from_length(Length::from_px(15f32));
let left_px = DeclaredValue::Value(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::BorderTopWidth(top_px));
properties.push(PropertyDeclaration::BorderRightWidth(right_px)); properties.push(PropertyDeclaration::BorderRightWidth(right_px));
@ -328,10 +327,10 @@ mod shorthand_serialization {
fn border_width_with_keywords_should_serialize_correctly() { fn border_width_with_keywords_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let top_px = DeclaredValue::Value(BorderWidth::Thin); let top_px = BorderWidth::Thin;
let right_px = DeclaredValue::Value(BorderWidth::Medium); let right_px = BorderWidth::Medium;
let bottom_px = DeclaredValue::Value(BorderWidth::Thick); let bottom_px = BorderWidth::Thick;
let left_px = DeclaredValue::Value(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::BorderTopWidth(top_px));
properties.push(PropertyDeclaration::BorderRightWidth(right_px)); properties.push(PropertyDeclaration::BorderRightWidth(right_px));
@ -346,15 +345,15 @@ mod shorthand_serialization {
fn border_color_should_serialize_correctly() { fn border_color_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let red = DeclaredValue::Value(CSSColor { let red = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
authored: None authored: None
}); };
let blue = DeclaredValue::Value(CSSColor { let blue = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::BorderTopColor(blue.clone())); properties.push(PropertyDeclaration::BorderTopColor(blue.clone()));
properties.push(PropertyDeclaration::BorderRightColor(red.clone())); properties.push(PropertyDeclaration::BorderRightColor(red.clone()));
@ -371,8 +370,8 @@ mod shorthand_serialization {
fn border_style_should_serialize_correctly() { fn border_style_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let solid = DeclaredValue::Value(BorderStyle::solid); let solid = BorderStyle::solid;
let dotted = DeclaredValue::Value(BorderStyle::dotted); let dotted = BorderStyle::dotted;
properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderTopStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(dotted.clone())); properties.push(PropertyDeclaration::BorderRightStyle(dotted.clone()));
properties.push(PropertyDeclaration::BorderBottomStyle(solid)); properties.push(PropertyDeclaration::BorderBottomStyle(solid));
@ -394,12 +393,12 @@ mod shorthand_serialization {
fn directional_border_should_show_all_properties_when_values_are_set() { fn directional_border_should_show_all_properties_when_values_are_set() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let width = DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))); let width = BorderWidth::from_length(Length::from_px(4f32));
let style = DeclaredValue::Value(BorderStyle::solid); let style = BorderStyle::solid;
let color = DeclaredValue::Value(CSSColor { let color = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopWidth(width));
properties.push(PropertyDeclaration::BorderTopStyle(style)); properties.push(PropertyDeclaration::BorderTopStyle(style));
@ -409,12 +408,10 @@ mod shorthand_serialization {
assert_eq!(serialization, "border-top: 4px solid rgb(255, 0, 0);"); assert_eq!(serialization, "border-top: 4px solid rgb(255, 0, 0);");
} }
fn get_border_property_values() -> (DeclaredValue<BorderWidth>, fn get_border_property_values() -> (BorderWidth, BorderStyle, CSSColor) {
DeclaredValue<BorderStyle>, (BorderWidth::from_length(Length::from_px(4f32)),
DeclaredValue<CSSColor>) { BorderStyle::solid,
(DeclaredValue::Value(BorderWidth::from_length(Length::from_px(4f32))), CSSColor::currentcolor())
DeclaredValue::Value(BorderStyle::solid),
DeclaredValue::Value(CSSColor::currentcolor()))
} }
#[test] #[test]
@ -501,10 +498,10 @@ mod shorthand_serialization {
fn list_style_should_show_all_properties_when_values_are_set() { fn list_style_should_show_all_properties_when_values_are_set() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let position = DeclaredValue::Value(ListStylePosition::inside); let position = ListStylePosition::inside;
let image = DeclaredValue::Value(Either::First( let image = Either::First(
SpecifiedUrl::new_for_testing("http://servo/test.png"))); SpecifiedUrl::new_for_testing("http://servo/test.png"));
let style_type = DeclaredValue::Value(ListStyleType::disc); let style_type = ListStyleType::disc;
properties.push(PropertyDeclaration::ListStylePosition(position)); properties.push(PropertyDeclaration::ListStylePosition(position));
properties.push(PropertyDeclaration::ListStyleImage(image)); properties.push(PropertyDeclaration::ListStyleImage(image));
@ -524,12 +521,12 @@ mod shorthand_serialization {
fn outline_should_show_all_properties_when_set() { fn outline_should_show_all_properties_when_set() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32))); let width = WidthContainer(Length::from_px(4f32));
let style = DeclaredValue::Value(Either::Second(BorderStyle::solid)); let style = Either::Second(BorderStyle::solid);
let color = DeclaredValue::Value(CSSColor { let color = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::OutlineWidth(width)); properties.push(PropertyDeclaration::OutlineWidth(width));
properties.push(PropertyDeclaration::OutlineStyle(style)); properties.push(PropertyDeclaration::OutlineStyle(style));
@ -543,12 +540,12 @@ mod shorthand_serialization {
fn outline_should_serialize_correctly_when_style_is_auto() { fn outline_should_serialize_correctly_when_style_is_auto() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let width = DeclaredValue::Value(WidthContainer(Length::from_px(4f32))); let width = WidthContainer(Length::from_px(4f32));
let style = DeclaredValue::Value(Either::First(Auto)); let style = Either::First(Auto);
let color = DeclaredValue::Value(CSSColor { let color = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)), parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
authored: None authored: None
}); };
properties.push(PropertyDeclaration::OutlineWidth(width)); properties.push(PropertyDeclaration::OutlineWidth(width));
properties.push(PropertyDeclaration::OutlineStyle(style)); properties.push(PropertyDeclaration::OutlineStyle(style));
properties.push(PropertyDeclaration::OutlineColor(color)); properties.push(PropertyDeclaration::OutlineColor(color));
@ -565,8 +562,8 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let width = DeclaredValue::Value(Either::Second(Auto)); let width = Either::Second(Auto);
let count = DeclaredValue::Value(ColumnCount::Auto); let count = ColumnCount::Auto;
properties.push(PropertyDeclaration::ColumnWidth(width)); properties.push(PropertyDeclaration::ColumnWidth(width));
properties.push(PropertyDeclaration::ColumnCount(count)); properties.push(PropertyDeclaration::ColumnCount(count));
@ -582,11 +579,10 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let grow = DeclaredValue::Value(NumberContainer(2f32)); let grow = NumberContainer(2f32);
let shrink = DeclaredValue::Value(NumberContainer(3f32)); let shrink = NumberContainer(3f32);
let basis = DeclaredValue::Value( let basis =
LengthOrPercentageOrAutoOrContent::Percentage(PercentageContainer(0.5f32)) LengthOrPercentageOrAutoOrContent::Percentage(PercentageContainer(0.5f32));
);
properties.push(PropertyDeclaration::FlexGrow(grow)); properties.push(PropertyDeclaration::FlexGrow(grow));
properties.push(PropertyDeclaration::FlexShrink(shrink)); properties.push(PropertyDeclaration::FlexShrink(shrink));
@ -603,8 +599,8 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let direction = DeclaredValue::Value(FlexDirection::row); let direction = FlexDirection::row;
let wrap = DeclaredValue::Value(FlexWrap::wrap); let wrap = FlexWrap::wrap;
properties.push(PropertyDeclaration::FlexDirection(direction)); properties.push(PropertyDeclaration::FlexDirection(direction));
properties.push(PropertyDeclaration::FlexWrap(wrap)); properties.push(PropertyDeclaration::FlexWrap(wrap));
@ -774,23 +770,23 @@ mod shorthand_serialization {
macro_rules! single_vec_value_typedef { macro_rules! single_vec_value_typedef {
($name:ident, $path:expr) => { ($name:ident, $path:expr) => {
DeclaredValue::Value($name::SpecifiedValue( $name::SpecifiedValue(
vec![$path] vec![$path]
)) )
}; };
} }
macro_rules! single_vec_keyword_value { macro_rules! single_vec_keyword_value {
($name:ident, $kw:ident) => { ($name:ident, $kw:ident) => {
DeclaredValue::Value($name::SpecifiedValue( $name::SpecifiedValue(
vec![$name::single_value::SpecifiedValue::$kw] vec![$name::single_value::SpecifiedValue::$kw]
)) )
}; };
} }
macro_rules! single_vec_variant_value { macro_rules! single_vec_variant_value {
($name:ident, $variant:expr) => { ($name:ident, $variant:expr) => {
DeclaredValue::Value($name::SpecifiedValue( $name::SpecifiedValue(
vec![$variant] vec![$variant]
)) )
}; };
} }
@ -913,9 +909,9 @@ mod shorthand_serialization {
#[test] #[test]
fn should_serialize_to_empty_string_if_sub_types_not_equal() { fn should_serialize_to_empty_string_if_sub_types_not_equal() {
let declarations = vec![ let declarations = vec![
(PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)), (PropertyDeclaration::ScrollSnapTypeX(ScrollSnapTypeXValue::mandatory),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::none)), (PropertyDeclaration::ScrollSnapTypeY(ScrollSnapTypeXValue::none),
Importance::Normal) Importance::Normal)
]; ];
@ -933,9 +929,9 @@ mod shorthand_serialization {
#[test] #[test]
fn should_serialize_to_single_value_if_sub_types_are_equal() { fn should_serialize_to_single_value_if_sub_types_are_equal() {
let declarations = vec![ let declarations = vec![
(PropertyDeclaration::ScrollSnapTypeX(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)), (PropertyDeclaration::ScrollSnapTypeX(ScrollSnapTypeXValue::mandatory),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::ScrollSnapTypeY(DeclaredValue::Value(ScrollSnapTypeXValue::mandatory)), (PropertyDeclaration::ScrollSnapTypeY(ScrollSnapTypeXValue::mandatory),
Importance::Normal) Importance::Normal)
]; ];

View file

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use app_units::Au; use app_units::Au;
use style::properties::{DeclaredValue, PropertyDeclaration}; use style::properties::PropertyDeclaration;
use style::properties::longhands::border_top_width; use style::properties::longhands::border_top_width;
use style::values::HasViewportPercentage; use style::values::HasViewportPercentage;
use style::values::specified::{Length, NoCalcLength, ViewportPercentageLength}; 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() { fn has_viewport_percentage_for_specified_value() {
//TODO: test all specified value with a HasViewportPercentage impl //TODO: test all specified value with a HasViewportPercentage impl
let pvw = PropertyDeclaration::BorderTopWidth( 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.))) Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)))
)) )
); );
assert!(pvw.has_viewport_percentage()); assert!(pvw.has_viewport_percentage());
let pabs = PropertyDeclaration::BorderTopWidth( let pabs = PropertyDeclaration::BorderTopWidth(
DeclaredValue::Value(border_top_width::SpecifiedValue::from_length( border_top_width::SpecifiedValue::from_length(
Length::NoCalc(NoCalcLength::Absolute(Au(100))) Length::NoCalc(NoCalcLength::Absolute(Au(100)))
)) )
); );
assert!(!pabs.has_viewport_percentage()); assert!(!pabs.has_viewport_percentage());
} }

View file

@ -10,7 +10,7 @@ use std::sync::Arc;
use style::error_reporting::ParseErrorReporter; use style::error_reporting::ParseErrorReporter;
use style::media_queries::MediaList; use style::media_queries::MediaList;
use style::parser::ParserContextExtraData; 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::rule_tree::{CascadeLevel, RuleTree, StrongRuleNode, StyleSource};
use style::stylesheets::{Origin, Stylesheet, CssRule}; use style::stylesheets::{Origin, Stylesheet, CssRule};
use test::{self, Bencher}; 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 { fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)]) -> StrongRuleNode {
let mut rules = rules.to_vec(); let mut rules = rules.to_vec();
rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Display(DeclaredValue::Value( PropertyDeclaration::Display(
longhands::display::SpecifiedValue::block)), longhands::display::SpecifiedValue::block),
Importance::Normal Importance::Normal
)))), CascadeLevel::UserNormal)); )))), CascadeLevel::UserNormal));
test_insertion(rule_tree, rules) test_insertion(rule_tree, rules)

View file

@ -17,8 +17,8 @@ use style::error_reporting::ParseErrorReporter;
use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage}; use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage};
use style::parser::ParserContextExtraData; use style::parser::ParserContextExtraData;
use style::properties::Importance; use style::properties::Importance;
use style::properties::{CSSWideKeyword, PropertyDeclaration, PropertyDeclarationBlock}; use style::properties::{CSSWideKeyword, DeclaredValueOwned, PropertyDeclaration, PropertyDeclarationBlock};
use style::properties::{DeclaredValue, longhands}; use style::properties::longhands;
use style::properties::longhands::animation_play_state; use style::properties::longhands::animation_play_state;
use style::stylesheets::{Origin, Namespaces}; use style::stylesheets::{Origin, Namespaces};
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule}; 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![ block: Arc::new(RwLock::new(block_from(vec![
(PropertyDeclaration::Display(DeclaredValue::Value( (PropertyDeclaration::Display(longhands::display::SpecifiedValue::none),
longhands::display::SpecifiedValue::none)),
Importance::Important), Importance::Important),
(PropertyDeclaration::Custom(Atom::from("a"), (PropertyDeclaration::Custom(Atom::from("a"),
DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)), DeclaredValueOwned::CSSWideKeyword(CSSWideKeyword::Inherit)),
Importance::Important), Importance::Important),
]))), ]))),
}))), }))),
@ -154,8 +153,7 @@ fn test_parse_stylesheet() {
}, },
]), ]),
block: Arc::new(RwLock::new(block_from(vec![ block: Arc::new(RwLock::new(block_from(vec![
(PropertyDeclaration::Display(DeclaredValue::Value( (PropertyDeclaration::Display(longhands::display::SpecifiedValue::block),
longhands::display::SpecifiedValue::block)),
Importance::Normal), Importance::Normal),
]))), ]))),
}))), }))),
@ -186,52 +184,52 @@ fn test_parse_stylesheet() {
}, },
]), ]),
block: Arc::new(RwLock::new(block_from(vec![ block: Arc::new(RwLock::new(block_from(vec![
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value( (PropertyDeclaration::BackgroundColor(
longhands::background_color::SpecifiedValue { longhands::background_color::SpecifiedValue {
authored: Some("blue".to_owned().into_boxed_str()), authored: Some("blue".to_owned().into_boxed_str()),
parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)), parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)),
} }
)), ),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value( (PropertyDeclaration::BackgroundPositionX(
longhands::background_position_x::SpecifiedValue( longhands::background_position_x::SpecifiedValue(
vec![longhands::background_position_x::single_value vec![longhands::background_position_x::single_value
::get_initial_position_value()]))), ::get_initial_position_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value( (PropertyDeclaration::BackgroundPositionY(
longhands::background_position_y::SpecifiedValue( longhands::background_position_y::SpecifiedValue(
vec![longhands::background_position_y::single_value vec![longhands::background_position_y::single_value
::get_initial_position_value()]))), ::get_initial_position_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value( (PropertyDeclaration::BackgroundRepeat(
longhands::background_repeat::SpecifiedValue( longhands::background_repeat::SpecifiedValue(
vec![longhands::background_repeat::single_value vec![longhands::background_repeat::single_value
::get_initial_specified_value()]))), ::get_initial_specified_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundAttachment(DeclaredValue::Value( (PropertyDeclaration::BackgroundAttachment(
longhands::background_attachment::SpecifiedValue( longhands::background_attachment::SpecifiedValue(
vec![longhands::background_attachment::single_value vec![longhands::background_attachment::single_value
::get_initial_specified_value()]))), ::get_initial_specified_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundImage(DeclaredValue::Value( (PropertyDeclaration::BackgroundImage(
longhands::background_image::SpecifiedValue( longhands::background_image::SpecifiedValue(
vec![longhands::background_image::single_value vec![longhands::background_image::single_value
::get_initial_specified_value()]))), ::get_initial_specified_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundSize(DeclaredValue::Value( (PropertyDeclaration::BackgroundSize(
longhands::background_size::SpecifiedValue( longhands::background_size::SpecifiedValue(
vec![longhands::background_size::single_value vec![longhands::background_size::single_value
::get_initial_specified_value()]))), ::get_initial_specified_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundOrigin(DeclaredValue::Value( (PropertyDeclaration::BackgroundOrigin(
longhands::background_origin::SpecifiedValue( longhands::background_origin::SpecifiedValue(
vec![longhands::background_origin::single_value vec![longhands::background_origin::single_value
::get_initial_specified_value()]))), ::get_initial_specified_value()])),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::BackgroundClip(DeclaredValue::Value( (PropertyDeclaration::BackgroundClip(
longhands::background_clip::SpecifiedValue( longhands::background_clip::SpecifiedValue(
vec![longhands::background_clip::single_value vec![longhands::background_clip::single_value
::get_initial_specified_value()]))), ::get_initial_specified_value()])),
Importance::Normal), Importance::Normal),
]))), ]))),
}))), }))),
@ -242,8 +240,8 @@ fn test_parse_stylesheet() {
selector: KeyframeSelector::new_for_unit_testing( selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(0.)]), vec![KeyframePercentage::new(0.)]),
block: Arc::new(RwLock::new(block_from(vec![ block: Arc::new(RwLock::new(block_from(vec![
(PropertyDeclaration::Width(DeclaredValue::Value( (PropertyDeclaration::Width(
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))), LengthOrPercentageOrAuto::Percentage(Percentage(0.))),
Importance::Normal), Importance::Normal),
]))) ])))
})), })),
@ -251,12 +249,12 @@ fn test_parse_stylesheet() {
selector: KeyframeSelector::new_for_unit_testing( selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(1.)]), vec![KeyframePercentage::new(1.)]),
block: Arc::new(RwLock::new(block_from(vec![ block: Arc::new(RwLock::new(block_from(vec![
(PropertyDeclaration::Width(DeclaredValue::Value( (PropertyDeclaration::Width(
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))), LengthOrPercentageOrAuto::Percentage(Percentage(1.))),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::AnimationPlayState(DeclaredValue::Value( (PropertyDeclaration::AnimationPlayState(
animation_play_state::SpecifiedValue( animation_play_state::SpecifiedValue(
vec![animation_play_state::SingleSpecifiedValue::running]))), vec![animation_play_state::SingleSpecifiedValue::running])),
Importance::Normal), Importance::Normal),
]))), ]))),
})), })),

View file

@ -7,7 +7,7 @@ use parking_lot::RwLock;
use selectors::parser::LocalName as LocalNameSelector; use selectors::parser::LocalName as LocalNameSelector;
use servo_atoms::Atom; use servo_atoms::Atom;
use std::sync::Arc; use std::sync::Arc;
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, DeclaredValue}; use style::properties::{PropertyDeclarationBlock, PropertyDeclaration};
use style::properties::{longhands, Importance}; use style::properties::{longhands, Importance};
use style::rule_tree::CascadeLevel; use style::rule_tree::CascadeLevel;
use style::selector_parser::SelectorParser; use style::selector_parser::SelectorParser;
@ -24,8 +24,8 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
let rule = Arc::new(RwLock::new(StyleRule { let rule = Arc::new(RwLock::new(StyleRule {
selectors: selectors, selectors: selectors,
block: Arc::new(RwLock::new(PropertyDeclarationBlock::with_one( block: Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Display(DeclaredValue::Value( PropertyDeclaration::Display(
longhands::display::SpecifiedValue::block)), longhands::display::SpecifiedValue::block),
Importance::Normal Importance::Normal
))), ))),
})); }));