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 -->
This commit is contained in:
bors-servo 2017-02-26 17:40:23 -08:00 committed by GitHub
commit b2539090fa
2 changed files with 31 additions and 1 deletions

View file

@ -487,7 +487,7 @@ pub fn parse_origin(context: &ParserContext, input: &mut Parser) -> Result<Origi
} }
Ok(()) Ok(())
}) { }) {
match LengthOrPercentage::parse(context, input) { match input.try(|input| LengthOrPercentage::parse(context, input)) {
Ok(value) => { Ok(value) => {
if horizontal.is_none() { if horizontal.is_none() {
horizontal = Some(value); horizontal = Some(value);

View file

@ -6,6 +6,7 @@ use cssparser::Parser;
use media_queries::CSSErrorReporterTest; use media_queries::CSSErrorReporterTest;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use style::parser::ParserContext; use style::parser::ParserContext;
use style::properties::longhands::{self, perspective_origin, transform_origin};
use style::stylesheets::Origin; use style::stylesheets::Origin;
use style_traits::ToCss; use style_traits::ToCss;
@ -33,3 +34,32 @@ fn test_clip() {
"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);
}