Make transform perspective reject negative lengths.

Contains one test.
Fixes:
https://github.com/servo/servo/pull/16242#issuecomment-291639340
This commit is contained in:
Pyfisch 2017-04-07 11:41:25 +02:00
parent 535d0e421a
commit b62cdb92ec
2 changed files with 4 additions and 1 deletions

View file

@ -1213,6 +1213,8 @@ ${helpers.predefined_type("scroll-snap-coordinate",
///
/// Part of CSS Transform Module Level 2 and defined at
/// [§ 13.1. 3D Transform Function](https://drafts.csswg.org/css-transforms-2/#funcdef-perspective).
///
/// The value must be greater than or equal to zero.
Perspective(specified::Length),
}
@ -1535,7 +1537,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
},
"perspective" => {
try!(input.parse_nested_block(|input| {
let d = try!(specified::Length::parse(context, input));
let d = try!(specified::Length::parse_non_negative(input));
result.push(SpecifiedOperation::Perspective(d));
Ok(())
}))

View file

@ -33,4 +33,5 @@ fn test_transform_translate() {
assert_roundtrip_with_context!(transform::parse, "translate(2px)");
assert_roundtrip_with_context!(transform::parse, "translate(2px, 5px)");
assert!(parse(transform::parse, "translate(2px foo)").is_err());
assert!(parse(transform::parse, "perspective(-10px)").is_err());
}