aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-02-26 17:40:23 -0800
committerGitHub <noreply@github.com>2017-02-26 17:40:23 -0800
commitb2539090fa35503e40348a9d519b0f13360e42c1 (patch)
tree6aa800cab648ba9ac1d9f00658b1e7c0ea4d03d1
parent3086b3d291253a11e83943a34464e21fb1283fba (diff)
parent89f96c0848011f191a4671376a035220ec4349b7 (diff)
downloadservo-b2539090fa35503e40348a9d519b0f13360e42c1.tar.gz
servo-b2539090fa35503e40348a9d519b0f13360e42c1.zip
Auto merge of #15613 - Varentsov:master, r=upsuper
fix {transform,perspective}-origin accepts (and ignores) anything for… … their second part of value <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #15487. <!-- Either: --> - [X] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15613) <!-- Reviewable:end -->
-rw-r--r--components/style/properties/longhand/effects.mako.rs2
-rw-r--r--tests/unit/style/parsing/effects.rs30
2 files changed, 31 insertions, 1 deletions
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<Origi
}
Ok(())
}) {
- match LengthOrPercentage::parse(context, input) {
+ match input.try(|input| LengthOrPercentage::parse(context, input)) {
Ok(value) => {
if horizontal.is_none() {
horizontal = Some(value);
diff --git a/tests/unit/style/parsing/effects.rs b/tests/unit/style/parsing/effects.rs
index d335604773b..baa1e2ada16 100644
--- a/tests/unit/style/parsing/effects.rs
+++ b/tests/unit/style/parsing/effects.rs
@@ -6,6 +6,7 @@ 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;
@@ -33,3 +34,32 @@ 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 some-rubbish");
+ let parsed = longhands::parse_origin(&context, &mut parser);
+ 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!(parsed.is_ok());
+ assert_eq!(parser.is_exhausted(), true);
+
+ let mut parser = Parser::new("1px");
+ let parsed = longhands::parse_origin(&context, &mut parser);
+ 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);
+}