From 920b0ee6ca4dfb85ad765bce058dcd4f9d17381c Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 30 Jan 2017 16:00:31 +1100 Subject: [PATCH 1/2] Don't require mask-mode to follow mask-image --- components/style/properties/shorthand/mask.mako.rs | 6 +----- tests/unit/style/parsing/mask.rs | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthand/mask.mako.rs index f71652fac2d..0f857e2ae0b 100644 --- a/components/style/properties/shorthand/mask.mako.rs +++ b/components/style/properties/shorthand/mask.mako.rs @@ -49,10 +49,6 @@ if let Ok(value) = input.try(|input| mask_image::single_value ::parse(context, input)) { image = Some(value); - - // Parse mask mode, if applicable. - mode = input.try(|input| mask_mode::single_value::parse(context, input)).ok(); - continue } } @@ -70,7 +66,7 @@ continue } } - % for name in "repeat origin clip composite".split(): + % for name in "repeat origin clip composite mode".split(): if ${name}.is_none() { if let Ok(value) = input.try(|input| mask_${name}::single_value ::parse(context, input)) { diff --git a/tests/unit/style/parsing/mask.rs b/tests/unit/style/parsing/mask.rs index 466f2b24a93..ed655bc844d 100644 --- a/tests/unit/style/parsing/mask.rs +++ b/tests/unit/style/parsing/mask.rs @@ -107,12 +107,12 @@ fn mask_shorthand_should_parse_origin_and_clip_correctly() { } #[test] -fn mask_shorthand_should_not_parse_when_mode_specified_but_image_not() { +fn mask_shorthand_should_parse_mode_everywhere() { let url = ServoUrl::parse("http://localhost").unwrap(); let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest)); - let mut parser = Parser::new("luminance 7px 4px repeat-x padding"); - assert!(mask::parse_value(&context, &mut parser).is_err()); + let mut parser = Parser::new("luminance 7px 4px repeat-x padding-box"); + assert!(mask::parse_value(&context, &mut parser).is_ok()); let mut parser = Parser::new("alpha"); - assert!(mask::parse_value(&context, &mut parser).is_err()); + assert!(mask::parse_value(&context, &mut parser).is_ok()); } From 4a0482f0a04feff8fbdcd9d59a8606d1651db7d3 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Mon, 30 Jan 2017 16:51:03 +1100 Subject: [PATCH 2/2] Add comma between layers for mask shorthand --- components/style/properties/shorthand/mask.mako.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/style/properties/shorthand/mask.mako.rs b/components/style/properties/shorthand/mask.mako.rs index 0f857e2ae0b..0d07e108d31 100644 --- a/components/style/properties/shorthand/mask.mako.rs +++ b/components/style/properties/shorthand/mask.mako.rs @@ -142,6 +142,10 @@ } for i in 0..len { + if i > 0 { + try!(dest.write_str(", ")); + } + % for name in "image mode position_x position_y size repeat origin clip composite".split(): let ${name} = if let DeclaredValue::Value(ref arr) = *self.mask_${name} { arr.0.get(i % arr.0.len())