LibWeb: Move Transformation::to_matrix to new CSV resolve methods

This gains us 2 WPT passes as we now correctly disallow relative lengths
in more places in the `DOMMatrix` constructor.
This commit is contained in:
Callum Law 2025-07-17 00:27:13 +12:00 committed by Jelle Raaijmakers
commit 3d7c5115d8
Notes: github-actions[bot] 2025-07-17 06:33:04 +00:00
3 changed files with 12 additions and 8 deletions

View file

@ -43,7 +43,7 @@ ErrorOr<Gfx::FloatMatrix4x4> Transformation::to_matrix(Optional<Painting::Painta
return length.absolute_length_to_px().to_float();
}
if (value.is_calculated() && value.calculated()->resolves_to_length()) {
if (auto const& resolved = value.calculated()->resolve_length_deprecated(context); resolved->is_absolute())
if (auto const& resolved = value.calculated()->resolve_length(context); resolved.has_value() && resolved->is_absolute())
return resolved->absolute_length_to_px().to_float();
}
return Error::from_string_literal("Transform contains non absolute units");
@ -55,9 +55,11 @@ ErrorOr<Gfx::FloatMatrix4x4> Transformation::to_matrix(Optional<Painting::Painta
return value.percentage().as_fraction();
if (value.is_calculated()) {
if (value.calculated()->resolves_to_number())
return value.calculated()->resolve_number_deprecated(context).value();
if (auto resolved_number = value.calculated()->resolve_number(context); resolved_number.has_value())
return resolved_number.value();
if (value.calculated()->resolves_to_percentage())
return value.calculated()->resolve_percentage_deprecated(context)->as_fraction();
if (auto resolved_percentage = value.calculated()->resolve_percentage(context); resolved_percentage.has_value())
return resolved_percentage->as_fraction();
}
return Error::from_string_literal("Transform contains non absolute units");
});