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;
}

View file

@ -0,0 +1,2 @@
Foo: 0
Bar: 1

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<body>
<style>
#foo {
math-style: compact;
math-depth: auto-add;
}
#bar {
math-depth: auto-add;
}
</style>
<div id="foo">
<div id="bar"></div>
</div>
<script src="../include.js"></script>
<script>
test(() => {
println("Foo: " + getComputedStyle(foo).mathDepth);
println("Bar: " + getComputedStyle(bar).mathDepth);
});
</script>
</body>
</html>