From 021d94bbd9ddefa34faaa05c03ef55d16064e3f7 Mon Sep 17 00:00:00 2001 From: ldm0 Date: Wed, 25 Nov 2026 22:44:20 +0800 Subject: [PATCH 1/3] Expose Stylo restyling for a single element --- style/traversal.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/style/traversal.rs b/style/traversal.rs index 0d9fa7e16d..33e54a772c 100644 --- a/style/traversal.rs +++ b/style/traversal.rs @@ -377,7 +377,7 @@ pub fn recalc_style_at( // Compute style for this element if necessary. if let Some(restyle_kind) = restyle_kind { - child_restyle_hint = compute_style(context, element, data, restyle_kind); + child_restyle_hint = restyle_element(context, element, data, restyle_kind); if !element.matches_user_and_content_rules() { // We must always cascade native anonymous subtrees, since they @@ -483,7 +483,12 @@ where } } -fn compute_style( +/// Apply the restyle kind selected by `ElementData::restyle_kind` to one element. +/// +/// The caller resolves the element's ancestors first and sets the current DOM +/// depth for selector matching. The returned hint describes work for the +/// children. The caller owns hint propagation, traversal and damage consumption. +pub fn restyle_element( context: &mut StyleContext, element: E, data: &mut ElementData, From 5aca06381f726d289acef01f06cf7871fc477c7c Mon Sep 17 00:00:00 2001 From: ldm0 Date: Wed, 25 Nov 2026 23:07:50 +0800 Subject: [PATCH 2/3] Let Servo embedders own animation updates during restyle --- style/matching.rs | 23 ++++++++++++++++------- style/traversal_flags.rs | 4 ++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/style/matching.rs b/style/matching.rs index e025e1a6e8..f101b13fe6 100644 --- a/style/matching.rs +++ b/style/matching.rs @@ -18,9 +18,9 @@ use crate::dom::TElement; #[cfg(feature = "servo")] use crate::dom::TNode; use crate::invalidation::element::restyle_hints::RestyleHint; +use crate::properties::longhands::display::computed_value::T as Display; use crate::properties::ComputedValues; use crate::properties::PropertyDeclarationBlock; -use crate::properties::longhands::display::computed_value::T as Display; #[cfg(feature = "servo")] use crate::rule_tree::RuleCascadeFlags; use crate::rule_tree::{CascadeLevel, CascadeOrigin, StrongRuleNode}; @@ -1010,12 +1010,21 @@ pub trait MatchMethods: TElement { mut new_styles: ResolvedElementStyles, important_rules_changed: bool, ) -> RestyleHint { - self.process_animations( - context, - &mut data.styles, - &mut new_styles, - important_rules_changed, - ); + #[cfg(feature = "servo")] + let update_animations = !context + .shared + .traversal_flags + .contains(TraversalFlags::SkipAnimationUpdates); + #[cfg(feature = "gecko")] + let update_animations = true; + if update_animations { + self.process_animations( + context, + &mut data.styles, + &mut new_styles, + important_rules_changed, + ); + } let root_font_relative_state_changed = new_styles.root_font_relative_state_changed(); diff --git a/style/traversal_flags.rs b/style/traversal_flags.rs index 54972043fd..cc934e00ef 100644 --- a/style/traversal_flags.rs +++ b/style/traversal_flags.rs @@ -28,6 +28,10 @@ bitflags! { /// unconditionally tick and process them. const FlushThrottledAnimations = 1 << 8; + /// The embedder owns the animation timeline and resolves base styles here. + #[cfg(feature = "servo")] + const SkipAnimationUpdates = 1 << 9; + } } From 7d0ac9860db0ef65b71066ce73814693eddabb81 Mon Sep 17 00:00:00 2001 From: ldm0 Date: Wed, 25 Nov 2026 18:54:19 +0800 Subject: [PATCH 3/3] test(cssom): assert all serialization independently of enabled longhands --- style/moli_declaration_block.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/style/moli_declaration_block.rs b/style/moli_declaration_block.rs index c61c212499..f06e63cbd5 100644 --- a/style/moli_declaration_block.rs +++ b/style/moli_declaration_block.rs @@ -546,8 +546,6 @@ mod tests { fn parsed_values_match_declaration_block_serialization() { with_detached_style_context(|context| { for (name, value) in [ - ("all", "inherit"), - ("all", "var(--shared, revert-layer)"), ("width", "var(--width, 2px)"), ("padding", "1px 2px 3px 4px"), ("margin", "var(--margin, 1px 2px)"), @@ -576,6 +574,32 @@ mod tests { }); } + #[test] + fn parsed_all_serializes_its_compact_value() { + with_detached_style_context(|context| { + // Expanding all into a block and reading it back runs two passes + // over enabled longhands. Other unit tests can enable preferences + // between those passes. Its own specified value is independent of + // which longhands are currently enabled. + for (value, unresolved) in [("inherit", false), ("var(--shared, revert-layer)", true)] { + for priority in [false, true] { + let parsed = + ParsedCssomProperty::parse("all", value, priority, context).unwrap(); + assert_eq!(parsed.value().as_deref(), Some(value)); + assert_eq!(parsed.has_unresolved_value(), unresolved); + assert_eq!( + parsed.entries().unwrap(), + [CssDeclarationEntry { + name: "all".to_owned(), + value: value.to_owned(), + priority, + }], + ); + } + } + }); + } + #[test] fn parsed_property_names_use_the_resolved_property_and_preserve_custom_case() { with_detached_style_context(|context| {