mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Serialize a bunch of image properties with Servo.
I had to fix the conversion for BackgroundSize too, hopefully we can simplify all this using cbindgen in the future instead of CalcValue. Differential Revision: https://phabricator.services.mozilla.com/D7580
This commit is contained in:
parent
0d5d5a9c82
commit
7345af613a
4 changed files with 63 additions and 19 deletions
|
@ -202,21 +202,34 @@ impl ToCss for CalcLengthOrPercentage {
|
|||
{
|
||||
use num_traits::Zero;
|
||||
|
||||
let (length, percentage) = match (self.length, self.percentage) {
|
||||
(l, None) => return l.to_css(dest),
|
||||
(l, Some(p)) if l.px() == 0. => return p.to_css(dest),
|
||||
(l, Some(p)) => (l, p),
|
||||
};
|
||||
let length = self.unclamped_length();
|
||||
match self.percentage {
|
||||
Some(p) => {
|
||||
if length.px() == 0. && self.clamping_mode.clamp(p.0) == p.0 {
|
||||
return p.to_css(dest);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if self.clamping_mode.clamp(length.px()) == length.px() {
|
||||
return length.to_css(dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dest.write_str("calc(")?;
|
||||
percentage.to_css(dest)?;
|
||||
|
||||
dest.write_str(if length.px() < Zero::zero() {
|
||||
" - "
|
||||
if let Some(percentage) = self.percentage {
|
||||
percentage.to_css(dest)?;
|
||||
if length.px() != 0. {
|
||||
dest.write_str(if length.px() < Zero::zero() {
|
||||
" - "
|
||||
} else {
|
||||
" + "
|
||||
})?;
|
||||
length.abs().to_css(dest)?;
|
||||
}
|
||||
} else {
|
||||
" + "
|
||||
})?;
|
||||
length.abs().to_css(dest)?;
|
||||
length.to_css(dest)?;
|
||||
}
|
||||
|
||||
dest.write_str(")")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue