diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index f507af9ec56..2537a71c29f 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -11,6 +11,20 @@ use properties::longhands::{background_color, background_position, background_repeat, background_attachment}; use properties::longhands::{background_image, background_size, background_origin, background_clip}; + impl From for background_clip::single_value::SpecifiedValue { + fn from(origin: background_origin::single_value::SpecifiedValue) -> + background_clip::single_value::SpecifiedValue { + match origin { + background_origin::single_value::SpecifiedValue::content_box => + background_clip::single_value::SpecifiedValue::content_box, + background_origin::single_value::SpecifiedValue::padding_box => + background_clip::single_value::SpecifiedValue::padding_box, + background_origin::single_value::SpecifiedValue::border_box => + background_clip::single_value::SpecifiedValue::border_box, + } + } + } + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { let mut background_color = None; @@ -56,6 +70,11 @@ % endfor break } + if clip.is_none() { + if let Some(origin) = origin { + clip = Some(background_clip::single_value::SpecifiedValue::from(origin)); + } + } let mut any = false; % for name in "image position repeat size attachment origin clip".split(): any = any || ${name}.is_some(); @@ -199,14 +218,6 @@ } } }, - (Some(origin), _) => { - try!(write!(dest, " ")); - try!(origin.to_css(dest)); - }, - (_, Some(clip)) => { - try!(write!(dest, " ")); - try!(clip.to_css(dest)); - }, _ => {} }; } diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthand/mask.mako.rs index 448dc7ac831..67e1386f6d6 100644 --- a/components/style/properties/shorthand/mask.mako.rs +++ b/components/style/properties/shorthand/mask.mako.rs @@ -10,6 +10,19 @@ use properties::longhands::{mask_mode, mask_repeat, mask_clip, mask_origin, mask_composite, mask_position}; use properties::longhands::{mask_size, mask_image}; + impl From for mask_clip::single_value::SpecifiedValue { + fn from(origin: mask_origin::single_value::SpecifiedValue) -> mask_clip::single_value::SpecifiedValue { + match origin { + mask_origin::single_value::SpecifiedValue::content_box => + mask_clip::single_value::SpecifiedValue::content_box, + mask_origin::single_value::SpecifiedValue::padding_box => + mask_clip::single_value::SpecifiedValue::padding_box, + mask_origin::single_value::SpecifiedValue::border_box => + mask_clip::single_value::SpecifiedValue::border_box, + } + } + } + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { % for name in "image mode position size repeat origin clip composite".split(): let mut mask_${name} = mask_${name}::SpecifiedValue(Vec::new()); @@ -56,6 +69,11 @@ % endfor break } + if clip.is_none() { + if let Some(origin) = origin { + clip = Some(mask_clip::single_value::SpecifiedValue::from(origin)); + } + } let mut any = false; % for name in "image mode position size repeat origin clip composite".split(): any = any || ${name}.is_some(); @@ -169,14 +187,6 @@ } } }, - (Some(origin), _) => { - try!(write!(dest, " ")); - try!(origin.to_css(dest)); - }, - (_, Some(clip)) => { - try!(write!(dest, " ")); - try!(clip.to_css(dest)); - }, _ => {} }; diff --git a/tests/unit/style/parsing/mask.rs b/tests/unit/style/parsing/mask.rs index a6ee3230248..827de66277e 100644 --- a/tests/unit/style/parsing/mask.rs +++ b/tests/unit/style/parsing/mask.rs @@ -106,8 +106,8 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() { let mut parser = Parser::new("padding-box"); let result = mask::parse_value(&context, &mut parser).unwrap(); - // TODO(#13466): We should fix origin/clip parsing behavior. assert_eq!(result.mask_origin.unwrap(), parse_longhand!(mask_origin, "padding-box")); + assert_eq!(result.mask_clip.unwrap(), parse_longhand!(mask_clip, "padding-box")); } #[test] diff --git a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-335.htm.ini b/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-335.htm.ini deleted file mode 100644 index d418de147a0..00000000000 --- a/tests/wpt/metadata-css/css-backgrounds-3_dev/html4/background-335.htm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[background-335.htm] - type: testharness - [background_specified_box_one_clip] - expected: FAIL -