style: Use saturating addition for math-depth

Differential Revision: https://phabricator.services.mozilla.com/D114070
This commit is contained in:
Oriol Brufau 2023-05-17 00:40:54 +02:00
parent 43cec05c04
commit 516c7a304a

View file

@ -828,14 +828,14 @@ impl ToComputedValue for specified::MathDepth {
let parent = cx.builder.get_parent_font().clone_math_depth() as i32; let parent = cx.builder.get_parent_font().clone_math_depth() as i32;
let style = cx.builder.get_parent_font().clone_math_style(); let style = cx.builder.get_parent_font().clone_math_style();
if style == MathStyleValue::Compact { if style == MathStyleValue::Compact {
parent + 1 parent.saturating_add(1)
} else { } else {
parent parent
} }
}, },
specified::MathDepth::Add(rel) => { specified::MathDepth::Add(rel) => {
let parent = cx.builder.get_parent_font().clone_math_depth(); let parent = cx.builder.get_parent_font().clone_math_depth();
parent as i32 + rel.to_computed_value(cx) (parent as i32).saturating_add(rel.to_computed_value(cx))
}, },
specified::MathDepth::Absolute(abs) => abs.to_computed_value(cx), specified::MathDepth::Absolute(abs) => abs.to_computed_value(cx),
}; };