style: Part 1: Add animation-timeline longhand property in style system

This patch adds the animation-timeline longhand property. For
shorthand, we will do that in the next patch.

This patch includes the aut-generated code in
devtools/shared/css/generated/properties-db.js, by `./mach devtools-css-db`.

Note:
1. we will use this property in Bug 1676791. For now, only make sure
   we parse it and serialize it correctly.
2. The syntax of animation-timeline may be updated, based on the spec
   issue: https://github.com/w3c/csswg-drafts/issues/6674.
   However, it's not a big problem to update it later, so we still can
   prototype this property based on the current version of spec.

Differential Revision: https://phabricator.services.mozilla.com/D126450
This commit is contained in:
Boris Chiou 2023-05-27 15:04:42 +02:00 committed by Oriol Brufau
parent 7d8a87cd01
commit 2a7436481c
9 changed files with 108 additions and 14 deletions

View file

@ -13,7 +13,7 @@ use crate::values::generics::box_::Perspective as GenericPerspective;
use crate::values::generics::box_::{GenericVerticalAlign, VerticalAlignKeyword};
use crate::values::specified::length::{LengthPercentage, NonNegativeLength};
use crate::values::specified::{AllowQuirks, Number};
use crate::values::{CustomIdent, KeyframesName};
use crate::values::{CustomIdent, KeyframesName, TimelineName};
use crate::Atom;
use cssparser::Parser;
use num_traits::FromPrimitive;
@ -762,6 +762,62 @@ impl Parse for AnimationName {
}
}
/// A value for the <single-animation-timeline>.
///
/// https://drafts.csswg.org/css-animations-2/#typedef-single-animation-timeline
/// cbindgen:private-default-tagged-enum-constructor=false
#[derive(
Clone,
Debug,
Eq,
Hash,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C, u8)]
pub enum AnimationTimeline {
/// Use default timeline. The animations timeline is a DocumentTimeline.
Auto,
/// The animation is not associated with a timeline.
None,
/// The scroll-timeline name
Timeline(TimelineName),
}
impl AnimationTimeline {
/// Returns the `auto` value.
pub fn auto() -> Self {
Self::Auto
}
}
impl Parse for AnimationTimeline {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
// We are using the same parser for TimelineName and KeyframesName, but animation-timeline
// accepts "auto", so need to manually parse this. (We can not derive Parse because
// TimelineName excludes only "none" keyword.)
// FIXME: Bug 1733260: we may drop None based on the spec issue:
// Note: https://github.com/w3c/csswg-drafts/issues/6674.
if input.try_parse(|i| i.expect_ident_matching("auto")).is_ok() {
return Ok(Self::Auto);
}
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
return Ok(Self::None);
}
TimelineName::parse(context, input).map(AnimationTimeline::Timeline)
}
}
/// https://drafts.csswg.org/css-scroll-snap-1/#snap-axis
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]