mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Don't incorrectly clamp values in calc that might not be only lengths.
Expressions with percentages may be negative or positive at computed value time. So, we can only clamp lengths at computed value time, which is what the other browsers do.
This commit is contained in:
parent
fbf77e40fe
commit
d02c5b0281
12 changed files with 97 additions and 48 deletions
|
@ -63,6 +63,8 @@ macro_rules! __define_css_keyword_enum__actual {
|
|||
|
||||
|
||||
pub mod specified {
|
||||
use app_units::Au;
|
||||
|
||||
#[repr(u8)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
|
@ -79,5 +81,14 @@ pub mod specified {
|
|||
AllowedNumericType::NonNegative => value >= 0.,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn clamp(&self, val: Au) -> Au {
|
||||
use std::cmp;
|
||||
match *self {
|
||||
AllowedNumericType::All => val,
|
||||
AllowedNumericType::NonNegative => cmp::max(Au(0), val),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue