diff --git a/servo/components/style/properties/shorthand/position.mako.rs b/servo/components/style/properties/shorthand/position.mako.rs index 12581a3dff7e..aed3f1bb7b3b 100644 --- a/servo/components/style/properties/shorthand/position.mako.rs +++ b/servo/components/style/properties/shorthand/position.mako.rs @@ -137,3 +137,98 @@ } + +<%helpers:shorthand name="place-content" sub_properties="align-content justify-content" + spec="https://drafts.csswg.org/css-align/#propdef-place-content" + products="gecko" disable_when_testing="True"> + use properties::longhands::align_content; + use properties::longhands::justify_content; + + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { + let align = align_content::parse(context, input)?; + let justify = input.try(|input| justify_content::parse(context, input)) + .unwrap_or(justify_content::SpecifiedValue::from(align)); + + Ok(Longhands { + align_content: align, + justify_content: justify, + }) + } + + impl<'a> ToCss for LonghandsToSerialize<'a> { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + if self.align_content == self.justify_content { + self.align_content.to_css(dest) + } else { + self.justify_content.to_css(dest)?; + dest.write_str(" ")?; + self.justify_content.to_css(dest) + } + } + } + + +<%helpers:shorthand name="place-self" sub_properties="align-self justify-self" + spec="https://drafts.csswg.org/css-align/#place-self-property" + products="gecko" disable_when_testing="True"> + 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 { + if self.align_self == self.justify_self { + self.align_self.to_css(dest) + } else { + self.align_self.to_css(dest)?; + dest.write_str(" ")?; + self.justify_self.to_css(dest) + } + } + } + + +<%helpers:shorthand name="place-items" sub_properties="align-items justify-items" + spec="https://drafts.csswg.org/css-align/#place-items-property" + products="gecko" disable_when_testing="True"> + use values::specified::align::{AlignItems, JustifyItems}; + use parser::Parse; + + impl From for JustifyItems { + fn from(align: AlignItems) -> JustifyItems { + JustifyItems(align.0) + } + } + + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { + let align = AlignItems::parse(context, input)?; + let justify = input.try(|input| JustifyItems::parse(context, input)) + .unwrap_or(JustifyItems::from(align)); + + Ok(Longhands { + align_items: align, + justify_items: justify, + }) + } + + impl<'a> ToCss for LonghandsToSerialize<'a> { + fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + if self.align_items.0 == self.justify_items.0 { + self.align_items.to_css(dest) + } else { + self.align_items.to_css(dest)?; + dest.write_str(" ")?; + self.justify_items.to_css(dest) + } + } + } +