mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Properly track whether <angle> or <time> values came from calc() expressions.
This commit is contained in:
parent
c654c05884
commit
fc72f096a0
10 changed files with 281 additions and 90 deletions
|
@ -20,7 +20,7 @@ pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword};
|
|||
pub use super::{Auto, Either, None_};
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use super::specified::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
||||
pub use super::specified::{Angle, BorderStyle, GridLine, Percentage, Time, UrlOrNone};
|
||||
pub use super::specified::{BorderStyle, GridLine, Percentage, UrlOrNone};
|
||||
pub use super::specified::url::SpecifiedUrl;
|
||||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNumber, LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
pub use self::length::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone, LengthOrNone};
|
||||
|
@ -114,6 +114,76 @@ impl<T> ToComputedValue for T
|
|||
}
|
||||
}
|
||||
|
||||
/// A computed `<angle>` value.
|
||||
#[derive(Clone, PartialEq, PartialOrd, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
pub struct Angle {
|
||||
radians: CSSFloat,
|
||||
}
|
||||
|
||||
impl Angle {
|
||||
/// Construct a computed `Angle` value from a radian amount.
|
||||
pub fn from_radians(radians: CSSFloat) -> Self {
|
||||
Angle {
|
||||
radians: radians,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the amount of radians this angle represents.
|
||||
#[inline]
|
||||
pub fn radians(&self) -> CSSFloat {
|
||||
self.radians
|
||||
}
|
||||
|
||||
/// Returns an angle that represents a rotation of zero radians.
|
||||
pub fn zero() -> Self {
|
||||
Self::from_radians(0.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Angle {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
write!(dest, "{}rad", self.radians())
|
||||
}
|
||||
}
|
||||
|
||||
/// A computed `<time>` value.
|
||||
#[derive(Clone, PartialEq, PartialOrd, Copy, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
|
||||
pub struct Time {
|
||||
seconds: CSSFloat,
|
||||
}
|
||||
|
||||
impl Time {
|
||||
/// Construct a computed `Time` value from a seconds amount.
|
||||
pub fn from_seconds(seconds: CSSFloat) -> Self {
|
||||
Time {
|
||||
seconds: seconds,
|
||||
}
|
||||
}
|
||||
|
||||
/// Construct a computed `Time` value that represents zero seconds.
|
||||
pub fn zero() -> Self {
|
||||
Self::from_seconds(0.0)
|
||||
}
|
||||
|
||||
/// Return the amount of seconds this time represents.
|
||||
#[inline]
|
||||
pub fn seconds(&self) -> CSSFloat {
|
||||
self.seconds
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Time {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
write!(dest, "{}s", self.seconds())
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for specified::Color {
|
||||
type ComputedValue = RGBA;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue