diff --git a/components/style/properties/longhands/ui.mako.rs b/components/style/properties/longhands/ui.mako.rs index 8d4bbab038c..81b9f0ba2c1 100644 --- a/components/style/properties/longhands/ui.mako.rs +++ b/components/style/properties/longhands/ui.mako.rs @@ -304,3 +304,14 @@ ${helpers.predefined_type( spec="https://drafts.csswg.org/css-animations-2/#propdef-animation-timeline", rule_types_allowed=DEFAULT_RULES_EXCEPT_KEYFRAME, )} + +${helpers.predefined_type( + "scroll-timeline-name", + "ScrollTimelineName", + "computed::ScrollTimelineName::none()", + engines="gecko", + animation_value_type="none", + gecko_pref="layout.css.scroll-linked-animations.enabled", + spec="https://github.com/w3c/csswg-drafts/issues/6674", + rule_types_allowed=DEFAULT_RULES_EXCEPT_KEYFRAME, +)} diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index f05870d6ead..9207b2e5ef0 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -14,10 +14,9 @@ use crate::values::specified::box_ as specified; pub use crate::values::specified::box_::{ AnimationName, AnimationTimeline, Appearance, BreakBetween, BreakWithin, Clear as SpecifiedClear, Contain, ContainerName, ContainerType, ContentVisibility, Display, - Float as SpecifiedFloat, Overflow, OverflowAnchor, OverflowClipBox, - OverscrollBehavior, ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop, - ScrollSnapStrictness, ScrollSnapType, ScrollbarGutter, TouchAction, - TransitionProperty, WillChange, + Float as SpecifiedFloat, Overflow, OverflowAnchor, OverflowClipBox, OverscrollBehavior, + ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop, ScrollSnapStrictness, ScrollSnapType, + ScrollTimelineName, ScrollbarGutter, TouchAction, TransitionProperty, WillChange, }; /// A computed value for the `vertical-align` property. diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 68256cdd20f..b9cebd60159 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -50,7 +50,7 @@ pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, ContentVisibi pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter}; pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop}; -pub use self::box_::{ScrollSnapStrictness, ScrollSnapType}; +pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName}; pub use self::box_::{TouchAction, VerticalAlign, WillChange}; pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, ColorScheme, PrintColorAdjust}; pub use self::column::ColumnCount; diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index e221619c843..5db6d2555e8 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -586,6 +586,12 @@ pub trait IsAuto { pub struct TimelineName(TimelineOrKeyframesName); impl TimelineName { + /// Create a new TimelineName from Atom. + #[cfg(feature = "gecko")] + pub fn from_atom(atom: Atom) -> Self { + Self(TimelineOrKeyframesName::from_atom(atom)) + } + /// Returns the `none` value. pub fn none() -> Self { Self(TimelineOrKeyframesName::none()) diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 3a6677de42a..2749b70c57d 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -874,6 +874,49 @@ impl Parse for AnimationTimeline { } } +/// A value for the scroll-timeline-name. +/// +/// Note: The spec doesn't mention `auto` for scroll-timeline-name. However, `auto` is a keyword in +/// animation-timeline, so we reject `auto` for scroll-timeline-name now. +/// +/// https://drafts.csswg.org/scroll-animations-1/rewrite#scroll-timeline-name +#[derive( + Clone, + Debug, + Eq, + Hash, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] +#[repr(C)] +pub struct ScrollTimelineName(pub TimelineName); + +impl ScrollTimelineName { + /// Returns the `none` value. + pub fn none() -> Self { + Self(TimelineName::none()) + } +} + +impl Parse for ScrollTimelineName { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + if let Ok(name) = input.try_parse(|input| TimelineName::parse(context, input)) { + return Ok(Self(name)); + } + + input.expect_ident_matching("none")?; + Ok(Self(TimelineName::none())) + } +} + /// https://drafts.csswg.org/css-scroll-snap-1/#snap-axis #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index c06386ef97d..a13167c7f38 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -41,7 +41,7 @@ pub use self::box_::{Appearance, BreakBetween, BreakWithin, ContainerName, Conta pub use self::box_::{Clear, ContentVisibility, Float, Overflow, OverflowAnchor}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize, ScrollbarGutter}; pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStop}; -pub use self::box_::{ScrollSnapStrictness, ScrollSnapType}; +pub use self::box_::{ScrollSnapStrictness, ScrollSnapType, ScrollTimelineName}; pub use self::box_::{TouchAction, TransitionProperty, VerticalAlign, WillChange}; pub use self::color::{Color, ColorOrAuto, ColorPropertyValue, ColorScheme, PrintColorAdjust}; pub use self::column::ColumnCount;