mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
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:
parent
3fa76ff2e8
commit
a44db17432
12 changed files with 101 additions and 99 deletions
|
@ -65,46 +65,6 @@ macro_rules! try_match_ident_ignore_ascii_case {
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! define_keyword_type {
|
|
||||||
($name:ident, $css:expr) => {
|
|
||||||
#[allow(missing_docs)]
|
|
||||||
#[derive(
|
|
||||||
Animate,
|
|
||||||
Clone,
|
|
||||||
ComputeSquaredDistance,
|
|
||||||
Copy,
|
|
||||||
MallocSizeOf,
|
|
||||||
PartialEq,
|
|
||||||
SpecifiedValueInfo,
|
|
||||||
ToAnimatedValue,
|
|
||||||
ToAnimatedZero,
|
|
||||||
ToComputedValue,
|
|
||||||
ToCss,
|
|
||||||
ToResolvedValue,
|
|
||||||
ToShmem,
|
|
||||||
)]
|
|
||||||
pub struct $name;
|
|
||||||
|
|
||||||
impl fmt::Debug for $name {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
f.write_str($css)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl $crate::parser::Parse for $name {
|
|
||||||
fn parse<'i, 't>(
|
|
||||||
_context: &$crate::parser::ParserContext,
|
|
||||||
input: &mut ::cssparser::Parser<'i, 't>,
|
|
||||||
) -> Result<$name, ::style_traits::ParseError<'i>> {
|
|
||||||
input
|
|
||||||
.expect_ident_matching($css)
|
|
||||||
.map(|_| $name)
|
|
||||||
.map_err(|e| e.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
macro_rules! local_name {
|
macro_rules! local_name {
|
||||||
($s:tt) => {
|
($s:tt) => {
|
||||||
|
|
|
@ -466,6 +466,7 @@ class Longhand(Property):
|
||||||
"JustifyItems",
|
"JustifyItems",
|
||||||
"JustifySelf",
|
"JustifySelf",
|
||||||
"LineBreak",
|
"LineBreak",
|
||||||
|
"LineClamp",
|
||||||
"MasonryAutoFlow",
|
"MasonryAutoFlow",
|
||||||
"MozForceBrokenImageIcon",
|
"MozForceBrokenImageIcon",
|
||||||
"text::MozControlCharacterVisibility",
|
"text::MozControlCharacterVisibility",
|
||||||
|
@ -483,7 +484,6 @@ class Longhand(Property):
|
||||||
"OverflowWrap",
|
"OverflowWrap",
|
||||||
"OverscrollBehavior",
|
"OverscrollBehavior",
|
||||||
"Percentage",
|
"Percentage",
|
||||||
"PositiveIntegerOrNone",
|
|
||||||
"PrintColorAdjust",
|
"PrintColorAdjust",
|
||||||
"Resize",
|
"Resize",
|
||||||
"RubyPosition",
|
"RubyPosition",
|
||||||
|
|
|
@ -38,7 +38,7 @@ use crate::selector_parser::PseudoElement;
|
||||||
use servo_arc::{Arc, RawOffsetArc, UniqueArc};
|
use servo_arc::{Arc, RawOffsetArc, UniqueArc};
|
||||||
use std::mem::{forget, MaybeUninit};
|
use std::mem::{forget, MaybeUninit};
|
||||||
use std::{cmp, ops, ptr};
|
use std::{cmp, ops, ptr};
|
||||||
use crate::values::{self, CustomIdent, Either, KeyframesName, None_};
|
use crate::values::{self, CustomIdent, KeyframesName};
|
||||||
use crate::values::computed::{Percentage, TransitionProperty};
|
use crate::values::computed::{Percentage, TransitionProperty};
|
||||||
use crate::values::computed::BorderStyle;
|
use crate::values::computed::BorderStyle;
|
||||||
use crate::values::computed::font::FontSize;
|
use crate::values::computed::font::FontSize;
|
||||||
|
@ -1127,9 +1127,7 @@ fn static_assert() {
|
||||||
${impl_copy_animation_value(ident, gecko_ffi_name)}
|
${impl_copy_animation_value(ident, gecko_ffi_name)}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<% skip_box_longhands= """display
|
<% skip_box_longhands= """display clear""" %>
|
||||||
clear
|
|
||||||
-webkit-line-clamp""" %>
|
|
||||||
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
||||||
|
@ -1169,28 +1167,6 @@ fn static_assert() {
|
||||||
gecko_inexhaustive=True,
|
gecko_inexhaustive=True,
|
||||||
) %>
|
) %>
|
||||||
${impl_keyword('clear', 'mBreakType', clear_keyword)}
|
${impl_keyword('clear', 'mBreakType', clear_keyword)}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub fn set__webkit_line_clamp(&mut self, v: longhands::_webkit_line_clamp::computed_value::T) {
|
|
||||||
self.gecko.mLineClamp = match v {
|
|
||||||
Either::First(n) => n.0 as u32,
|
|
||||||
Either::Second(None_) => 0,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
${impl_simple_copy('_webkit_line_clamp', 'mLineClamp')}
|
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
|
||||||
pub fn clone__webkit_line_clamp(&self) -> longhands::_webkit_line_clamp::computed_value::T {
|
|
||||||
match self.gecko.mLineClamp {
|
|
||||||
0 => Either::Second(None_),
|
|
||||||
n => {
|
|
||||||
debug_assert!(n <= std::i32::MAX as u32);
|
|
||||||
Either::First((n as i32).into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
<%def name="simple_image_array_property(name, shorthand, field_name)">
|
<%def name="simple_image_array_property(name, shorthand, field_name)">
|
||||||
|
|
|
@ -119,8 +119,6 @@
|
||||||
use crate::values::computed::{Context, ToComputedValue};
|
use crate::values::computed::{Context, ToComputedValue};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::values::{computed, specified};
|
use crate::values::{computed, specified};
|
||||||
#[allow(unused_imports)]
|
|
||||||
use crate::values::{Auto, Either, None_};
|
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,8 +412,6 @@
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::properties::{UnparsedValue, ShorthandId};
|
use crate::properties::{UnparsedValue, ShorthandId};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::values::{Auto, Either, None_};
|
|
||||||
#[allow(unused_imports)]
|
|
||||||
use crate::error_reporting::ParseErrorReporter;
|
use crate::error_reporting::ParseErrorReporter;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use crate::properties::longhands;
|
use crate::properties::longhands;
|
||||||
|
|
|
@ -547,16 +547,13 @@ ${helpers.predefined_type(
|
||||||
spec="https://compat.spec.whatwg.org/#touch-action",
|
spec="https://compat.spec.whatwg.org/#touch-action",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
// Note that we only implement -webkit-line-clamp as a single, longhand
|
|
||||||
// property for now, but the spec defines line-clamp as a shorthand for separate
|
|
||||||
// max-lines, block-ellipsis, and continue properties.
|
|
||||||
${helpers.predefined_type(
|
${helpers.predefined_type(
|
||||||
"-webkit-line-clamp",
|
"-webkit-line-clamp",
|
||||||
"PositiveIntegerOrNone",
|
"LineClamp",
|
||||||
"Either::Second(None_)",
|
"computed::LineClamp::none()",
|
||||||
engines="gecko",
|
engines="gecko",
|
||||||
gecko_pref="layout.css.webkit-line-clamp.enabled",
|
gecko_pref="layout.css.webkit-line-clamp.enabled",
|
||||||
animation_value_type="Integer",
|
animation_value_type="ComputedValue",
|
||||||
spec="https://drafts.csswg.org/css-overflow-3/#line-clamp",
|
spec="https://drafts.csswg.org/css-overflow-3/#line-clamp",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
@ -378,6 +378,7 @@ trivial_to_animated_value!(ComputedAngle);
|
||||||
trivial_to_animated_value!(ComputedUrl);
|
trivial_to_animated_value!(ComputedUrl);
|
||||||
trivial_to_animated_value!(bool);
|
trivial_to_animated_value!(bool);
|
||||||
trivial_to_animated_value!(f32);
|
trivial_to_animated_value!(f32);
|
||||||
|
trivial_to_animated_value!(i32);
|
||||||
// Note: This implementation is for ToAnimatedValue of ShapeSource.
|
// Note: This implementation is for ToAnimatedValue of ShapeSource.
|
||||||
//
|
//
|
||||||
// SVGPathData uses Box<[T]>. If we want to derive ToAnimatedValue for all the
|
// SVGPathData uses Box<[T]>. If we want to derive ToAnimatedValue for all the
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
|
|
||||||
//! Computed types for box properties.
|
//! Computed types for box properties.
|
||||||
|
|
||||||
|
use crate::values::animated::{Animate, Procedure};
|
||||||
use crate::values::computed::length::{LengthPercentage, NonNegativeLength};
|
use crate::values::computed::length::{LengthPercentage, NonNegativeLength};
|
||||||
use crate::values::computed::{Context, Number, ToComputedValue};
|
use crate::values::computed::{Context, Integer, Number, ToComputedValue};
|
||||||
use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||||
use crate::values::generics::box_::Perspective as GenericPerspective;
|
use crate::values::generics::box_::{GenericLineClamp, GenericPerspective, GenericVerticalAlign, GenericContainIntrinsicSize};
|
||||||
use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
|
||||||
use crate::values::generics::box_::ContainIntrinsicSize as GenericContainIntrinsicSize;
|
|
||||||
use crate::values::specified::box_ as specified;
|
use crate::values::specified::box_ as specified;
|
||||||
|
|
||||||
pub use crate::values::specified::box_::{
|
pub use crate::values::specified::box_::{
|
||||||
|
@ -30,6 +29,22 @@ pub type AnimationIterationCount = GenericAnimationIterationCount<Number>;
|
||||||
/// A computed value for the `contain-intrinsic-size` property.
|
/// A computed value for the `contain-intrinsic-size` property.
|
||||||
pub type ContainIntrinsicSize = GenericContainIntrinsicSize<NonNegativeLength>;
|
pub type ContainIntrinsicSize = GenericContainIntrinsicSize<NonNegativeLength>;
|
||||||
|
|
||||||
|
/// A computed value for the `line-clamp` property.
|
||||||
|
pub type LineClamp = GenericLineClamp<Integer>;
|
||||||
|
|
||||||
|
impl Animate for LineClamp {
|
||||||
|
#[inline]
|
||||||
|
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
|
||||||
|
if self.is_none() != other.is_none() {
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
if self.is_none() {
|
||||||
|
return Ok(Self::none())
|
||||||
|
}
|
||||||
|
Ok(Self(self.0.animate(&other.0, procedure)?.max(1)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl AnimationIterationCount {
|
impl AnimationIterationCount {
|
||||||
/// Returns the value `1.0`.
|
/// Returns the value `1.0`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
||||||
pub use self::border::{BorderImageSlice, BorderImageWidth};
|
pub use self::border::{BorderImageSlice, BorderImageWidth};
|
||||||
pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain, ContainerName, ContainerType};
|
pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain, ContainerName, ContainerType};
|
||||||
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, ContentVisibility, ContainIntrinsicSize, Float};
|
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, ContentVisibility, ContainIntrinsicSize, Float};
|
||||||
pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty};
|
pub use self::box_::{Display, LineClamp, Overflow, OverflowAnchor, TransitionProperty};
|
||||||
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
|
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
|
||||||
pub use self::box_::{ScrollAxis, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
|
pub use self::box_::{ScrollAxis, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
|
||||||
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName};
|
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName};
|
||||||
|
@ -101,7 +101,6 @@ pub use self::ui::{Cursor, MozForceBrokenImageIcon, UserSelect};
|
||||||
pub use super::specified::TextTransform;
|
pub use super::specified::TextTransform;
|
||||||
pub use super::specified::ViewportVariant;
|
pub use super::specified::ViewportVariant;
|
||||||
pub use super::specified::{BorderStyle, TextDecorationLine};
|
pub use super::specified::{BorderStyle, TextDecorationLine};
|
||||||
pub use super::{Auto, Either, None_};
|
|
||||||
pub use app_units::Au;
|
pub use app_units::Au;
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
|
@ -876,9 +875,6 @@ impl From<CSSInteger> for PositiveInteger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A computed positive `<integer>` value or `none`.
|
|
||||||
pub type PositiveIntegerOrNone = Either<PositiveInteger, None_>;
|
|
||||||
|
|
||||||
/// rect(...) | auto
|
/// rect(...) | auto
|
||||||
pub type ClipRect = generics::GenericClipRect<LengthOrAuto>;
|
pub type ClipRect = generics::GenericClipRect<LengthOrAuto>;
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,6 @@ pub enum GenericContainIntrinsicSize<L> {
|
||||||
pub use self::GenericContainIntrinsicSize as ContainIntrinsicSize;
|
pub use self::GenericContainIntrinsicSize as ContainIntrinsicSize;
|
||||||
|
|
||||||
impl<L: ToCss> ToCss for ContainIntrinsicSize<L> {
|
impl<L: ToCss> ToCss for ContainIntrinsicSize<L> {
|
||||||
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
where
|
where
|
||||||
W: Write,
|
W: Write,
|
||||||
|
@ -123,6 +122,55 @@ impl<L: ToCss> ToCss for ContainIntrinsicSize<L> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Note that we only implement -webkit-line-clamp as a single, longhand
|
||||||
|
/// property for now, but the spec defines line-clamp as a shorthand for
|
||||||
|
/// separate max-lines, block-ellipsis, and continue properties.
|
||||||
|
///
|
||||||
|
/// https://drafts.csswg.org/css-overflow-3/#line-clamp
|
||||||
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
ComputeSquaredDistance,
|
||||||
|
Copy,
|
||||||
|
Debug,
|
||||||
|
MallocSizeOf,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToAnimatedValue,
|
||||||
|
ToAnimatedZero,
|
||||||
|
ToResolvedValue,
|
||||||
|
ToShmem,
|
||||||
|
)]
|
||||||
|
#[repr(transparent)]
|
||||||
|
#[value_info(other_values = "auto")]
|
||||||
|
pub struct GenericLineClamp<I>(pub I);
|
||||||
|
|
||||||
|
pub use self::GenericLineClamp as LineClamp;
|
||||||
|
|
||||||
|
impl<I: crate::Zero> LineClamp<I> {
|
||||||
|
/// Returns the `none` value.
|
||||||
|
pub fn none() -> Self {
|
||||||
|
Self(crate::Zero::zero())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns whether we're the `none` value.
|
||||||
|
pub fn is_none(&self) -> bool {
|
||||||
|
self.0.is_zero()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I: crate::Zero + ToCss> ToCss for LineClamp<I> {
|
||||||
|
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||||
|
where
|
||||||
|
W: Write,
|
||||||
|
{
|
||||||
|
if self.is_none() {
|
||||||
|
return dest.write_str("none");
|
||||||
|
}
|
||||||
|
self.0.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-animations/#animation-iteration-count
|
/// https://drafts.csswg.org/css-animations/#animation-iteration-count
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone,
|
Clone,
|
||||||
|
@ -135,13 +183,15 @@ impl<L: ToCss> ToCss for ContainIntrinsicSize<L> {
|
||||||
ToResolvedValue,
|
ToResolvedValue,
|
||||||
ToShmem,
|
ToShmem,
|
||||||
)]
|
)]
|
||||||
pub enum AnimationIterationCount<Number> {
|
pub enum GenericAnimationIterationCount<Number> {
|
||||||
/// A `<number>` value.
|
/// A `<number>` value.
|
||||||
Number(Number),
|
Number(Number),
|
||||||
/// The `infinite` keyword.
|
/// The `infinite` keyword.
|
||||||
Infinite,
|
Infinite,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub use self::GenericAnimationIterationCount as AnimationIterationCount;
|
||||||
|
|
||||||
/// A generic value for the `perspective` property.
|
/// A generic value for the `perspective` property.
|
||||||
#[derive(
|
#[derive(
|
||||||
Animate,
|
Animate,
|
||||||
|
|
|
@ -48,9 +48,6 @@ pub fn normalize(v: CSSFloat) -> CSSFloat {
|
||||||
/// A CSS integer value.
|
/// A CSS integer value.
|
||||||
pub type CSSInteger = i32;
|
pub type CSSInteger = i32;
|
||||||
|
|
||||||
define_keyword_type!(None_, "none");
|
|
||||||
define_keyword_type!(Auto, "auto");
|
|
||||||
|
|
||||||
/// Serialize an identifier which is represented as an atom.
|
/// Serialize an identifier which is represented as an atom.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub fn serialize_atom_identifier<W>(ident: &Atom, dest: &mut W) -> fmt::Result
|
pub fn serialize_atom_identifier<W>(ident: &Atom, dest: &mut W) -> fmt::Result
|
||||||
|
|
|
@ -8,11 +8,10 @@ use crate::custom_properties::Name as CustomPropertyName;
|
||||||
use crate::parser::{Parse, ParserContext};
|
use crate::parser::{Parse, ParserContext};
|
||||||
use crate::properties::{LonghandId, PropertyDeclarationId};
|
use crate::properties::{LonghandId, PropertyDeclarationId};
|
||||||
use crate::properties::{PropertyId, ShorthandId};
|
use crate::properties::{PropertyId, ShorthandId};
|
||||||
use crate::values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
use crate::values::generics::box_::{GenericAnimationIterationCount, GenericPerspective, GenericLineClamp};
|
||||||
use crate::values::generics::box_::Perspective as GenericPerspective;
|
|
||||||
use crate::values::generics::box_::{GenericContainIntrinsicSize, GenericVerticalAlign, VerticalAlignKeyword};
|
use crate::values::generics::box_::{GenericContainIntrinsicSize, GenericVerticalAlign, VerticalAlignKeyword};
|
||||||
use crate::values::specified::length::{LengthPercentage, NonNegativeLength};
|
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::values::{CustomIdent, KeyframesName, TimelineName};
|
||||||
use crate::Atom;
|
use crate::Atom;
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
|
@ -615,6 +614,9 @@ impl Debug for Display {
|
||||||
/// A specified value for the `contain-intrinsic-size` property.
|
/// A specified value for the `contain-intrinsic-size` property.
|
||||||
pub type ContainIntrinsicSize = GenericContainIntrinsicSize<NonNegativeLength>;
|
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.
|
/// A specified value for the `vertical-align` property.
|
||||||
pub type VerticalAlign = GenericVerticalAlign<LengthPercentage>;
|
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
|
/// https://drafts.csswg.org/css-contain-2/#content-visibility
|
||||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
|
@ -13,7 +13,7 @@ use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as Generic
|
||||||
use super::generics::grid::{TrackList as GenericTrackList, TrackSize as GenericTrackSize};
|
use super::generics::grid::{TrackList as GenericTrackList, TrackSize as GenericTrackSize};
|
||||||
use super::generics::transform::IsParallelTo;
|
use super::generics::transform::IsParallelTo;
|
||||||
use super::generics::{self, GreaterThanOrEqualToOne, NonNegative};
|
use super::generics::{self, GreaterThanOrEqualToOne, NonNegative};
|
||||||
use super::{CSSFloat, CSSInteger, Either, None_};
|
use super::{CSSFloat, CSSInteger};
|
||||||
use crate::context::QuirksMode;
|
use crate::context::QuirksMode;
|
||||||
use crate::parser::{Parse, ParserContext};
|
use crate::parser::{Parse, ParserContext};
|
||||||
use crate::values::serialize_atom_identifier;
|
use crate::values::serialize_atom_identifier;
|
||||||
|
@ -38,7 +38,7 @@ pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
|
||||||
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
|
pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
|
||||||
pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain, Display};
|
pub use self::box_::{AnimationIterationCount, AnimationName, AnimationTimeline, Contain, Display};
|
||||||
pub use self::box_::{Appearance, BreakBetween, BreakWithin, ContainerName, ContainerType};
|
pub use self::box_::{Appearance, BreakBetween, BreakWithin, ContainerName, ContainerType};
|
||||||
pub use self::box_::{Clear, ContentVisibility, ContainIntrinsicSize, Float, Overflow, OverflowAnchor};
|
pub use self::box_::{Clear, ContentVisibility, ContainIntrinsicSize, LineClamp, Float, Overflow, OverflowAnchor};
|
||||||
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
|
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter};
|
||||||
pub use self::box_::{ScrollAxis, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
|
pub use self::box_::{ScrollAxis, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop};
|
||||||
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName};
|
pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName};
|
||||||
|
@ -708,9 +708,6 @@ impl Parse for PositiveInteger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A specified positive `<integer>` value or `none`.
|
|
||||||
pub type PositiveIntegerOrNone = Either<PositiveInteger, None_>;
|
|
||||||
|
|
||||||
/// The specified value of a grid `<track-breadth>`
|
/// The specified value of a grid `<track-breadth>`
|
||||||
pub type TrackBreadth = GenericTrackBreadth<LengthPercentage>;
|
pub type TrackBreadth = GenericTrackBreadth<LengthPercentage>;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue