mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce CalcLengthOrPercentage::unclamped_length
This is necessary for some operations, notably converting this to something suitable for gecko.
This commit is contained in:
parent
bcf1a6c5e5
commit
307dd74ecf
9 changed files with 32 additions and 20 deletions
|
@ -88,12 +88,21 @@ impl CalcLengthOrPercentage {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns this `calc()` as a `<length>`.
|
||||
///
|
||||
/// Panics in debug mode if a percentage is present in the expression.
|
||||
#[inline]
|
||||
#[allow(missing_docs)]
|
||||
pub fn length(&self) -> Au {
|
||||
debug_assert!(self.percentage.is_none());
|
||||
self.clamping_mode.clamp(self.length)
|
||||
}
|
||||
|
||||
/// Returns the `<length>` component of this `calc()`, unclamped.
|
||||
#[inline]
|
||||
pub fn unclamped_length(&self) -> Au {
|
||||
self.length
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(missing_docs)]
|
||||
pub fn percentage(&self) -> CSSFloat {
|
||||
|
@ -245,7 +254,7 @@ impl LengthOrPercentage {
|
|||
match *self {
|
||||
Length(l) => (l, NotNaN::new(0.0).unwrap()),
|
||||
Percentage(p) => (Au(0), NotNaN::new(p).unwrap()),
|
||||
Calc(c) => (c.length(), NotNaN::new(c.percentage()).unwrap()),
|
||||
Calc(c) => (c.unclamped_length(), NotNaN::new(c.percentage()).unwrap()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue