style: Update calc() serialization to the spec.

This commit is contained in:
Emilio Cobos Álvarez 2017-08-17 21:20:07 +02:00
parent d17f27640b
commit f8a6eccda2
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 89 additions and 25 deletions

View file

@ -11,7 +11,7 @@ use values::CSSFloat;
use values::animated::ToAnimatedZero;
/// A computed percentage.
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, Default, HasViewportPercentage, PartialEq)]
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, Default, HasViewportPercentage, PartialEq, PartialOrd)]
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
pub struct Percentage(pub CSSFloat);
@ -27,6 +27,12 @@ impl Percentage {
pub fn hundred() -> Self {
Percentage(1.)
}
/// Returns the absolute value for this percentage.
#[inline]
pub fn abs(&self) -> Self {
Percentage(self.0.abs())
}
}
/// https://drafts.csswg.org/css-transitions/#animtype-percentage