style: Part 3: Add CSSScrollTimelineRule for CSSOM

Implement CSSScrollTimelineRule CSSOM API.
https://drafts.csswg.org/scroll-animations-1/#the-css-scroll-timeline-rule-interface

We rely on the CSSOM API for testing. However, the wpt doesn't match the
current spec and it has some errors. We update the wpt and enable the
preference for testing in the next patch.

Differential Revision: https://phabricator.services.mozilla.com/D125766
This commit is contained in:
Boris Chiou 2023-05-27 07:58:22 +02:00 committed by Oriol Brufau
parent 2a11460915
commit b297c10fbf
2 changed files with 24 additions and 11 deletions

View file

@ -10,13 +10,11 @@
use crate::gecko::url::CssUrlData; use crate::gecko::url::CssUrlData;
use crate::gecko_bindings::structs::{ use crate::gecko_bindings::structs::{
RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData, RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData, RawServoDeclarationBlock,
RawServoDeclarationBlock, RawServoFontFaceRule, RawServoFontFaceRule, RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe,
RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe, RawServoKeyframesRule, RawServoLayerRule, RawServoMediaList, RawServoMediaRule,
RawServoKeyframesRule, RawServoLayerRule, RawServoMediaList, RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule, RawServoScrollTimelineRule,
RawServoMediaRule, RawServoMozDocumentRule, RawServoNamespaceRule, RawServoStyleRule, RawServoStyleSheetContents, RawServoSupportsRule, ServoCssRules,
RawServoPageRule, RawServoStyleRule, RawServoStyleSheetContents,
RawServoSupportsRule, ServoCssRules
}; };
use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
use crate::media_queries::MediaList; use crate::media_queries::MediaList;
@ -25,9 +23,9 @@ use crate::properties::{ComputedValues, PropertyDeclarationBlock};
use crate::shared_lock::Locked; use crate::shared_lock::Locked;
use crate::stylesheets::keyframes_rule::Keyframe; use crate::stylesheets::keyframes_rule::Keyframe;
use crate::stylesheets::{ use crate::stylesheets::{
CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule, CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule,
DocumentRule, ImportRule, KeyframesRule, LayerRule, MediaRule, KeyframesRule, LayerRule, MediaRule, NamespaceRule, PageRule, ScrollTimelineRule, StyleRule,
NamespaceRule, PageRule, StyleRule, StylesheetContents, SupportsRule StylesheetContents, SupportsRule,
}; };
use servo_arc::{Arc, ArcBorrow}; use servo_arc::{Arc, ArcBorrow};
use std::{mem, ptr}; use std::{mem, ptr};
@ -90,6 +88,9 @@ impl_arc_ffi!(Locked<NamespaceRule> => RawServoNamespaceRule
impl_arc_ffi!(Locked<PageRule> => RawServoPageRule impl_arc_ffi!(Locked<PageRule> => RawServoPageRule
[Servo_PageRule_AddRef, Servo_PageRule_Release]); [Servo_PageRule_AddRef, Servo_PageRule_Release]);
impl_arc_ffi!(Locked<ScrollTimelineRule> => RawServoScrollTimelineRule
[Servo_ScrollTimelineRule_AddRef, Servo_ScrollTimelineRule_Release]);
impl_arc_ffi!(Locked<SupportsRule> => RawServoSupportsRule impl_arc_ffi!(Locked<SupportsRule> => RawServoSupportsRule
[Servo_SupportsRule_AddRef, Servo_SupportsRule_Release]); [Servo_SupportsRule_AddRef, Servo_SupportsRule_Release]);

View file

@ -169,6 +169,12 @@ pub enum Source {
None, None,
} }
impl Default for Source {
fn default() -> Self {
Source::Auto
}
}
/// The scroll-timeline orientation. /// The scroll-timeline orientation.
/// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-orientation /// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-orientation
/// ///
@ -189,11 +195,17 @@ pub enum Orientation {
Vertical, Vertical,
} }
impl Default for Orientation {
fn default() -> Self {
Orientation::Auto
}
}
/// Scroll-timeline offsets. We treat None as an empty vector. /// Scroll-timeline offsets. We treat None as an empty vector.
/// value: none | <scroll-timeline-offset># /// value: none | <scroll-timeline-offset>#
/// ///
/// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-scroll-offsets /// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-scroll-offsets
#[derive(Clone, Debug, ToCss, ToShmem)] #[derive(Clone, Default, Debug, ToCss, ToShmem)]
#[css(comma)] #[css(comma)]
pub struct ScrollOffsets(#[css(if_empty = "none", iterable)] Box<[ScrollTimelineOffset]>); pub struct ScrollOffsets(#[css(if_empty = "none", iterable)] Box<[ScrollTimelineOffset]>);