mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Add place-items shorthand property (it fails unit-test)
This commit is contained in:
parent
b6cbd31b73
commit
bfa408255f
2 changed files with 49 additions and 0 deletions
|
@ -210,3 +210,35 @@
|
|||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="place-items" sub_properties="align-items justify-items"
|
||||
spec="https://drafts.csswg.org/css-align/#place-items-property"
|
||||
products="gecko">
|
||||
use values::specified::align::{AlignItems, JustifyItems};
|
||||
use parser::Parse;
|
||||
|
||||
impl From<AlignItems> for JustifyItems {
|
||||
fn from(align: AlignItems) -> JustifyItems {
|
||||
JustifyItems(align.0)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||
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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.align_items.to_css(dest)?;
|
||||
dest.write_str(" ")?;
|
||||
self.justify_items.to_css(dest)
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
|
|
@ -1280,4 +1280,21 @@ mod shorthand_serialization {
|
|||
let serialization = shorthand_properties_to_string(properties);
|
||||
assert_eq!(serialization, "place-self: auto baseline;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn place_items_serialize_all_available_properties() {
|
||||
use style::properties::longhands::align_items::SpecifiedValue as AlignItems;
|
||||
use style::properties::longhands::justify_items::SpecifiedValue as JustifyItems;
|
||||
|
||||
let mut properties = Vec::new();
|
||||
|
||||
let align = AlignItems::flex_start;
|
||||
let justify = JustifyItems::baseline;
|
||||
|
||||
properties.push(PropertyDeclaration::AlignItems(align));
|
||||
properties.push(PropertyDeclaration::JustifyItems(justify));
|
||||
|
||||
let serialization = shorthand_properties_to_string(properties);
|
||||
assert_eq!(serialization, "place-items: flex-start baseline;");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue