diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 9ff28b6e6d7..a4d78e7f3fc 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -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(()) })) diff --git a/tests/unit/style/parsing/box_.rs b/tests/unit/style/parsing/box_.rs index dd8c229ebb8..e6b73a3b246 100644 --- a/tests/unit/style/parsing/box_.rs +++ b/tests/unit/style/parsing/box_.rs @@ -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()); }