Rename DeclaredValue::SpecifiedValue to DeclaredValue::Value

This commit is contained in:
Simon Sapin 2015-07-23 01:14:03 +02:00
parent 3fcd8938f3
commit 5fb6acb753
3 changed files with 30 additions and 30 deletions

View file

@ -62,7 +62,7 @@ use dom::virtualmethods::{VirtualMethods, vtable_for};
use devtools_traits::AttrInfo; use devtools_traits::AttrInfo;
use smallvec::VecLike; use smallvec::VecLike;
use style::legacy::{UnsignedIntegerAttribute, from_declaration}; use style::legacy::{UnsignedIntegerAttribute, from_declaration};
use style::properties::DeclaredValue::SpecifiedValue; use style::properties::DeclaredValue;
use style::properties::longhands::{self, background_image, border_spacing}; use style::properties::longhands::{self, background_image, border_spacing};
use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute}; use style::properties::{PropertyDeclarationBlock, PropertyDeclaration, parse_style_attribute};
use style::values::CSSFloat; use style::values::CSSFloat;
@ -271,7 +271,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(color) = bgcolor { if let Some(color) = bgcolor {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BackgroundColor(SpecifiedValue( PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
CSSColor { parsed: Color::RGBA(color), authored: None })))); CSSColor { parsed: Color::RGBA(color), authored: None }))));
} }
@ -284,7 +284,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(url) = background { if let Some(url) = background {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BackgroundImage(SpecifiedValue( PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
background_image::SpecifiedValue(Some(specified::Image::Url(url))))))); background_image::SpecifiedValue(Some(specified::Image::Url(url)))))));
} }
@ -297,7 +297,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(color) = color { if let Some(color) = color {
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Color(SpecifiedValue(CSSRGBA { PropertyDeclaration::Color(DeclaredValue::Value(CSSRGBA {
parsed: color, parsed: color,
authored: None, authored: None,
})))); }))));
@ -313,7 +313,7 @@ impl RawLayoutElementHelpers for Element {
if let Some(cellspacing) = cellspacing { if let Some(cellspacing) = cellspacing {
let width_value = specified::Length::Absolute(Au::from_px(cellspacing as i32)); let width_value = specified::Length::Absolute(Au::from_px(cellspacing as i32));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderSpacing(SpecifiedValue( PropertyDeclaration::BorderSpacing(DeclaredValue::Value(
border_spacing::SpecifiedValue { border_spacing::SpecifiedValue {
horizontal: width_value, horizontal: width_value,
vertical: width_value, vertical: width_value,
@ -343,7 +343,7 @@ impl RawLayoutElementHelpers for Element {
let value = specified::Length::ServoCharacterWidth( let value = specified::Length::ServoCharacterWidth(
specified::CharacterWidth(size)); specified::CharacterWidth(size));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue( PropertyDeclaration::Width(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value))))); specified::LengthOrPercentageOrAuto::Length(value)))));
} }
@ -367,13 +367,13 @@ impl RawLayoutElementHelpers for 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(SpecifiedValue(width_value)))); PropertyDeclaration::Width(DeclaredValue::Value(width_value))));
} }
LengthOrPercentageOrAuto::Length(length) => { LengthOrPercentageOrAuto::Length(length) => {
let width_value = specified::LengthOrPercentageOrAuto::Length( let width_value = specified::LengthOrPercentageOrAuto::Length(
specified::Length::Absolute(length)); specified::Length::Absolute(length));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue(width_value)))); PropertyDeclaration::Width(DeclaredValue::Value(width_value))));
} }
} }
@ -391,13 +391,13 @@ impl RawLayoutElementHelpers for Element {
let height_value = 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(SpecifiedValue(height_value)))); PropertyDeclaration::Height(DeclaredValue::Value(height_value))));
} }
LengthOrPercentageOrAuto::Length(length) => { LengthOrPercentageOrAuto::Length(length) => {
let height_value = specified::LengthOrPercentageOrAuto::Length( let height_value = specified::LengthOrPercentageOrAuto::Length(
specified::Length::Absolute(length)); specified::Length::Absolute(length));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Height(SpecifiedValue(height_value)))); PropertyDeclaration::Height(DeclaredValue::Value(height_value))));
} }
} }
@ -420,7 +420,7 @@ impl RawLayoutElementHelpers for Element {
// https://html.spec.whatwg.org/multipage/#textarea-effective-width // https://html.spec.whatwg.org/multipage/#textarea-effective-width
let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(cols)); let value = specified::Length::ServoCharacterWidth(specified::CharacterWidth(cols));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Width(SpecifiedValue( PropertyDeclaration::Width(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value))))); specified::LengthOrPercentageOrAuto::Length(value)))));
} }
@ -441,7 +441,7 @@ impl RawLayoutElementHelpers for Element {
// https://html.spec.whatwg.org/multipage/#textarea-effective-height // https://html.spec.whatwg.org/multipage/#textarea-effective-height
let value = specified::Length::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat)); let value = specified::Length::FontRelative(specified::FontRelativeLength::Em(rows as CSSFloat));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::Height(SpecifiedValue( PropertyDeclaration::Height(DeclaredValue::Value(
specified::LengthOrPercentageOrAuto::Length(value))))); specified::LengthOrPercentageOrAuto::Length(value)))));
} }
@ -456,16 +456,16 @@ impl RawLayoutElementHelpers for Element {
if let Some(border) = border { if let Some(border) = border {
let width_value = specified::Length::Absolute(Au::from_px(border as i32)); let width_value = specified::Length::Absolute(Au::from_px(border as i32));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderTopWidth(SpecifiedValue( PropertyDeclaration::BorderTopWidth(DeclaredValue::Value(
longhands::border_top_width::SpecifiedValue(width_value))))); longhands::border_top_width::SpecifiedValue(width_value)))));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderLeftWidth(SpecifiedValue( PropertyDeclaration::BorderLeftWidth(DeclaredValue::Value(
longhands::border_left_width::SpecifiedValue(width_value))))); longhands::border_left_width::SpecifiedValue(width_value)))));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderBottomWidth(SpecifiedValue( PropertyDeclaration::BorderBottomWidth(DeclaredValue::Value(
longhands::border_bottom_width::SpecifiedValue(width_value))))); longhands::border_bottom_width::SpecifiedValue(width_value)))));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderRightWidth(SpecifiedValue( PropertyDeclaration::BorderRightWidth(DeclaredValue::Value(
longhands::border_right_width::SpecifiedValue(width_value))))); longhands::border_right_width::SpecifiedValue(width_value)))));
} }
} }

