mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: When serializing background shorthand skip initial values and order values according to grammar
Differential Revision: https://phabricator.services.mozilla.com/D155077
This commit is contained in:
parent
76192031d3
commit
c8e3dc4d19
1 changed files with 54 additions and 18 deletions
|
@ -12,7 +12,7 @@
|
||||||
background-clip"
|
background-clip"
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#the-background">
|
spec="https://drafts.csswg.org/css-backgrounds/#the-background">
|
||||||
use crate::properties::longhands::{background_position_x, background_position_y, background_repeat};
|
use crate::properties::longhands::{background_position_x, background_position_y, background_repeat};
|
||||||
use crate::properties::longhands::{background_attachment, background_image, background_size, background_origin};
|
use crate::properties::longhands::{background_attachment, background_color, background_image, background_size, background_origin};
|
||||||
use crate::properties::longhands::background_clip;
|
use crate::properties::longhands::background_clip;
|
||||||
use crate::properties::longhands::background_clip::single_value::computed_value::T as Clip;
|
use crate::properties::longhands::background_clip::single_value::computed_value::T as Clip;
|
||||||
use crate::properties::longhands::background_origin::single_value::computed_value::T as Origin;
|
use crate::properties::longhands::background_origin::single_value::computed_value::T as Origin;
|
||||||
|
@ -156,35 +156,71 @@
|
||||||
dest.write_str(", ")?;
|
dest.write_str(", ")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut wrote_value = false;
|
||||||
|
|
||||||
if i == len - 1 {
|
if i == len - 1 {
|
||||||
self.background_color.to_css(dest)?;
|
if *self.background_color != background_color::get_initial_specified_value() {
|
||||||
dest.write_str(" ")?;
|
self.background_color.to_css(dest)?;
|
||||||
|
wrote_value = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if *image != background_image::single_value::get_initial_specified_value() {
|
||||||
|
if wrote_value {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
}
|
||||||
|
image.to_css(dest)?;
|
||||||
|
wrote_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Size is only valid after a position so when there is a
|
||||||
|
// non-initial size we must also serialize position
|
||||||
|
if *position_x != PositionComponent::zero() ||
|
||||||
|
*position_y != PositionComponent::zero() ||
|
||||||
|
*size != background_size::single_value::get_initial_specified_value()
|
||||||
|
{
|
||||||
|
if wrote_value {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Position {
|
||||||
|
horizontal: position_x.clone(),
|
||||||
|
vertical: position_y.clone()
|
||||||
|
}.to_css(dest)?;
|
||||||
|
|
||||||
|
wrote_value = true;
|
||||||
|
|
||||||
|
if *size != background_size::single_value::get_initial_specified_value() {
|
||||||
|
dest.write_str(" / ")?;
|
||||||
|
size.to_css(dest)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
image.to_css(dest)?;
|
|
||||||
% for name in "repeat attachment".split():
|
% for name in "repeat attachment".split():
|
||||||
dest.write_str(" ")?;
|
if *${name} != background_${name}::single_value::get_initial_specified_value() {
|
||||||
${name}.to_css(dest)?;
|
if wrote_value {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
}
|
||||||
|
${name}.to_css(dest)?;
|
||||||
|
wrote_value = true;
|
||||||
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
||||||
dest.write_str(" ")?;
|
|
||||||
Position {
|
|
||||||
horizontal: position_x.clone(),
|
|
||||||
vertical: position_y.clone()
|
|
||||||
}.to_css(dest)?;
|
|
||||||
|
|
||||||
if *size != background_size::single_value::get_initial_specified_value() {
|
|
||||||
dest.write_str(" / ")?;
|
|
||||||
size.to_css(dest)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if *origin != Origin::PaddingBox || *clip != Clip::BorderBox {
|
if *origin != Origin::PaddingBox || *clip != Clip::BorderBox {
|
||||||
dest.write_str(" ")?;
|
if wrote_value {
|
||||||
|
dest.write_str(" ")?;
|
||||||
|
}
|
||||||
origin.to_css(dest)?;
|
origin.to_css(dest)?;
|
||||||
if *clip != From::from(*origin) {
|
if *clip != From::from(*origin) {
|
||||||
dest.write_str(" ")?;
|
dest.write_str(" ")?;
|
||||||
clip.to_css(dest)?;
|
clip.to_css(dest)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wrote_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !wrote_value {
|
||||||
|
image.to_css(dest)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue