mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move specified and computed percentages to submodules
This commit is contained in:
parent
fb8400d745
commit
796a2b9632
7 changed files with 212 additions and 174 deletions
|
@ -49,6 +49,7 @@ pub use super::generics::grid::GridLine;
|
|||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNone, LengthOrNumber, LengthOrPercentage};
|
||||
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::NonNegativeLengthOrPercentage;
|
||||
pub use self::percentage::Percentage;
|
||||
pub use self::position::Position;
|
||||
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind, SVGStrokeDashArray, SVGWidth};
|
||||
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, WordSpacing};
|
||||
|
@ -66,6 +67,7 @@ pub mod image;
|
|||
#[cfg(feature = "gecko")]
|
||||
pub mod gecko;
|
||||
pub mod length;
|
||||
pub mod percentage;
|
||||
pub mod position;
|
||||
pub mod rect;
|
||||
pub mod svg;
|
||||
|
@ -658,45 +660,6 @@ impl From<Au> for NonNegativeAu {
|
|||
}
|
||||
}
|
||||
|
||||
/// A computed `<percentage>` value.
|
||||
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, Default, HasViewportPercentage, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))]
|
||||
pub struct Percentage(pub CSSFloat);
|
||||
|
||||
impl Percentage {
|
||||
/// 0%
|
||||
#[inline]
|
||||
pub fn zero() -> Self {
|
||||
Percentage(0.)
|
||||
}
|
||||
|
||||
/// 100%
|
||||
#[inline]
|
||||
pub fn hundred() -> Self {
|
||||
Percentage(1.)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for Percentage {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
write!(dest, "{}%", self.0 * 100.)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for specified::Percentage {
|
||||
type ComputedValue = Percentage;
|
||||
|
||||
#[inline]
|
||||
fn to_computed_value(&self, _: &Context) -> Percentage {
|
||||
Percentage(self.get())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_computed_value(computed: &Percentage) -> Self {
|
||||
specified::Percentage::new(computed.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// The computed value of a CSS `url()`, resolved relative to the stylesheet URL.
|
||||
#[cfg(feature = "servo")]
|
||||
#[derive(Clone, Debug, HeapSizeOf, Serialize, Deserialize, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue