Introduce CSSPixelLength and update NonNegativeLength.

First, we define computed::CSSPixelLength which contains a CSSFloat, a
pixel value, and then we replace computed::Length with CSSPixelLength.
Therefore, the |ComputedValue| of NoCalcLength, AbsoluteLength,
FontRelativeLength, ViewportPercentageLength, CharacterWidth, and
PhysicalLength is CSSPixelLength.

Besides, we drop NonNegativeAu, and replace computed::NonNegativeLength
with NonNegative<computed::Length>. (i.e. NonNegative<CSSPixelLength>)
This commit is contained in:
Boris Chiou 2017-09-13 14:26:51 +08:00
parent cad3aff508
commit a949e2a057
40 changed files with 502 additions and 406 deletions

View file

@ -65,34 +65,34 @@ fn test_rgba_color_interepolation_out_of_range_clamped_2() {
// Transform
#[test]
fn test_transform_interpolation_on_translate() {
use style::values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
use style::values::computed::{CalcLengthOrPercentage, Length, LengthOrPercentage};
let from = TransformList(Some(vec![
TransformOperation::Translate(LengthOrPercentage::Length(Au(0)),
LengthOrPercentage::Length(Au(100)),
Au(25))]));
Length::new(25.))]));
let to = TransformList(Some(vec![
TransformOperation::Translate(LengthOrPercentage::Length(Au(100)),
LengthOrPercentage::Length(Au(0)),
Au(75))]));
Length::new(75.))]));
assert_eq!(
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
TransformList(Some(vec![TransformOperation::Translate(
LengthOrPercentage::Length(Au(50)),
LengthOrPercentage::Length(Au(50)),
Au(50),
Length::new(50.),
)]))
);
let from = TransformList(Some(vec![TransformOperation::Translate(
LengthOrPercentage::Percentage(Percentage(0.5)),
LengthOrPercentage::Percentage(Percentage(1.0)),
Au(25),
Length::new(25.),
)]));
let to = TransformList(Some(vec![
TransformOperation::Translate(LengthOrPercentage::Length(Au(100)),
LengthOrPercentage::Length(Au(50)),
Au(75))]));
Length::new(75.))]));
assert_eq!(
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
TransformList(Some(vec![TransformOperation::Translate(
@ -100,7 +100,7 @@ fn test_transform_interpolation_on_translate() {
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(Au(50), Some(Percentage(0.25)))),
// calc(25px + 50%)
LengthOrPercentage::Calc(CalcLengthOrPercentage::new(Au(25), Some(Percentage(0.5)))),
Au(50),
Length::new(50.),
)]))
);
}
@ -150,14 +150,14 @@ fn test_transform_interpolation_on_skew() {
#[test]
fn test_transform_interpolation_on_mismatched_lists() {
use style::values::computed::{Angle, LengthOrPercentage, Percentage};
use style::values::computed::{Angle, Length, LengthOrPercentage};
let from = TransformList(Some(vec![TransformOperation::Rotate(0.0, 0.0, 1.0,
Angle::from_radians(100.0))]));
let to = TransformList(Some(vec![
TransformOperation::Translate(LengthOrPercentage::Length(Au(100)),
LengthOrPercentage::Length(Au(0)),
Au(0))]));
Length::new(0.))]));
assert_eq!(
from.animate(&to, Procedure::Interpolate { progress: 0.5 }).unwrap(),
TransformList(Some(vec![TransformOperation::InterpolateMatrix {