diff --git a/tests/unit/style/parsing/background.rs b/tests/unit/style/parsing/background.rs index 278291d70e7..f5a6ceda850 100644 --- a/tests/unit/style/parsing/background.rs +++ b/tests/unit/style/parsing/background.rs @@ -7,7 +7,8 @@ use media_queries::CSSErrorReporterTest; use servo_url::ServoUrl; use style::parser::ParserContext; use style::properties::longhands::{background_attachment, background_clip, background_color, background_image}; -use style::properties::longhands::{background_origin, background_position, background_repeat, background_size}; +use style::properties::longhands::{background_origin, background_position_x, background_position_y, background_repeat}; +use style::properties::longhands::background_size; use style::properties::shorthands::background; use style::stylesheets::Origin; @@ -20,7 +21,8 @@ fn background_shorthand_should_parse_all_available_properties_when_specified() { let result = background::parse_value(&context, &mut parser).unwrap(); assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\")")); - assert_eq!(result.background_position.unwrap(), parse_longhand!(background_position, "top center")); + assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "center")); + assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "top")); assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "200px 200px")); assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat-x")); assert_eq!(result.background_attachment.unwrap(), parse_longhand!(background_attachment, "fixed")); @@ -36,7 +38,8 @@ fn background_shorthand_should_parse_when_some_fields_set() { let mut parser = Parser::new("14px 40px repeat-y"); let result = background::parse_value(&context, &mut parser).unwrap(); - assert_eq!(result.background_position.unwrap(), parse_longhand!(background_position, "14px 40px")); + assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "14px")); + assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "40px")); assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "repeat-y")); let mut parser = Parser::new("url(\"http://servo/test.png\") repeat blue"); @@ -68,8 +71,8 @@ fn background_shorthand_should_parse_comma_separated_declarations() { assert_eq!(result.background_image.unwrap(), parse_longhand!(background_image, "url(\"http://servo/test.png\"), \ url(\"http://servo/test.png\"), none")); - assert_eq!(result.background_position.unwrap(), parse_longhand!(background_position, "left top, center center, \ - 0% 0%")); + assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "left, center, 0%")); + assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "top, center, 0%")); assert_eq!(result.background_repeat.unwrap(), parse_longhand!(background_repeat, "no-repeat, no-repeat, repeat")); assert_eq!(result.background_clip.unwrap(), parse_longhand!(background_clip, "border-box, border-box, border-box")); assert_eq!(result.background_origin.unwrap(), parse_longhand!(background_origin, "padding-box, padding-box, \ @@ -86,12 +89,14 @@ fn background_shorthand_should_parse_position_and_size_correctly() { let mut parser = Parser::new("7px 4px"); let result = background::parse_value(&context, &mut parser).unwrap(); - assert_eq!(result.background_position.unwrap(), parse_longhand!(background_position, "7px 4px")); + assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "7px")); + assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "4px")); let mut parser = Parser::new("7px 4px / 30px 20px"); let result = background::parse_value(&context, &mut parser).unwrap(); - assert_eq!(result.background_position.unwrap(), parse_longhand!(background_position, "7px 4px")); + assert_eq!(result.background_position_x.unwrap(), parse_longhand!(background_position_x, "7px")); + assert_eq!(result.background_position_y.unwrap(), parse_longhand!(background_position_y, "4px")); assert_eq!(result.background_size.unwrap(), parse_longhand!(background_size, "30px 20px")); let mut parser = Parser::new("/ 30px 20px"); diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 182f128faa0..21e490a86c1 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -688,11 +688,12 @@ mod shorthand_serialization { use style::properties::longhands::background_clip as clip; use style::properties::longhands::background_image as image; use style::properties::longhands::background_origin as origin; - use style::properties::longhands::background_position as position; + use style::properties::longhands::background_position_x as position_x; + use style::properties::longhands::background_position_y as position_y; use style::properties::longhands::background_repeat as repeat; use style::properties::longhands::background_size as size; use style::values::specified::Image; - use style::values::specified::position::{HorizontalPosition, Position, VerticalPosition}; + use style::values::specified::position::{HorizontalPosition, VerticalPosition}; use super::*; macro_rules! single_vec_value_typedef { ($name:ident, $path:expr) => { @@ -731,16 +732,17 @@ mod shorthand_serialization { authored: None }); - let position = single_vec_value_typedef!(position, - Position { - horizontal: HorizontalPosition { - keyword: None, - position: Some(LengthOrPercentage::Length(Length::from_px(7f32))), - }, - vertical: VerticalPosition { - keyword: None, - position: Some(LengthOrPercentage::Length(Length::from_px(4f32))), - }, + let position_x = single_vec_value_typedef!(position_x, + HorizontalPosition { + keyword: None, + position: Some(LengthOrPercentage::Length(Length::from_px(7f32))), + } + ); + + let position_y = single_vec_value_typedef!(position_y, + VerticalPosition { + keyword: None, + position: Some(LengthOrPercentage::Length(Length::from_px(4f32))), } ); @@ -763,7 +765,8 @@ mod shorthand_serialization { let clip = single_vec_keyword_value!(clip, padding_box); properties.push(PropertyDeclaration::BackgroundColor(color)); - properties.push(PropertyDeclaration::BackgroundPosition(position)); + properties.push(PropertyDeclaration::BackgroundPositionX(position_x)); + properties.push(PropertyDeclaration::BackgroundPositionY(position_y)); properties.push(PropertyDeclaration::BackgroundRepeat(repeat)); properties.push(PropertyDeclaration::BackgroundAttachment(attachment)); properties.push(PropertyDeclaration::BackgroundImage(image)); @@ -789,16 +792,17 @@ mod shorthand_serialization { authored: None }); - let position = single_vec_value_typedef!(position, - Position { - horizontal: HorizontalPosition { - keyword: None, - position: Some(LengthOrPercentage::Length(Length::from_px(7f32))), - }, - vertical: VerticalPosition { - keyword: None, - position: Some(LengthOrPercentage::Length(Length::from_px(4f32))), - }, + let position_x = single_vec_value_typedef!(position_x, + HorizontalPosition { + keyword: None, + position: Some(LengthOrPercentage::Length(Length::from_px(7f32))), + } + ); + + let position_y = single_vec_value_typedef!(position_y, + VerticalPosition { + keyword: None, + position: Some(LengthOrPercentage::Length(Length::from_px(4f32))), } ); @@ -821,7 +825,8 @@ mod shorthand_serialization { let clip = single_vec_keyword_value!(clip, padding_box); properties.push(PropertyDeclaration::BackgroundColor(color)); - properties.push(PropertyDeclaration::BackgroundPosition(position)); + properties.push(PropertyDeclaration::BackgroundPositionX(position_x)); + properties.push(PropertyDeclaration::BackgroundPositionY(position_y)); properties.push(PropertyDeclaration::BackgroundRepeat(repeat)); properties.push(PropertyDeclaration::BackgroundAttachment(attachment)); properties.push(PropertyDeclaration::BackgroundImage(image)); @@ -846,16 +851,17 @@ mod shorthand_serialization { authored: None }); - let position = single_vec_value_typedef!(position, - Position { - horizontal: HorizontalPosition { - keyword: None, - position: Some(LengthOrPercentage::Length(Length::from_px(0f32))), - }, - vertical: VerticalPosition { - keyword: None, - position: Some(LengthOrPercentage::Length(Length::from_px(0f32))), - }, + let position_x = single_vec_value_typedef!(position_x, + HorizontalPosition { + keyword: None, + position: Some(LengthOrPercentage::Length(Length::from_px(0f32))), + } + ); + + let position_y = single_vec_value_typedef!(position_y, + VerticalPosition { + keyword: None, + position: Some(LengthOrPercentage::Length(Length::from_px(0f32))), } ); @@ -870,7 +876,8 @@ mod shorthand_serialization { let clip = DeclaredValue::Initial; properties.push(PropertyDeclaration::BackgroundColor(color)); - properties.push(PropertyDeclaration::BackgroundPosition(position)); + properties.push(PropertyDeclaration::BackgroundPositionX(position_x)); + properties.push(PropertyDeclaration::BackgroundPositionY(position_y)); properties.push(PropertyDeclaration::BackgroundRepeat(repeat)); properties.push(PropertyDeclaration::BackgroundAttachment(attachment)); properties.push(PropertyDeclaration::BackgroundImage(image)); diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index a5a5be5a7d1..d4c8bcc28a1 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -190,10 +190,15 @@ fn test_parse_stylesheet() { } )), Importance::Normal), - (PropertyDeclaration::BackgroundPosition(DeclaredValue::Value( - longhands::background_position::SpecifiedValue( - vec![longhands::background_position::single_value - ::get_initial_specified_value()]))), + (PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value( + longhands::background_position_x::SpecifiedValue( + vec![longhands::background_position_x::single_value + ::get_initial_position_value()]))), + Importance::Normal), + (PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value( + longhands::background_position_y::SpecifiedValue( + vec![longhands::background_position_y::single_value + ::get_initial_position_value()]))), Importance::Normal), (PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value( longhands::background_repeat::SpecifiedValue( diff --git a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-331.htm.ini b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-331.htm.ini index aeae4c583a2..8d83039b0a6 100644 --- a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-331.htm.ini +++ b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-331.htm.ini @@ -6,3 +6,6 @@ [background_initial_color] expected: FAIL + [background_initial_position] + expected: FAIL + diff --git a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-333.htm.ini b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-333.htm.ini index 04fd52fd845..11c7900a2d9 100644 --- a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-333.htm.ini +++ b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-333.htm.ini @@ -6,3 +6,6 @@ [background_specified_color_color] expected: FAIL + [background_specified_color_position] + expected: FAIL +