Make use of Either<A, B> for LengthOrNone

This commit is contained in:
Ravi Shankar 2016-11-03 21:29:47 +05:30
parent 5df250bc05
commit c4fc49c559
10 changed files with 21 additions and 116 deletions

View file

@ -178,7 +178,7 @@
use parser::{ParserContext, ParserContextExtraData};
use properties::{CSSWideKeyword, DeclaredValue, Shorthand};
% endif
#[allow(unused_imports)]
use values::{Auto, Either, None_, Normal};
use cascade_info::CascadeInfo;
use error_reporting::ParseErrorReporter;
use parser::Parse;

View file

@ -22,6 +22,7 @@ use std::cmp;
use std::fmt;
use style_traits::ToCss;
use super::ComputedValues;
use values::Either;
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
use values::computed::{BorderRadiusSize, LengthOrNone};
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
@ -682,8 +683,8 @@ impl Interpolate for BoxShadow {
impl Interpolate for LengthOrNone {
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
match (*self, *other) {
(LengthOrNone::Length(ref len), LengthOrNone::Length(ref other)) =>
len.interpolate(&other, progress).map(LengthOrNone::Length),
(Either::First(ref length), Either::First(ref other)) =>
length.interpolate(&other, progress).map(Either::First),
_ => Err(()),
}
}

View file

@ -1395,7 +1395,7 @@ ${helpers.single_keyword("transform-style",
${helpers.predefined_type("perspective",
"LengthOrNone",
"computed::LengthOrNone::None",
"Either::Second(None_)",
products="servo",
animatable=True)}

View file

@ -30,6 +30,7 @@ use logical_geometry::WritingMode;
use parser::{ParserContext, ParserContextExtraData};
use style_traits::ToCss;
use stylesheets::Origin;
#[cfg(feature = "servo")] use values::Either;
use values::{HasViewportPercentage, computed};
use cascade_info::CascadeInfo;
use rule_tree::StrongRuleNode;
@ -1249,7 +1250,7 @@ impl ComputedValues {
if effects.transform.0.is_some() {
return transform_style::T::flat;
}
if effects.perspective != computed::LengthOrNone::None {
if let Either::First(ref _length) = effects.perspective {
return transform_style::T::flat;
}
}