style: Part 10: Make source and scroll-offsets accept only default value

Based on our previous patches, we only support default behavior for
source and scroll-offsets:
1. source:auto
2. scroll-offsets: none
3. scroll-offsets: auto, auto, ...

So update the parser for them. We expect to remove whole
@scroll-timeline in Bug 1733260, so now only do a tiny update in parser.

Differential Revision: https://phabricator.services.mozilla.com/D132417
This commit is contained in:
Boris Chiou 2023-06-06 15:27:39 +02:00 committed by Oriol Brufau
parent e66bcf2cc5
commit 9430287183

View file

@ -157,15 +157,19 @@ impl<'a, 'b, 'i> DeclarationParser<'i> for ScrollTimelineDescriptorsParser<'a, '
/// The scroll-timeline source.
///
/// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-source
// FIXME: Bug 1733260 may drop the entire @scroll-timeline, and now we don't support source other
// than the default value (so use #[css(skip)]).
#[derive(Clone, Debug, Parse, PartialEq, ToCss, ToShmem)]
pub enum Source {
/// The scroll container.
#[css(skip)]
Selector(ScrollTimelineSelector),
/// The initial value. The scrollingElement of the Document associated with the Window that is
/// the current global object.
Auto,
/// Null. However, it's not clear what is the expected behavior of this. See the spec issue:
/// https://drafts.csswg.org/scroll-animations/#issue-0d1e73bd
#[css(skip)]
None,
}
@ -215,7 +219,7 @@ pub struct ScrollOffsets(#[css(if_empty = "none", iterable)] Box<[ScrollTimeline
impl Parse for ScrollOffsets {
fn parse<'i, 't>(
context: &ParserContext,
_context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if input.try_parse(|i| i.expect_ident_matching("none")).is_ok() {
@ -224,7 +228,7 @@ impl Parse for ScrollOffsets {
Ok(ScrollOffsets(
input
.parse_comma_separated(|i| ScrollTimelineOffset::parse(context, i))?
.parse_comma_separated(|i| ScrollTimelineOffset::parse(i))?
.into_boxed_slice(),
))
}
@ -234,14 +238,18 @@ impl Parse for ScrollOffsets {
/// value: auto | <length-percentage> | <element-offset>
///
/// https://drafts.csswg.org/scroll-animations/#typedef-scroll-timeline-offset
// FIXME: Bug 1733260 may drop the entire @scroll-timeline, and now we don't support
// <scroll-timeline-offset> other than the default value (so use #[css(skip)]).
#[derive(Clone, Debug, Parse, PartialEq, ToCss, ToShmem)]
pub enum ScrollTimelineOffset {
/// The initial value. A container-based offset.
Auto,
/// A container-based offset with the distance indicated by the value along source's scroll
/// range in orientation.
#[css(skip)]
LengthPercentage(LengthPercentage),
/// An element-based offset.
#[css(skip)]
ElementOffset(ElementOffset),
}