Bug 1374233 - Part 4: Add NonNegativeLengthOr{Auto|Normal|Number}.

Add NonNegativeLength, which could be computed to NonNegativeAu. So we
can declare Either<NonNegativeLength, X>, X=Auto, Normal, or Number.

NonNegativeLengthOrAuto is for column-width.
NonNegativeLengthOrNormal is for column-gap.
NonNegativeLengthOrNumber is for -moz-tab-size.

MozReview-Commit-ID: AfU8XpA1um0
This commit is contained in:
Boris Chiou 2017-07-20 16:27:35 +08:00
parent 234d2c1b32
commit 2ef38ce67a
8 changed files with 68 additions and 20 deletions

View file

@ -17,10 +17,10 @@ use nsstring::{nsACString, nsCString};
use std::cmp::max;
use values::{Auto, Either, ExtremumLength, None_, Normal};
use values::computed::{Angle, LengthOrPercentage, LengthOrPercentageOrAuto};
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage};
use values::computed::{LengthOrPercentageOrNone, Number, NumberOrPercentage, NonNegativeAu};
use values::computed::{MaxLength, MozLength, Percentage};
use values::computed::basic_shape::ShapeRadius as ComputedShapeRadius;
use values::generics::CounterStyleOrNone;
use values::generics::{CounterStyleOrNone, NonNegative};
use values::generics::basic_shape::ShapeRadius;
use values::generics::gecko::ScrollSnapPoint;
use values::generics::grid::{TrackBreadth, TrackKeyword};
@ -134,6 +134,16 @@ impl GeckoStyleCoordConvertible for Au {
}
}
impl GeckoStyleCoordConvertible for NonNegativeAu {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
self.0.to_gecko_style_coord(coord);
}
fn from_gecko_style_coord<T: CoordData>(coord: &T) -> Option<Self> {
Au::from_gecko_style_coord(coord).map(NonNegative::<Au>)
}
}
impl GeckoStyleCoordConvertible for LengthOrPercentageOrAuto {
fn to_gecko_style_coord<T: CoordDataMut>(&self, coord: &mut T) {
let value = match *self {