diff --git a/components/style/properties/longhand/effects.mako.rs b/components/style/properties/longhand/effects.mako.rs index b7bcffadbd3..b56f105c492 100644 --- a/components/style/properties/longhand/effects.mako.rs +++ b/components/style/properties/longhand/effects.mako.rs @@ -83,6 +83,7 @@ ${helpers.predefined_type("clip", "computed::ClipRectOrAuto::auto()", animation_value_type="ComputedValue", boxed="True", + allow_quirks=True, spec="https://drafts.fxtf.org/css-masking/#clip-property")} // FIXME: This prop should be animatable diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 31990fba71a..7dea44b085f 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -1219,13 +1219,22 @@ impl ToComputedValue for ClipRect { impl Parse for ClipRect { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - use values::specified::{AllowQuirks, Length}; + Self::parse_quirky(context, input, AllowQuirks::No) + } +} - fn parse_argument(context: &ParserContext, input: &mut Parser) -> Result, ()> { +impl ClipRect { + /// Parses a rect(, , , ), allowing quirks. + pub fn parse_quirky(context: &ParserContext, input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { + use values::specified::Length; + + fn parse_argument(context: &ParserContext, input: &mut Parser, + allow_quirks: AllowQuirks) -> Result, ()> { if input.try(|input| input.expect_ident_matching("auto")).is_ok() { Ok(None) } else { - Length::parse_quirky(context, input, AllowQuirks::Yes).map(Some) + Length::parse_quirky(context, input, allow_quirks).map(Some) } } @@ -1234,21 +1243,21 @@ impl Parse for ClipRect { } input.parse_nested_block(|input| { - let top = try!(parse_argument(context, input)); + let top = try!(parse_argument(context, input, allow_quirks)); let right; let bottom; let left; if input.try(|input| input.expect_comma()).is_ok() { - right = try!(parse_argument(context, input)); + right = try!(parse_argument(context, input, allow_quirks)); try!(input.expect_comma()); - bottom = try!(parse_argument(context, input)); + bottom = try!(parse_argument(context, input, allow_quirks)); try!(input.expect_comma()); - left = try!(parse_argument(context, input)); + left = try!(parse_argument(context, input, allow_quirks)); } else { - right = try!(parse_argument(context, input)); - bottom = try!(parse_argument(context, input)); - left = try!(parse_argument(context, input)); + right = try!(parse_argument(context, input, allow_quirks)); + bottom = try!(parse_argument(context, input, allow_quirks)); + left = try!(parse_argument(context, input, allow_quirks)); } Ok(ClipRect { top: top, @@ -1263,6 +1272,18 @@ impl Parse for ClipRect { /// rect(...) | auto pub type ClipRectOrAuto = Either; +impl ClipRectOrAuto { + /// Parses a ClipRect or Auto, allowing quirks. + pub fn parse_quirky(context: &ParserContext, input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { + if let Ok(v) = input.try(|i| ClipRect::parse_quirky(context, i, allow_quirks)) { + Ok(Either::First(v)) + } else { + Auto::parse(context, input).map(Either::Second) + } + } +} + /// | auto pub type ColorOrAuto = Either;