servo: Merge #15613 - fix {transform,perspective}-origin accepts (and ignores) anything for… (from Varentsov:master); r=upsuper
authorNeck Varentsov <neck.varentsov@gmail.com>
Sun, 26 Feb 2017 17:40:23 -0800
changeset 374016 a95cda83b56d9d85158fbbfbe92bce8b592786d7
parent 374015 586854d5c3d4bab19a41c1695a06da4408005094
child 374017 e3df33f21fab407a457876519d4a6e06d51346a5
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersupsuper
milestone54.0a1
servo: Merge #15613 - fix {transform,perspective}-origin accepts (and ignores) anything for… (from Varentsov:master); r=upsuper … 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. --> Source-Repo: https://github.com/servo/servo Source-Revision: b2539090fa35503e40348a9d519b0f13360e42c1
servo/components/style/properties/longhand/effects.mako.rs
servo/tests/unit/style/parsing/effects.rs
--- a/servo/components/style/properties/longhand/effects.mako.rs
+++ b/servo/components/style/properties/longhand/effects.mako.rs
@@ -482,17 +482,17 @@ pub fn parse_origin(context: &ParserCont
                     } else {
                         return Err(())
                     }
                 },
                 _ => return Err(())
             }
             Ok(())
         }) {
-            match LengthOrPercentage::parse(context, input) {
+            match input.try(|input| LengthOrPercentage::parse(context, input)) {
                 Ok(value) => {
                     if horizontal.is_none() {
                         horizontal = Some(value);
                     } else if vertical.is_none() {
                         vertical = Some(value);
                     } else if let LengthOrPercentage::Length(length) = value {
                         depth = Some(length);
                     } else {
--- a/servo/tests/unit/style/parsing/effects.rs
+++ b/servo/tests/unit/style/parsing/effects.rs
@@ -1,16 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 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;
 
 #[test]
 fn test_clip() {
     use style::properties::longhands::clip;
 
     assert_roundtrip_with_context!(clip::parse, "auto");
@@ -28,8 +29,37 @@ fn test_clip() {
     assert_roundtrip_with_context!(clip::parse,
                                    "rect(1px auto auto 4px)",
                                    "rect(1px, auto, auto, 4px)");
     assert_roundtrip_with_context!(clip::parse,
                                    "rect(auto auto auto auto)",
                                    "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);
+}