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

@ -0,0 +1,54 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! Generic types for CSS values related to length.
use values::computed::ExtremumLength;
/// A generic value for the `width`, `height`, `min-width`, or `min-height` property.
///
/// Unlike `max-width` or `max-height` properties, a MozLength can be `auto`,
/// and cannot be `none`.
///
/// Note that it only accepts non-negative values.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
PartialEq,
SpecifiedValueInfo,
ToAnimatedZero,
ToComputedValue,
ToCss,
)]
pub enum MozLength<LengthOrPercentageOrAuto> {
LengthOrPercentageOrAuto(LengthOrPercentageOrAuto),
#[animation(error)]
ExtremumLength(ExtremumLength),
}
/// A generic value for the `max-width` or `max-height` property.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
PartialEq,
SpecifiedValueInfo,
ToAnimatedZero,
ToComputedValue,
ToCss
)]
pub enum MaxLength<LengthOrPercentageOrNone> {
LengthOrPercentageOrNone(LengthOrPercentageOrNone),
#[animation(error)]
ExtremumLength(ExtremumLength),
}

View file

@ -27,6 +27,7 @@ pub mod font;
pub mod gecko;
pub mod grid;
pub mod image;
pub mod length;
pub mod position;
pub mod rect;
pub mod size;