From e165d1f885a6c8b421e44b00dc4b2937db9bd9ad Mon Sep 17 00:00:00 2001 From: Neck Varentsov Date: Fri, 17 Feb 2017 10:18:19 +0300 Subject: [PATCH 1/4] fix {transform,perspective}-origin accepts (and ignores) anything for their second part of value --- components/style/properties/longhand/effects.mako.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index e651cc57a2e..5c44a737b83 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -487,7 +487,7 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result { if horizontal.is_none() { horizontal = Some(value); From 6d311c54653c562cfef44bef6bb6ed8a6134522a Mon Sep 17 00:00:00 2001 From: Neck Varentsov Date: Sat, 25 Feb 2017 01:02:34 +0300 Subject: [PATCH 2/4] add tests --- tests/unit/style/parsing/effects.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/unit/style/parsing/effects.rs b/tests/unit/style/parsing/effects.rs index d335604773b..dce06cc688e 100644 --- a/tests/unit/style/parsing/effects.rs +++ b/tests/unit/style/parsing/effects.rs @@ -8,6 +8,7 @@ use servo_url::ServoUrl; use style::parser::ParserContext; use style::stylesheets::Origin; use style_traits::ToCss; +use style::properties::longhands; #[test] fn test_clip() { @@ -33,3 +34,23 @@ fn test_clip() { "rect(auto, auto, auto, auto)"); } +#[test] +fn test_longhands_parse_origin() { + let url = ServoUrl::parse("http://localhost").unwrap(); + let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); + + let mut parser = Parser::new("1px 2px rubbish"); + let parsed = longhands::parse_origin(&context, &mut parser); + assert_eq!(parsed.is_ok(), true); + assert_eq!(parser.is_exhausted(), false); + + let mut parser = Parser::new("1px 2px"); + let parsed = longhands::parse_origin(&context, &mut parser); + assert_eq!(parsed.is_ok(), true); + assert_eq!(parser.is_exhausted(), true); + + let mut parser = Parser::new("1px"); + let parsed = longhands::parse_origin(&context, &mut parser); + assert_eq!(parsed.is_ok(), true); + assert_eq!(parser.is_exhausted(), true); +} From fd6718ec158bc300a0612e91eba988899cb7ee32 Mon Sep 17 00:00:00 2001 From: Neck Varentsov Date: Sun, 26 Feb 2017 18:32:21 +0300 Subject: [PATCH 3/4] add test test_effects_parser_exhaustion --- tests/unit/style/parsing/effects.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/unit/style/parsing/effects.rs b/tests/unit/style/parsing/effects.rs index dce06cc688e..a9ac4b7b3e8 100644 --- a/tests/unit/style/parsing/effects.rs +++ b/tests/unit/style/parsing/effects.rs @@ -9,6 +9,7 @@ use style::parser::ParserContext; use style::stylesheets::Origin; use style_traits::ToCss; use style::properties::longhands; +use style::properties::longhands::{perspective_origin, transform_origin}; #[test] fn test_clip() { @@ -39,18 +40,27 @@ fn test_longhands_parse_origin() { let url = ServoUrl::parse("http://localhost").unwrap(); let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); - let mut parser = Parser::new("1px 2px rubbish"); + let mut parser = Parser::new("1px some-rubbish"); let parsed = longhands::parse_origin(&context, &mut parser); - assert_eq!(parsed.is_ok(), true); + assert!(parsed.is_ok()); assert_eq!(parser.is_exhausted(), false); let mut parser = Parser::new("1px 2px"); let parsed = longhands::parse_origin(&context, &mut parser); - assert_eq!(parsed.is_ok(), true); + assert!(parsed.is_ok()); assert_eq!(parser.is_exhausted(), true); let mut parser = Parser::new("1px"); let parsed = longhands::parse_origin(&context, &mut parser); - assert_eq!(parsed.is_ok(), true); + assert!(parsed.is_ok()); assert_eq!(parser.is_exhausted(), true); } + +#[test] +fn test_effects_parser_exhaustion() { + assert_parser_exhausted!(perspective_origin, "1px 1px", true); + assert_parser_exhausted!(transform_origin, "1px 1px", true); + + assert_parser_exhausted!(perspective_origin, "1px some-rubbish", false); + assert_parser_exhausted!(transform_origin, "1px some-rubbish", false); +} From 89f96c0848011f191a4671376a035220ec4349b7 Mon Sep 17 00:00:00 2001 From: Neck Varentsov Date: Sun, 26 Feb 2017 22:52:51 +0300 Subject: [PATCH 4/4] rebase and fix tidiness lint --- tests/unit/style/parsing/effects.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/unit/style/parsing/effects.rs b/tests/unit/style/parsing/effects.rs index a9ac4b7b3e8..baa1e2ada16 100644 --- a/tests/unit/style/parsing/effects.rs +++ b/tests/unit/style/parsing/effects.rs @@ -6,10 +6,9 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use servo_url::ServoUrl; use style::parser::ParserContext; +use style::properties::longhands::{self, perspective_origin, transform_origin}; use style::stylesheets::Origin; use style_traits::ToCss; -use style::properties::longhands; -use style::properties::longhands::{perspective_origin, transform_origin}; #[test] fn test_clip() {