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 @@ + + + + +
+
+
+ + + +