LibWeb: Make CSSPerspective correctly clamp its input for toMatrix()

This commit is contained in:
Psychpsyo 2025-11-13 00:45:47 +01:00 committed by Jelle Raaijmakers
parent 684c543ddb
commit edccb92da7
Notes: github-actions[bot] 2025-11-13 14:48:12 +00:00
2 changed files with 10 additions and 9 deletions

View file

@ -121,7 +121,7 @@ WebIDL::ExceptionOr<GC::Ref<Geometry::DOMMatrix>> CSSPerspective::to_matrix() co
[&matrix](GC::Ref<CSSNumericValue> const& numeric_value) -> WebIDL::ExceptionOr<void> {
// NB: to() throws a TypeError if the conversion can't be done.
auto distance = TRY(numeric_value->to("px"_fly_string))->value();
matrix->set_m34(-1 / (distance <= 0 ? 1 : distance));
matrix->set_m34(-1 / max(distance, 1));
return {};
},
[](GC::Ref<CSSKeywordValue> const&) -> WebIDL::ExceptionOr<void> {