LibWeb: Clamp negative computed values for padding-* properties

Interpolation can leave `padding-*` values as negative - this should be
handled by interpolation clamping it to the allowed range of values
but we don't yet do that. As a stop gap we can clamp this before setting
it in ComputedValues.

This fixes 3 crashes and gains us 11 passes in the imported WPT tests
This commit is contained in:
Callum Law 2025-08-22 03:41:19 +12:00 committed by Sam Atkins
parent a0b7d0542c
commit 6fcaceedd9
Notes: github-actions[bot] 2025-09-01 11:30:30 +00:00
10 changed files with 490 additions and 28 deletions

View file

@ -313,8 +313,10 @@ GC::Ref<SVGAnimatedLength> SVGElement::svg_animated_length_for_property(CSS::Pro
// FIXME: Create a proper animated value when animations are supported.
auto make_length = [&](SVGLength::ReadOnly read_only) {
if (auto const computed_properties = this->computed_properties()) {
if (auto length = computed_properties->length_percentage(property); length.has_value())
return SVGLength::from_length_percentage(realm(), *length, read_only);
if (auto layout_node = this->layout_node()) {
if (auto length = computed_properties->length_percentage(property, *layout_node, CSS::ComputedProperties::ClampNegativeLengths::Yes); length.has_value())
return SVGLength::from_length_percentage(realm(), *length, read_only);
}
}
return SVGLength::create(realm(), 0, 0, read_only);
};