mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Add scroll() to animation-timeline for style system
scroll() is defined in the spec proposal, and there is a temporary spec: https://drafts.csswg.org/scroll-animations-1/rewrite#scroll-notation. The spec is still under development, so we don't drop the orignal scroll-timeline at rule. Instead, we add a new scroll() notation to animation-timeline, and support both syntax for now. Differential Revision: https://phabricator.services.mozilla.com/D143417
This commit is contained in:
parent
f981596622
commit
3b174e376e
1 changed files with 91 additions and 0 deletions
|
@ -723,6 +723,80 @@ impl Parse for AnimationName {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A value for the <Scroller> used in scroll().
|
||||||
|
///
|
||||||
|
/// https://drafts.csswg.org/scroll-animations-1/rewrite#typedef-scroller
|
||||||
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
Hash,
|
||||||
|
MallocSizeOf,
|
||||||
|
Parse,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
|
ToResolvedValue,
|
||||||
|
ToShmem,
|
||||||
|
)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum Scroller {
|
||||||
|
/// The nearest ancestor scroll container. (Default.)
|
||||||
|
Nearest,
|
||||||
|
/// The document viewport as the scroll container.
|
||||||
|
Root,
|
||||||
|
// FIXME: Bug 1764450: Once we support container-name CSS property (Bug 1744224), we may add
|
||||||
|
// <custom-ident> here, based on the result of the spec issue:
|
||||||
|
// https://github.com/w3c/csswg-drafts/issues/7046
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Scroller {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Nearest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A value for the <Axis> used in scroll().
|
||||||
|
///
|
||||||
|
/// https://drafts.csswg.org/scroll-animations-1/rewrite#typedef-axis
|
||||||
|
#[derive(
|
||||||
|
Clone,
|
||||||
|
Debug,
|
||||||
|
Eq,
|
||||||
|
Hash,
|
||||||
|
MallocSizeOf,
|
||||||
|
Parse,
|
||||||
|
PartialEq,
|
||||||
|
SpecifiedValueInfo,
|
||||||
|
ToComputedValue,
|
||||||
|
ToCss,
|
||||||
|
ToResolvedValue,
|
||||||
|
ToShmem,
|
||||||
|
)]
|
||||||
|
#[repr(u8)]
|
||||||
|
pub enum ScrollAxis {
|
||||||
|
/// The block axis of the scroll container. (Default.)
|
||||||
|
Block,
|
||||||
|
/// The inline axis of the scroll container.
|
||||||
|
Inline,
|
||||||
|
/// The vertical block axis of the scroll container.
|
||||||
|
Vertical,
|
||||||
|
/// The horizontal axis of the scroll container.
|
||||||
|
Horizontal,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ScrollAxis {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Block
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn is_default<T: Default + PartialEq>(value: &T) -> bool {
|
||||||
|
*value == Default::default()
|
||||||
|
}
|
||||||
|
|
||||||
/// A value for the <single-animation-timeline>.
|
/// A value for the <single-animation-timeline>.
|
||||||
///
|
///
|
||||||
/// https://drafts.csswg.org/css-animations-2/#typedef-single-animation-timeline
|
/// https://drafts.csswg.org/css-animations-2/#typedef-single-animation-timeline
|
||||||
|
@ -748,6 +822,13 @@ pub enum AnimationTimeline {
|
||||||
None,
|
None,
|
||||||
/// The scroll-timeline name
|
/// The scroll-timeline name
|
||||||
Timeline(TimelineName),
|
Timeline(TimelineName),
|
||||||
|
/// The scroll() notation
|
||||||
|
/// https://drafts.csswg.org/scroll-animations-1/rewrite#scroll-notation
|
||||||
|
#[css(function)]
|
||||||
|
Scroll(
|
||||||
|
#[css(skip_if = "is_default")] ScrollAxis,
|
||||||
|
#[css(skip_if = "is_default")] Scroller,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnimationTimeline {
|
impl AnimationTimeline {
|
||||||
|
@ -780,6 +861,16 @@ impl Parse for AnimationTimeline {
|
||||||
return Ok(Self::None);
|
return Ok(Self::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://drafts.csswg.org/scroll-animations-1/rewrite#scroll-notation
|
||||||
|
if input.try_parse(|i| i.expect_function_matching("scroll")).is_ok() {
|
||||||
|
return input.parse_nested_block(|i| {
|
||||||
|
Ok(Self::Scroll(
|
||||||
|
i.try_parse(ScrollAxis::parse).unwrap_or(ScrollAxis::Block),
|
||||||
|
i.try_parse(Scroller::parse).unwrap_or(Scroller::Nearest),
|
||||||
|
))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
TimelineName::parse(context, input).map(AnimationTimeline::Timeline)
|
TimelineName::parse(context, input).map(AnimationTimeline::Timeline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue