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.
This commit is contained in:
Callum Law 2025-08-21 17:25:04 +12:00 committed by Jelle Raaijmakers
commit 6373ab68ee
Notes: github-actions[bot] 2025-08-22 07:49:58 +00:00
3 changed files with 35 additions and 1 deletions

View file

@ -3186,10 +3186,17 @@ void StyleComputer::compute_math_depth(ComputedProperties& style, Optional<DOM::
VERIFY_NOT_REACHED();
};
auto inherited_math_style = [&]() -> NonnullRefPtr<StyleValue const> {
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;
}