From 766feec4c09c9d8ead9eedcb409d303dea7363ce Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 24 May 2017 20:27:18 +1000 Subject: [PATCH 1/2] Reject "text" value in background shorthand. --- components/style/properties/shorthand/background.mako.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index b4f3f9fe079..58f0361cffa 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -69,6 +69,13 @@ if ${name}.is_none() { if let Ok(value) = input.try(|input| background_${name}::single_value ::parse(context, input)) { + % if name == "clip" and product == "gecko": + // "text" value of background-clip should not be part of background + // shorthand per current spec and impls. + if value == background_clip::single_value::SpecifiedValue::text { + return Err(()); + } + % endif ${name} = Some(value); continue } From 7d48c9fa90d3dfa2cc2f0ff47c8677912e9cd313 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 24 May 2017 21:53:52 +1000 Subject: [PATCH 2/2] Only allow color value at the last element. --- .../style/properties/shorthand/background.mako.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index 58f0361cffa..5a7747cf3fb 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -39,17 +39,20 @@ let mut background_${name} = background_${name}::SpecifiedValue(Vec::new()); % endfor try!(input.parse_comma_separated(|input| { + // background-color can only be in the last element, so if it + // is parsed anywhere before, the value is invalid. + if background_color.is_some() { + return Err(()); + } + % for name in "image position repeat size attachment origin clip".split(): let mut ${name} = None; % endfor loop { - if let Ok(value) = input.try(|i| CSSColor::parse(context, i)) { - if background_color.is_none() { + if background_color.is_none() { + if let Ok(value) = input.try(|i| CSSColor::parse(context, i)) { background_color = Some(value); continue - } else { - // color can only be the last element - return Err(()) } } if position.is_none() {