mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Tweak the serialization of text-decoration.
We are trying to not serialize `text-decoration-line: none` if there are other non-default values for the longhands. Differential Revision: https://phabricator.services.mozilla.com/D44908
This commit is contained in:
parent
3c2e4d1e98
commit
eb8195dfa4
1 changed files with 34 additions and 10 deletions
|
@ -74,25 +74,49 @@
|
||||||
|
|
||||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||||
self.text_decoration_line.to_css(dest)?;
|
use crate::values::specified::TextDecorationLine;
|
||||||
|
|
||||||
|
let (is_solid_style, is_current_color, is_auto_thickness) =
|
||||||
|
(
|
||||||
|
% if engine == "gecko":
|
||||||
|
*self.text_decoration_style == text_decoration_style::SpecifiedValue::Solid,
|
||||||
|
*self.text_decoration_color == specified::Color::CurrentColor,
|
||||||
|
self.text_decoration_thickness.map_or(true, |t| t.is_auto())
|
||||||
|
% else:
|
||||||
|
true, true, true
|
||||||
|
% endif
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut has_value = false;
|
||||||
|
let is_none = *self.text_decoration_line == TextDecorationLine::none();
|
||||||
|
if (is_solid_style && is_current_color && is_auto_thickness) || !is_none {
|
||||||
|
self.text_decoration_line.to_css(dest)?;
|
||||||
|
has_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
% if engine == "gecko":
|
% if engine == "gecko":
|
||||||
if *self.text_decoration_style != text_decoration_style::SpecifiedValue::Solid {
|
if !is_solid_style {
|
||||||
|
if has_value {
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
self.text_decoration_style.to_css(dest)?;
|
|
||||||
}
|
}
|
||||||
|
self.text_decoration_style.to_css(dest)?;
|
||||||
|
has_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
if *self.text_decoration_color != specified::Color::CurrentColor {
|
if !is_current_color {
|
||||||
|
if has_value {
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
self.text_decoration_color.to_css(dest)?;
|
|
||||||
}
|
}
|
||||||
|
self.text_decoration_color.to_css(dest)?;
|
||||||
|
has_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(text_decoration_thickness) = self.text_decoration_thickness {
|
if !is_auto_thickness {
|
||||||
if !text_decoration_thickness.is_auto() {
|
if has_value {
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
self.text_decoration_thickness.to_css(dest)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
self.text_decoration_thickness.to_css(dest)?;
|
||||||
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue