style: Move MozLength and MaxLength into generics.

Move MozLength and MaxLength into generics, and drop the manual implementation
of ToComputedValue.

Differential Revision: https://phabricator.services.mozilla.com/D8291
This commit is contained in:
Boris Chiou 2018-10-16 01:07:41 +00:00 committed by Emilio Cobos Álvarez
parent 53eb6cd667
commit c9d39b2b19
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 89 additions and 118 deletions

View file

@ -292,8 +292,9 @@ impl ToAnimatedValue for ComputedMaxLength {
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
use values::computed::{Length, LengthOrPercentageOrNone, Percentage};
use values::generics::length::MaxLength as GenericMaxLength;
match animated {
ComputedMaxLength::LengthOrPercentageOrNone(lopn) => {
GenericMaxLength::LengthOrPercentageOrNone(lopn) => {
let result = match lopn {
LengthOrPercentageOrNone::Length(px) => {
LengthOrPercentageOrNone::Length(Length::new(px.px().max(0.)))
@ -303,7 +304,7 @@ impl ToAnimatedValue for ComputedMaxLength {
},
_ => lopn,
};
ComputedMaxLength::LengthOrPercentageOrNone(result)
GenericMaxLength::LengthOrPercentageOrNone(result)
},
_ => animated,
}
@ -321,8 +322,9 @@ impl ToAnimatedValue for ComputedMozLength {
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
use values::computed::{Length, LengthOrPercentageOrAuto, Percentage};
use values::generics::length::MozLength as GenericMozLength;
match animated {
ComputedMozLength::LengthOrPercentageOrAuto(lopa) => {
GenericMozLength::LengthOrPercentageOrAuto(lopa) => {
let result = match lopa {
LengthOrPercentageOrAuto::Length(px) => {
LengthOrPercentageOrAuto::Length(Length::new(px.px().max(0.)))
@ -332,7 +334,7 @@ impl ToAnimatedValue for ComputedMozLength {
},
_ => lopa,
};
ComputedMozLength::LengthOrPercentageOrAuto(result)
GenericMozLength::LengthOrPercentageOrAuto(result)
},
_ => animated,
}