mirror of
https://github.com/servo/servo.git
synced 2025-08-16 02:45:36 +01:00
Replace Au with CSSPixelLength in CalcLengthOrPercentage.
We replace Au with CSSPixelLength for the length part of computed::CalcLengthOrPercentage. Therefore, it would be easier to use CSSPixelLength for all other LengthOrPercentage{*} types.
This commit is contained in:
parent
a949e2a057
commit
535c1e3c6f
13 changed files with 99 additions and 117 deletions
|
@ -90,16 +90,18 @@ fn test_transform_interpolation_on_translate() {
|
|||
Length::new(25.),
|
||||
)]));
|
||||
let to = TransformList(Some(vec![
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Au(100)),
|
||||
LengthOrPercentage::Length(Au(50)),
|
||||
TransformOperation::Translate(LengthOrPercentage::Length(Au::from_px(100)),
|
||||
LengthOrPercentage::Length(Au::from_px(50)),
|
||||
Length::new(75.))]));
|
||||
assert_eq!(
|
||||
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
|
||||
TransformList(Some(vec![TransformOperation::Translate(
|
||||
// calc(50px + 25%)
|
||||
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(Au(50), Some(Percentage(0.25)))),
|
||||
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(Length::new(50.),
|
||||
Some(Percentage(0.25)))),
|
||||
// calc(25px + 50%)
|
||||
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(Au(25), Some(Percentage(0.5)))),
|
||||
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(Length::new(25.),
|
||||
Some(Percentage(0.5)))),
|
||||
Length::new(50.),
|
||||
)]))
|
||||
);
|
||||
|
|
|
@ -8,12 +8,12 @@ use style::values::computed::{CalcLengthOrPercentage, Percentage};
|
|||
|
||||
#[test]
|
||||
fn test_length_calc() {
|
||||
let calc = CalcLengthOrPercentage::new(Au(10), Some(Percentage(0.2)));
|
||||
let calc = CalcLengthOrPercentage::new(Au(10).into(), Some(Percentage(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::new(Au(10), None);
|
||||
let calc = CalcLengthOrPercentage::new(Au(10).into(), None);
|
||||
assert_eq!(calc.to_used_value(Some(Au(0))), Some(Au(10)));
|
||||
assert_eq!(calc.to_used_value(None), Some(Au(10)));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue