style: Make flex-flow serialization interoperable

Differential Revision: https://phabricator.services.mozilla.com/D180270
This commit is contained in:
Ting-Yu Lin 2023-06-08 16:37:21 +00:00 committed by Martin Robinson
parent abc0c86fef
commit 019c14cf0b

View file

@ -9,7 +9,6 @@
servo_pref="layout.flexbox.enabled",
sub_properties="flex-direction flex-wrap"
extra_prefixes="webkit"
derive_serialize="True"
spec="https://drafts.csswg.org/css-flexbox/#flex-flow-property">
use crate::properties::longhands::{flex_direction, flex_wrap};
@ -43,6 +42,21 @@
flex_wrap: unwrap_or_initial!(flex_wrap, wrap),
})
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
if *self.flex_direction == flex_direction::get_initial_specified_value() &&
*self.flex_wrap != flex_wrap::get_initial_specified_value() {
return self.flex_wrap.to_css(dest)
}
self.flex_direction.to_css(dest)?;
if *self.flex_wrap != flex_wrap::get_initial_specified_value() {
dest.write_char(' ')?;
self.flex_wrap.to_css(dest)?;
}
Ok(())
}
}
</%helpers:shorthand>
<%helpers:shorthand name="flex"