style: Move line-clamp out of mako and do some adjacent clean-up

No behavior change, but simplifies the following patch.

Differential Revision: https://phabricator.services.mozilla.com/D155180
This commit is contained in:
Emilio Cobos Álvarez 2022-08-31 12:39:19 +00:00 committed by Martin Robinson
parent 3fa76ff2e8
commit a44db17432
12 changed files with 101 additions and 99 deletions

View file

@ -8,11 +8,10 @@ use crate::custom_properties::Name as CustomPropertyName;
use crate::parser::{Parse, ParserContext};
use crate::properties::{LonghandId, PropertyDeclarationId};
use crate::properties::{PropertyId, ShorthandId};
use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
use crate::values::generics::box_::Perspective as GenericPerspective;
use crate::values::generics::box_::{GenericAnimationIterationCount, GenericPerspective, GenericLineClamp};
use crate::values::generics::box_::{GenericContainIntrinsicSize, GenericVerticalAlign, VerticalAlignKeyword};
use crate::values::specified::length::{LengthPercentage, NonNegativeLength};
use crate::values::specified::{AllowQuirks, Number};
use crate::values::specified::{AllowQuirks, Number, Integer};
use crate::values::{CustomIdent, KeyframesName, TimelineName};
use crate::Atom;
use cssparser::Parser;
@ -615,6 +614,9 @@ impl Debug for Display {
/// A specified value for the `contain-intrinsic-size` property.
pub type ContainIntrinsicSize = GenericContainIntrinsicSize<NonNegativeLength>;
/// A specified value for the `line-clamp` property.
pub type LineClamp = GenericLineClamp<Integer>;
/// A specified value for the `vertical-align` property.
pub type VerticalAlign = GenericVerticalAlign<LengthPercentage>;
@ -1443,6 +1445,21 @@ impl Parse for ContainIntrinsicSize {
}
}
impl Parse for LineClamp {
/// none | <positive-integer>
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if let Ok(i) = input.try_parse(|i| crate::values::specified::PositiveInteger::parse(context, i))
{
return Ok(Self(i.0))
}
input.expect_ident_matching("none")?;
Ok(Self::none())
}
}
/// https://drafts.csswg.org/css-contain-2/#content-visibility
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(