From 6373ab68ee19e9973a2d65053edc6ba1593da9bb Mon Sep 17 00:00:00 2001 From: Callum Law Date: Thu, 21 Aug 2025 17:25:04 +1200 Subject: [PATCH] LibWeb: Use inherited value of math-style when computing math-depth The spec calls for us to use the inherited value but we were using our own value. --- Libraries/LibWeb/CSS/StyleComputer.cpp | 9 ++++++- ...math-depth-auto-add-math-style-inherit.txt | 2 ++ ...ath-depth-auto-add-math-style-inherit.html | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/css/math-depth-auto-add-math-style-inherit.txt create mode 100644 Tests/LibWeb/Text/input/css/math-depth-auto-add-math-style-inherit.html diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index c9d95e0711f..9009a9fd04b 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -3186,10 +3186,17 @@ void StyleComputer::compute_math_depth(ComputedProperties& style, Optional NonnullRefPtr { + if (!element_to_inherit_style_from.has_value()) + return property_initial_value(CSS::PropertyID::MathStyle); + + return element_to_inherit_style_from->computed_properties()->property(CSS::PropertyID::MathStyle); + }; + // The computed value of the math-depth value is determined as follows: // - If the specified value of math-depth is auto-add and the inherited value of math-style is compact // then the computed value of math-depth of the element is its inherited value plus one. - if (math_depth.is_auto_add() && style.property(CSS::PropertyID::MathStyle).to_keyword() == Keyword::Compact) { + if (math_depth.is_auto_add() && inherited_math_style()->to_keyword() == Keyword::Compact) { style.set_math_depth(inherited_math_depth() + 1); return; } diff --git a/Tests/LibWeb/Text/expected/css/math-depth-auto-add-math-style-inherit.txt b/Tests/LibWeb/Text/expected/css/math-depth-auto-add-math-style-inherit.txt new file mode 100644 index 00000000000..0496a59fcbc --- /dev/null +++ b/Tests/LibWeb/Text/expected/css/math-depth-auto-add-math-style-inherit.txt @@ -0,0 +1,2 @@ +Foo: 0 +Bar: 1 diff --git a/Tests/LibWeb/Text/input/css/math-depth-auto-add-math-style-inherit.html b/Tests/LibWeb/Text/input/css/math-depth-auto-add-math-style-inherit.html new file mode 100644 index 00000000000..df43ddb17d5 --- /dev/null +++ b/Tests/LibWeb/Text/input/css/math-depth-auto-add-math-style-inherit.html @@ -0,0 +1,25 @@ + + + + +
+
+
+ + + +