mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Refactor how calc() clamping is done on computed values (fixes #15296)
This commit is contained in:
parent
f935f2da01
commit
d0b9bd9c64
13 changed files with 173 additions and 154 deletions
|
@ -5,17 +5,18 @@
|
|||
use app_units::Au;
|
||||
use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_length};
|
||||
use style::values::computed::CalcLengthOrPercentage;
|
||||
use style_traits::values::specified::AllowedLengthType;
|
||||
|
||||
#[test]
|
||||
fn test_length_calc() {
|
||||
let calc = CalcLengthOrPercentage { length: Au(10), percentage: Some(0.2) };
|
||||
assert_eq!(calc.to_computed(Some(Au(10))), Some(Au(12)));
|
||||
assert_eq!(calc.to_computed(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_computed(None), None);
|
||||
let calc = CalcLengthOrPercentage::new(Au(10), Some(0.2));
|
||||
assert_eq!(calc.to_used_value(Some(Au(10))), Some(Au(12)));
|
||||
assert_eq!(calc.to_used_value(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_used_value(None), None);
|
||||
|
||||
let calc = CalcLengthOrPercentage { length: Au(10), percentage: None };
|
||||
assert_eq!(calc.to_computed(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_computed(None), Some(Au(10)));
|
||||
let calc = CalcLengthOrPercentage::new(Au(10), None);
|
||||
assert_eq!(calc.to_used_value(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_used_value(None), Some(Au(10)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue