mirror of
https://github.com/servo/servo.git
synced 2025-08-11 16:35:33 +01:00
Add place-content shorthand property
This commit is contained in:
parent
d77d752990
commit
d6f4c8c6dd
2 changed files with 66 additions and 0 deletions
|
@ -137,3 +137,52 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
</%helpers:shorthand>
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
<%helpers:shorthand name="place-content" sub_properties="align-content justify-content"
|
||||||
|
spec="https://drafts.csswg.org/css-align/#propdef-place-content"
|
||||||
|
products="gecko">
|
||||||
|
use properties::longhands::align_content;
|
||||||
|
use properties::longhands::justify_content;
|
||||||
|
|
||||||
|
% if product == "servo":
|
||||||
|
impl From<align_content::SpecifiedValue> for justify_content::SpecifiedValue {
|
||||||
|
fn from(align: align_content::SpecifiedValue) ->
|
||||||
|
justify_content::SpecifiedValue {
|
||||||
|
match align {
|
||||||
|
align_content::SpecifiedValue::stretch =>
|
||||||
|
justify_content::SpecifiedValue::stretch,
|
||||||
|
align_content::SpecifiedValue::flex_start =>
|
||||||
|
justify_content::SpecifiedValue::flex_start,
|
||||||
|
align_content::SpecifiedValue::flex_end =>
|
||||||
|
justify_content::SpecifiedValue::flex_end,
|
||||||
|
align_content::SpecifiedValue::center =>
|
||||||
|
justify_content::SpecifiedValue::center,
|
||||||
|
align_content::SpecifiedValue::space_between =>
|
||||||
|
justify_content::SpecifiedValue::space_between,
|
||||||
|
align_content::SpecifiedValue::space_around =>
|
||||||
|
justify_content::SpecifiedValue::space_around,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
|
||||||
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
|
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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
self.align_content.to_css(dest)?;
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
self.justify_content.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</%helpers:shorthand>
|
||||||
|
|
||||||
|
|
|
@ -1246,4 +1246,21 @@ mod shorthand_serialization {
|
||||||
assert_eq!(counter_increment.to_css_string(), counter_increment_css);
|
assert_eq!(counter_increment.to_css_string(), counter_increment_css);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn place_content_serialize_all_available_properties() {
|
||||||
|
use style::properties::longhands::align_content::SpecifiedValue as AlignContent;
|
||||||
|
use style::properties::longhands::justify_content::SpecifiedValue as JustifyContent;
|
||||||
|
|
||||||
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
|
let align = AlignContent::stretch;
|
||||||
|
let justify = JustifyContent::center;
|
||||||
|
|
||||||
|
properties.push(PropertyDeclaration::AlignContent(align));
|
||||||
|
properties.push(PropertyDeclaration::JustifyContent(justify));
|
||||||
|
|
||||||
|
let serialization = shorthand_properties_to_string(properties);
|
||||||
|
assert_eq!(serialization, "place-content: stretch center;");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue