From b297c10fbf03382b067073532513393a4a0cd9f8 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Sat, 27 May 2023 07:58:22 +0200 Subject: [PATCH] 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 --- components/style/gecko/arc_types.rs | 21 ++++++++++--------- .../style/stylesheets/scroll_timeline_rule.rs | 14 ++++++++++++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/components/style/gecko/arc_types.rs b/components/style/gecko/arc_types.rs index 788f75f2b2f..05fcdb5b12d 100644 --- a/components/style/gecko/arc_types.rs +++ b/components/style/gecko/arc_types.rs @@ -10,13 +10,11 @@ use crate::gecko::url::CssUrlData; use crate::gecko_bindings::structs::{ - RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData, - RawServoDeclarationBlock, RawServoFontFaceRule, - RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe, - RawServoKeyframesRule, RawServoLayerRule, RawServoMediaList, - RawServoMediaRule, RawServoMozDocumentRule, RawServoNamespaceRule, - RawServoPageRule, RawServoStyleRule, RawServoStyleSheetContents, - RawServoSupportsRule, ServoCssRules + RawServoAnimationValue, RawServoCounterStyleRule, RawServoCssUrlData, RawServoDeclarationBlock, + RawServoFontFaceRule, RawServoFontFeatureValuesRule, RawServoImportRule, RawServoKeyframe, + RawServoKeyframesRule, RawServoLayerRule, RawServoMediaList, RawServoMediaRule, + RawServoMozDocumentRule, RawServoNamespaceRule, RawServoPageRule, RawServoScrollTimelineRule, + RawServoStyleRule, RawServoStyleSheetContents, RawServoSupportsRule, ServoCssRules, }; use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong}; use crate::media_queries::MediaList; @@ -25,9 +23,9 @@ use crate::properties::{ComputedValues, PropertyDeclarationBlock}; use crate::shared_lock::Locked; use crate::stylesheets::keyframes_rule::Keyframe; use crate::stylesheets::{ - CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule, - DocumentRule, ImportRule, KeyframesRule, LayerRule, MediaRule, - NamespaceRule, PageRule, StyleRule, StylesheetContents, SupportsRule + CounterStyleRule, CssRules, DocumentRule, FontFaceRule, FontFeatureValuesRule, ImportRule, + KeyframesRule, LayerRule, MediaRule, NamespaceRule, PageRule, ScrollTimelineRule, StyleRule, + StylesheetContents, SupportsRule, }; use servo_arc::{Arc, ArcBorrow}; use std::{mem, ptr}; @@ -90,6 +88,9 @@ impl_arc_ffi!(Locked => RawServoNamespaceRule impl_arc_ffi!(Locked => RawServoPageRule [Servo_PageRule_AddRef, Servo_PageRule_Release]); +impl_arc_ffi!(Locked => RawServoScrollTimelineRule + [Servo_ScrollTimelineRule_AddRef, Servo_ScrollTimelineRule_Release]); + impl_arc_ffi!(Locked => RawServoSupportsRule [Servo_SupportsRule_AddRef, Servo_SupportsRule_Release]); diff --git a/components/style/stylesheets/scroll_timeline_rule.rs b/components/style/stylesheets/scroll_timeline_rule.rs index f11e469f958..bbc5d9caf8f 100644 --- a/components/style/stylesheets/scroll_timeline_rule.rs +++ b/components/style/stylesheets/scroll_timeline_rule.rs @@ -169,6 +169,12 @@ pub enum Source { None, } +impl Default for Source { + fn default() -> Self { + Source::Auto + } +} + /// The scroll-timeline orientation. /// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-orientation /// @@ -189,11 +195,17 @@ pub enum Orientation { Vertical, } +impl Default for Orientation { + fn default() -> Self { + Orientation::Auto + } +} + /// Scroll-timeline offsets. We treat None as an empty vector. /// value: none | # /// /// https://drafts.csswg.org/scroll-animations/#descdef-scroll-timeline-scroll-offsets -#[derive(Clone, Debug, ToCss, ToShmem)] +#[derive(Clone, Default, Debug, ToCss, ToShmem)] #[css(comma)] pub struct ScrollOffsets(#[css(if_empty = "none", iterable)] Box<[ScrollTimelineOffset]>);