Improve serialization of the outline shorthand

This is a backport of https://phabricator.services.mozilla.com/D155569,
by Connor Pearson.

Test: /css/css-ui/parsing/outline-valid-mandatory.html
This commit is contained in:
Oriol Brufau 2023-05-03 23:20:32 +02:00
parent f29834608a
commit 960f496948
3 changed files with 22 additions and 116 deletions

View file

@ -7,7 +7,6 @@
<%helpers:shorthand name="outline"
engines="gecko servo-2013 servo-2020"
sub_properties="outline-color outline-style outline-width"
derive_serialize="True"
spec="https://drafts.csswg.org/css-ui/#propdef-outline">
use crate::properties::longhands::{outline_color, outline_width, outline_style};
use crate::values::specified;
@ -56,6 +55,28 @@
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
let mut wrote_value = false;
% for name in "color style width".split():
if *self.outline_${name} != outline_${name}::get_initial_specified_value() {
if wrote_value {
dest.write_char(' ')?;
}
self.outline_${name}.to_css(dest)?;
wrote_value = true;
}
% endfor
if !wrote_value {
self.outline_style.to_css(dest)?;
}
Ok(())
}
}
</%helpers:shorthand>
// The -moz-outline-radius shorthand is non-standard and not on a standards track.