From 79c63809e368313bd87a11ef1db88d8d20d554ce Mon Sep 17 00:00:00 2001 From: ldm0 Date: Sun, 30 Aug 2026 17:05:13 +0800 Subject: [PATCH] fix(css): enable starting-style parsing --- .../css_stylesheet_runtime/tests.rs | 21 +++++++++++++++++++ moli-renderer-v8/src/style_engine/mod.rs | 1 + 2 files changed, 22 insertions(+) diff --git a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs index e5af1b5e58..d8aa617dd8 100644 --- a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs +++ b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/tests.rs @@ -777,6 +777,27 @@ fn grouping_rule_css_text_uses_stylo_rule_view_serialization() { ); } +#[test] +fn starting_style_rule_accepts_an_empty_prelude_and_rejects_nonempty_preludes() { + crate::style_engine::ensure_stylo_browser_compat_prefs(); + + assert_eq!( + parsed_top_level_rule_texts("@starting-style {}"), + ["@starting-style {\n}"] + ); + for css_text in [ + "@starting-style div {}", + "@starting-style () {}", + "@starting-style ( {}", + "@starting-style }{}", + ] { + assert!( + parsed_top_level_rule_texts(css_text).is_empty(), + "unexpectedly accepted {css_text:?}" + ); + } +} + #[test] fn grouping_rule_css_text_uses_stylo_page_rule_child_serialization() { let css_text = diff --git a/moli-renderer-v8/src/style_engine/mod.rs b/moli-renderer-v8/src/style_engine/mod.rs index fe336fea40..f4d0d1a97c 100644 --- a/moli-renderer-v8/src/style_engine/mod.rs +++ b/moli-renderer-v8/src/style_engine/mod.rs @@ -1119,6 +1119,7 @@ pub(crate) fn ensure_stylo_browser_compat_prefs() { stylo_static_prefs::set_pref!("layout.css.content.alt-text.enabled", true); stylo_static_prefs::set_pref!("layout.css.margin-rules.enabled", true); stylo_static_prefs::set_pref!("layout.css.scroll-driven-animations.enabled", true); + stylo_static_prefs::set_pref!("layout.css.starting-style-at-rules.enabled", true); stylo_static_prefs::set_pref!("layout.css.style-queries.enabled", true); stylo_static_prefs::set_pref!("layout.css.tree-counting-functions.enabled", true); stylo_static_prefs::set_pref!("layout.css.zoom.enabled", true);