Skip to content

Commit

Permalink
Add place-self shorthand property (it fails unit-test)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamamu committed Apr 9, 2017
1 parent d6f4c8c commit b6cbd31
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
24 changes: 24 additions & 0 deletions components/style/properties/shorthand/position.mako.rs
Expand Up @@ -186,3 +186,27 @@
}
</%helpers:shorthand>

<%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<Longhands, ()> {
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<W>(&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)
}
}
</%helpers:shorthand>
17 changes: 17 additions & 0 deletions tests/unit/style/properties/serialization.rs
Expand Up @@ -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;");
}
}

0 comments on commit b6cbd31

Please sign in to comment.