mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Replace LengthOrNone by a specific type for the perspective property
This was its only use, and it was bugged: AFAIK this didn't properly clamp animated values below 0.
This commit is contained in:
parent
4a98fa70bf
commit
260e05320c
11 changed files with 88 additions and 32 deletions
|
@ -13,9 +13,10 @@ use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
|
|||
use values::CustomIdent;
|
||||
use values::KeyframesName;
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
use values::generics::box_::Perspective as GenericPerspective;
|
||||
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
||||
use values::specified::{AllowQuirks, Number};
|
||||
use values::specified::length::LengthOrPercentage;
|
||||
use values::specified::length::{LengthOrPercentage, NonNegativeLength};
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)]
|
||||
|
@ -588,3 +589,18 @@ impl Parse for Contain {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A specified value for the `perspective` property.
|
||||
pub type Perspective = GenericPerspective<NonNegativeLength>;
|
||||
|
||||
impl Parse for Perspective {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(GenericPerspective::None);
|
||||
}
|
||||
Ok(GenericPerspective::Length(NonNegativeLength::parse(context, input)?))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::ops::{Add, Mul};
|
|||
use style_traits::{ParseError, StyleParseErrorKind};
|
||||
use style_traits::values::specified::AllowedNumericType;
|
||||
use super::{AllowQuirks, Number, ToComputedValue, Percentage};
|
||||
use values::{Auto, CSSFloat, Either, None_, Normal};
|
||||
use values::{Auto, CSSFloat, Either, Normal};
|
||||
use values::computed::{self, CSSPixelLength, Context, ExtremumLength};
|
||||
use values::generics::NonNegative;
|
||||
use values::specified::NonNegativeNumber;
|
||||
|
@ -1062,9 +1062,6 @@ impl NonNegativeLengthOrPercentage {
|
|||
}
|
||||
}
|
||||
|
||||
/// Either a `<length>` or the `none` keyword.
|
||||
pub type LengthOrNone = Either<Length, None_>;
|
||||
|
||||
/// Either a `<length>` or the `normal` keyword.
|
||||
pub type LengthOrNormal = Either<Length, Normal>;
|
||||
|
||||
|
|
|
@ -39,8 +39,9 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa
|
|||
pub use self::font::{FontFamily, FontLanguageOverride, FontVariationSettings, FontVariantEastAsian};
|
||||
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
|
||||
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang};
|
||||
pub use self::box_::{AnimationIterationCount, AnimationName, Display, OverscrollBehavior, Contain};
|
||||
pub use self::box_::{OverflowClipBox, ScrollSnapType, TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
|
||||
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective};
|
||||
pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
|
||||
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
|
||||
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
|
@ -51,7 +52,7 @@ pub use self::image::{ColorStop, EndingShape as GradientEndingShape, Gradient};
|
|||
pub use self::image::{GradientItem, GradientKind, Image, ImageLayer, MozImageRect};
|
||||
pub use self::inherited_box::ImageOrientation;
|
||||
pub use self::length::{AbsoluteLength, CalcLengthOrPercentage, CharacterWidth};
|
||||
pub use self::length::{FontRelativeLength, Length, LengthOrNone, LengthOrNumber};
|
||||
pub use self::length::{FontRelativeLength, Length, LengthOrNumber};
|
||||
pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
||||
pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{NoCalcLength, ViewportPercentageLength};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue