Auto merge of #29708 - Loirooriol:outline-serialization, r=mrobinson

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

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #29697 (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
This commit is contained in:
bors-servo 2023-05-05 16:22:51 +02:00 committed by GitHub
commit 0e6db5266d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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.