diff --git a/components/style/invalidation/stylesheets.rs b/components/style/invalidation/stylesheets.rs index fc39b8cca76..1d1111170ed 100644 --- a/components/style/invalidation/stylesheets.rs +++ b/components/style/invalidation/stylesheets.rs @@ -619,11 +619,12 @@ impl StylesheetInvalidationSet { // existing elements. } }, - ScrollTimeline(..) => { - // TODO: Bug 1676784: check if animation-timeline name is referenced. - // Now we do nothing. - }, - CounterStyle(..) | Page(..) | Viewport(..) | FontFeatureValues(..) => { + // TODO: Check if timeline name is referenced, though this might go away in bug 1737918. + ScrollTimeline(..) | + CounterStyle(..) | + Page(..) | + Viewport(..) | + FontFeatureValues(..) => { debug!( " > Found unsupported rule, marking the whole subtree \ invalid." diff --git a/components/style/matching.rs b/components/style/matching.rs index f81f9c3a233..9b267cd8b46 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -277,7 +277,7 @@ trait PrivateMatchMethods: TElement { let old_box_style = old_style.get_box(); - let keyframes_could_have_changed = context + let keyframes_or_timeline_could_have_changed = context .shared .traversal_flags .contains(TraversalFlags::ForCSSRuleChanges); @@ -287,9 +287,9 @@ trait PrivateMatchMethods: TElement { // element has or will have CSS animation style regardless of whether // the animation is running or not. // - // TODO: We should check which @keyframes were added/changed/deleted and - // update only animations corresponding to those @keyframes. - if keyframes_could_have_changed { + // TODO: We should check which @keyframes/@scroll-timeline were added/changed/deleted and + // update only animations corresponding to those @keyframes/@scroll-timeline. + if keyframes_or_timeline_could_have_changed { return true; } diff --git a/components/style/stylist.rs b/components/style/stylist.rs index a5538aa1189..a48a7103f84 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -30,7 +30,9 @@ use crate::stylesheets::keyframes_rule::KeyframesAnimation; use crate::stylesheets::layer_rule::{LayerId, LayerName, LayerOrder}; use crate::stylesheets::viewport_rule::{self, MaybeNew, ViewportRule}; #[cfg(feature = "gecko")] -use crate::stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule}; +use crate::stylesheets::{ + CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule, ScrollTimelineRule, +}; use crate::stylesheets::{ CssRule, EffectiveRulesIterator, Origin, OriginSet, PerOrigin, PerOriginIter, }; @@ -1542,6 +1544,10 @@ pub struct ExtraStyleData { /// A map of effective page rules. #[cfg(feature = "gecko")] pub pages: Vec>>, + + /// A map of effective scroll-timeline rules. + #[cfg(feature = "gecko")] + pub scroll_timelines: PrecomputedHashMap>>, } #[cfg(feature = "gecko")] @@ -1570,6 +1576,18 @@ impl ExtraStyleData { fn add_page(&mut self, rule: &Arc>) { self.pages.push(rule.clone()); } + + /// Add the given @scroll-timeline rule. + fn add_scroll_timeline( + &mut self, + guard: &SharedRwLockReadGuard, + rule: &Arc>, + )-> Result<(), FailedAllocationError> { + let name = rule.read_with(guard).name.as_atom().clone(); + self.scroll_timelines + .try_insert(name, rule.clone()) + .map(|_| {}) + } } impl ExtraStyleData { @@ -1580,6 +1598,7 @@ impl ExtraStyleData { self.font_feature_values.clear(); self.counter_styles.clear(); self.pages.clear(); + self.scroll_timelines.clear(); } } } @@ -1604,6 +1623,7 @@ impl MallocSizeOf for ExtraStyleData { n += self.font_feature_values.shallow_size_of(ops); n += self.counter_styles.shallow_size_of(ops); n += self.pages.shallow_size_of(ops); + n += self.scroll_timelines.shallow_size_of(ops); n } } @@ -2351,12 +2371,10 @@ impl CascadeData { } }, #[cfg(feature = "gecko")] - CssRule::ScrollTimeline(..) => { - // TODO: Bug 1676791: set the timeline into animation. - // https://phabricator.services.mozilla.com/D126452 - // + CssRule::ScrollTimeline(ref rule) => { // Note: Bug 1733260: we may drop @scroll-timeline rule once this spec issue // https://github.com/w3c/csswg-drafts/issues/6674 gets landed. + self.extra_data.add_scroll_timeline(guard, rule)?; }, #[cfg(feature = "gecko")] CssRule::FontFace(ref rule) => {