style: Support scroll-timeline-name longhand in style system

Implement "scroll-timeline-name: none | <custom-ident>".

Differential Revision: https://phabricator.services.mozilla.com/D146018
This commit is contained in:
Boris Chiou 2022-06-13 20:26:44 +00:00 committed by Martin Robinson
parent 105050d46d
commit 8d8594ef86
6 changed files with 65 additions and 6 deletions

View file

@ -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,
)}

View file

@ -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.

View file

@ -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;

View file

@ -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())

View file

@ -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<Self, ParseError<'i>> {
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))]

View file

@ -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;