mirror of
https://github.com/servo/servo.git
synced 2025-08-11 08:25:32 +01:00
style: Use Rust types for perspective and z-index.
Differential Revision: https://phabricator.services.mozilla.com/D20381
This commit is contained in:
parent
6428ed726d
commit
74d7d5bc42
8 changed files with 17 additions and 87 deletions
|
@ -74,6 +74,7 @@ pub enum AnimationIterationCount<Number> {
|
|||
Copy,
|
||||
Debug,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToAnimatedValue,
|
||||
|
@ -81,13 +82,16 @@ pub enum AnimationIterationCount<Number> {
|
|||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum Perspective<NonNegativeLength> {
|
||||
#[repr(C, u8)]
|
||||
pub enum GenericPerspective<NonNegativeLength> {
|
||||
/// A non-negative length.
|
||||
Length(NonNegativeLength),
|
||||
/// The keyword `none`.
|
||||
None,
|
||||
}
|
||||
|
||||
pub use self::GenericPerspective as Perspective;
|
||||
|
||||
impl<L> Perspective<L> {
|
||||
/// Returns `none`.
|
||||
#[inline]
|
||||
|
|
|
@ -45,18 +45,22 @@ impl<H, V> Position<H, V> {
|
|||
Debug,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
Parse,
|
||||
SpecifiedValueInfo,
|
||||
ToAnimatedZero,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum ZIndex<Integer> {
|
||||
#[repr(C, u8)]
|
||||
pub enum GenericZIndex<I> {
|
||||
/// An integer value.
|
||||
Integer(Integer),
|
||||
Integer(I),
|
||||
/// The keyword `auto`.
|
||||
Auto,
|
||||
}
|
||||
|
||||
pub use self::GenericZIndex as ZIndex;
|
||||
|
||||
impl<Integer> ZIndex<Integer> {
|
||||
/// Returns `auto`
|
||||
#[inline]
|
||||
|
|
|
@ -862,20 +862,6 @@ 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,
|
||||
)?))
|
||||
}
|
||||
}
|
||||
|
||||
/// A given transition property, that is either `All`, a longhand or shorthand
|
||||
/// property, or an unsupported or custom property.
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)]
|
||||
|
|
|
@ -585,7 +585,7 @@ impl Parse for PositiveInteger {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
Integer::parse_positive(context, input).map(GreaterThanOrEqualToOne::<Integer>)
|
||||
Integer::parse_positive(context, input).map(GreaterThanOrEqualToOne)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -731,15 +731,3 @@ impl GridTemplateAreas {
|
|||
|
||||
/// A specified value for the `z-index` property.
|
||||
pub type ZIndex = GenericZIndex<Integer>;
|
||||
|
||||
impl Parse for ZIndex {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|i| i.expect_ident_matching("auto")).is_ok() {
|
||||
return Ok(GenericZIndex::Auto);
|
||||
}
|
||||
Ok(GenericZIndex::Integer(Integer::parse(context, input)?))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue