From 20c07332a1f36c2560de5fd3c9a9e97b3ba51486 Mon Sep 17 00:00:00 2001 From: n0max Date: Sun, 26 Mar 2017 23:15:04 +0200 Subject: [PATCH] Parse perspective property as non negative and add tests --- .../style/properties/longhand/box.mako.rs | 1 + components/style/values/specified/length.rs | 11 ++++++++ tests/wpt/mozilla/meta/MANIFEST.json | 10 +++++++ tests/wpt/mozilla/tests/css/perspective.html | 28 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 tests/wpt/mozilla/tests/css/perspective.html diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 17e95115a5c..7b881ab3817 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -1711,6 +1711,7 @@ ${helpers.single_keyword("resize", ${helpers.predefined_type("perspective", "LengthOrNone", "Either::Second(None_)", + "parse_non_negative_length", gecko_ffi_name="mChildPerspective", spec="https://drafts.csswg.org/css-transforms/#perspective", extra_prefixes="moz webkit", diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index bffae92c4ff..7cbb0a279c1 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -458,6 +458,17 @@ impl Parse for Length { } } +impl Either { + /// Parse a non-negative length or none + #[inline] + pub fn parse_non_negative_length(context: &ParserContext, input: &mut Parser) -> Result { + if input.try(|input| None_::parse(context, input)).is_ok() { + return Ok(Either::Second(None_)); + } + Length::parse_non_negative(input).map(Either::First) + } +} + impl Either { #[inline] #[allow(missing_docs)] diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 5d7438c4e04..37849385c0d 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -11100,6 +11100,12 @@ {} ] ], + "css/perspective.html": [ + [ + "/_mozilla/css/perspective.html", + {} + ] + ], "css/stylesheet_media_queries.html": [ [ "/_mozilla/css/stylesheet_media_queries.html", @@ -22741,6 +22747,10 @@ "001acfd664f89e45ab321bf549803ca24d44e098", "support" ], + "css/perspective.html": [ + "6d455ef4b9c815d89917f496999268d7410cfa62", + "testharness" + ], "css/perspective_zero.html": [ "bcb877f51808e896d8024877f945ce289dbc6b36", "reftest" diff --git a/tests/wpt/mozilla/tests/css/perspective.html b/tests/wpt/mozilla/tests/css/perspective.html new file mode 100644 index 00000000000..a575b866a89 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/perspective.html @@ -0,0 +1,28 @@ + + + +CSS Test: parsing perspective property + + + +
+ +