From b6cbd31b7303189eb29e7ef65692a2871046017e Mon Sep 17 00:00:00 2001 From: tamamu Date: Mon, 10 Apr 2017 03:16:04 +0900 Subject: [PATCH] Add place-self shorthand property (it fails unit-test) --- .../properties/shorthand/position.mako.rs | 24 +++++++++++++++++++ tests/unit/style/properties/serialization.rs | 17 +++++++++++++ 2 files changed, 41 insertions(+) diff --git a/components/style/properties/shorthand/position.mako.rs b/components/style/properties/shorthand/position.mako.rs index 0f4a97528bd9..9acbd9047dbf 100644 --- a/components/style/properties/shorthand/position.mako.rs +++ b/components/style/properties/shorthand/position.mako.rs @@ -186,3 +186,27 @@ } +<%helpers:shorthand name="place-self" sub_properties="align-self justify-self" + spec="https://drafts.csswg.org/css-align/#place-self-property" + products="gecko"> + use values::specified::align::AlignJustifySelf; + use parser::Parse; + + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { + let align = AlignJustifySelf::parse(context, input)?; + let justify = input.try(|input| AlignJustifySelf::parse(context, input)).unwrap_or(align.clone()); + + Ok(Longhands { + align_self: align, + justify_self: justify, + }) + } + + impl<'a> ToCss for LonghandsToSerialize<'a> { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + self.align_self.to_css(dest)?; + dest.write_str(" ")?; + self.justify_self.to_css(dest) + } + } + diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index 112fb97e0c6e..ee867505420e 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -1263,4 +1263,21 @@ mod shorthand_serialization { let serialization = shorthand_properties_to_string(properties); assert_eq!(serialization, "place-content: stretch center;"); } + + #[test] + fn place_self_serialize_all_available_properties() { + use style::properties::longhands::align_self::SpecifiedValue as AlignSelf; + use style::properties::longhands::justify_self::SpecifiedValue as JustifySelf; + + let mut properties = Vec::new(); + + let align = AlignSelf::auto; + let justify = JustifySelf::baseline; + + properties.push(PropertyDeclaration::AlignSelf(align)); + properties.push(PropertyDeclaration::JustifySelf(justify)); + + let serialization = shorthand_properties_to_string(properties); + assert_eq!(serialization, "place-self: auto baseline;"); + } }