View file

@ -156,7 +156,7 @@ pub mod longhands {
} }
seen.set_${property.ident}(); seen.set_${property.ident}();
let computed_value = match *declared_value { let computed_value = match *declared_value {
DeclaredValue::SpecifiedValue(ref specified_value) => { DeclaredValue::Value(ref specified_value) => {
specified_value.to_computed_value(&context) specified_value.to_computed_value(&context)
} }
DeclaredValue::Initial => get_initial_value(), DeclaredValue::Initial => get_initial_value(),
@ -209,7 +209,7 @@ pub mod longhands {
% if derived_from is None: % if derived_from is None:
pub fn parse_specified(context: &ParserContext, input: &mut Parser) pub fn parse_specified(context: &ParserContext, input: &mut Parser)
-> Result<DeclaredValue<SpecifiedValue>, ()> { -> Result<DeclaredValue<SpecifiedValue>, ()> {
parse(context, input).map(DeclaredValue::SpecifiedValue) parse(context, input).map(DeclaredValue::Value)
} }
% endif % endif
</%self:raw_longhand> </%self:raw_longhand>
@ -1653,7 +1653,7 @@ pub mod longhands {
Color::RGBA(rgba) => rgba, Color::RGBA(rgba) => rgba,
Color::CurrentColor => return Ok(DeclaredValue::Inherit) Color::CurrentColor => return Ok(DeclaredValue::Inherit)
}; };
Ok(DeclaredValue::SpecifiedValue(CSSRGBA { Ok(DeclaredValue::Value(CSSRGBA {
parsed: rgba, parsed: rgba,
authored: value.authored, authored: value.authored,
})) }))
@ -5661,7 +5661,7 @@ impl CSSWideKeyword {
#[derive(Clone, PartialEq, Eq, Copy, Debug)] #[derive(Clone, PartialEq, Eq, Copy, Debug)]
pub enum DeclaredValue<T> { pub enum DeclaredValue<T> {
SpecifiedValue(T), Value(T),
Initial, Initial,
Inherit, Inherit,
// There is no Unset variant here. // There is no Unset variant here.
@ -5672,7 +5672,7 @@ pub enum DeclaredValue<T> {
impl<T: ToCss> DeclaredValue<T> { impl<T: ToCss> DeclaredValue<T> {
pub fn specified_value(&self) -> String { pub fn specified_value(&self) -> String {
match self { match self {
&DeclaredValue::SpecifiedValue(ref inner) => inner.to_css_string(), &DeclaredValue::Value(ref inner) => inner.to_css_string(),
&DeclaredValue::Initial => "initial".to_owned(), &DeclaredValue::Initial => "initial".to_owned(),
&DeclaredValue::Inherit => "inherit".to_owned(), &DeclaredValue::Inherit => "inherit".to_owned(),
} }
@ -5742,7 +5742,7 @@ impl PropertyDeclaration {
Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit, Ok(CSSWideKeyword::InheritKeyword) => DeclaredValue::Inherit,
Ok(CSSWideKeyword::InitialKeyword) => DeclaredValue::Initial, Ok(CSSWideKeyword::InitialKeyword) => DeclaredValue::Initial,
Err(()) => match ::custom_properties::parse(input) { Err(()) => match ::custom_properties::parse(input) {
Ok(value) => DeclaredValue::SpecifiedValue(value), Ok(value) => DeclaredValue::Value(value),
Err(()) => return PropertyDeclarationParseResult::InvalidValue, Err(()) => return PropertyDeclarationParseResult::InvalidValue,
} }
}; };
@ -5808,7 +5808,7 @@ impl PropertyDeclaration {
% for sub_property in shorthand.sub_properties: % for sub_property in shorthand.sub_properties:
result_list.push(PropertyDeclaration::${sub_property.camel_case}( result_list.push(PropertyDeclaration::${sub_property.camel_case}(
match result.${sub_property.ident} { match result.${sub_property.ident} {
Some(value) => DeclaredValue::SpecifiedValue(value), Some(value) => DeclaredValue::Value(value),
None => DeclaredValue::Initial, None => DeclaredValue::Initial,
} }
)); ));
@ -6122,7 +6122,7 @@ fn cascade_with_cached_declarations(
} }
seen.set_${property.ident}(); seen.set_${property.ident}();
let computed_value = match *declared_value { let computed_value = match *declared_value {
DeclaredValue::SpecifiedValue(ref specified_value) DeclaredValue::Value(ref specified_value)
=> specified_value.to_computed_value(context), => specified_value.to_computed_value(context),
DeclaredValue::Initial DeclaredValue::Initial
=> longhands::${property.ident}::get_initial_value(), => longhands::${property.ident}::get_initial_value(),
@ -6277,7 +6277,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
macro_rules! get_specified( macro_rules! get_specified(
($style_struct_getter: ident, $property: ident, $declared_value: expr) => { ($style_struct_getter: ident, $property: ident, $declared_value: expr) => {
match *$declared_value { match *$declared_value {
DeclaredValue::SpecifiedValue(specified_value) => specified_value, DeclaredValue::Value(specified_value) => specified_value,
DeclaredValue::Initial => longhands::$property::get_initial_value(), DeclaredValue::Initial => longhands::$property::get_initial_value(),
DeclaredValue::Inherit => inherited_style.$style_struct_getter().$property.clone(), DeclaredValue::Inherit => inherited_style.$style_struct_getter().$property.clone(),
} }
@ -6292,7 +6292,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
match *declaration { match *declaration {
PropertyDeclaration::FontSize(ref value) => { PropertyDeclaration::FontSize(ref value) => {
context.font_size = match *value { context.font_size = match *value {
DeclaredValue::SpecifiedValue(ref specified_value) => { DeclaredValue::Value(ref specified_value) => {
match specified_value.0 { match specified_value.0 {
Length::FontRelative(value) => { Length::FontRelative(value) => {
value.to_computed_value(context.inherited_font_size, value.to_computed_value(context.inherited_font_size,
@ -6310,7 +6310,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
} }
PropertyDeclaration::Color(ref value) => { PropertyDeclaration::Color(ref value) => {
context.color = match *value { context.color = match *value {
DeclaredValue::SpecifiedValue(ref specified_value) => { DeclaredValue::Value(ref specified_value) => {
specified_value.parsed specified_value.parsed
} }
DeclaredValue::Initial => longhands::color::get_initial_value(), DeclaredValue::Initial => longhands::color::get_initial_value(),

View file

@ -52,7 +52,7 @@ fn test_parse_stylesheet() {
declarations: PropertyDeclarationBlock { declarations: PropertyDeclarationBlock {
normal: Arc::new(vec![]), normal: Arc::new(vec![]),
important: Arc::new(vec![ important: Arc::new(vec![
PropertyDeclaration::Display(DeclaredValue::SpecifiedValue( PropertyDeclaration::Display(DeclaredValue::Value(
longhands::display::SpecifiedValue::none)), longhands::display::SpecifiedValue::none)),
]), ]),
}, },
@ -90,7 +90,7 @@ fn test_parse_stylesheet() {
], ],
declarations: PropertyDeclarationBlock { declarations: PropertyDeclarationBlock {
normal: Arc::new(vec![ normal: Arc::new(vec![
PropertyDeclaration::Display(DeclaredValue::SpecifiedValue( PropertyDeclaration::Display(DeclaredValue::Value(
longhands::display::SpecifiedValue::block)), longhands::display::SpecifiedValue::block)),
]), ]),
important: Arc::new(vec![]), important: Arc::new(vec![]),
@ -123,7 +123,7 @@ fn test_parse_stylesheet() {
PropertyDeclaration::BackgroundAttachment(DeclaredValue::Initial), PropertyDeclaration::BackgroundAttachment(DeclaredValue::Initial),
PropertyDeclaration::BackgroundRepeat(DeclaredValue::Initial), PropertyDeclaration::BackgroundRepeat(DeclaredValue::Initial),
PropertyDeclaration::BackgroundPosition(DeclaredValue::Initial), PropertyDeclaration::BackgroundPosition(DeclaredValue::Initial),
PropertyDeclaration::BackgroundColor(DeclaredValue::SpecifiedValue( PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
longhands::background_color::SpecifiedValue { longhands::background_color::SpecifiedValue {
authored: Some("blue".to_owned()), authored: Some("blue".to_owned()),
parsed: cssparser::Color::RGBA(cssparser::RGBA { parsed: cssparser::Color::RGBA(cssparser::RGBA {