mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Clamp any values less than 1 in perspective() transform function
This commit is contained in:
parent
0cb9f4b66f
commit
d284b4c2b8
Notes:
github-actions[bot]
2025-11-12 17:46:31 +00:00
Author: https://github.com/Psychpsyo
Commit: d284b4c2b8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6800
Reviewed-by: https://github.com/gmta ✅
4 changed files with 77 additions and 3 deletions
|
|
@ -75,15 +75,20 @@ ErrorOr<Gfx::FloatMatrix4x4> Transformation::to_matrix(Optional<Painting::Painta
|
|||
|
||||
switch (m_function) {
|
||||
case CSS::TransformFunction::Perspective:
|
||||
// https://drafts.csswg.org/css-transforms-2/#perspective
|
||||
// https://drafts.csswg.org/css-transforms-2/#funcdef-perspective
|
||||
// Count is zero when null parameter
|
||||
if (count == 1) {
|
||||
// FIXME: Add support for the 'perspective-origin' CSS property.
|
||||
auto distance = TRY(value(0));
|
||||
// If the depth value is less than '1px', it must be treated as '1px' for the purpose of rendering, for
|
||||
// computing the resolved value of 'transform', and when used as the endpoint of interpolation.
|
||||
// Note: The intent of the above rules on values less than '1px' is that they cover the cases where
|
||||
// the 'perspective()' function needs to be converted into a matrix.
|
||||
if (distance < 1)
|
||||
distance = 1;
|
||||
return Gfx::FloatMatrix4x4(1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, -1 / (distance <= 0 ? 1 : distance), 1);
|
||||
0, 0, -1 / distance, 1);
|
||||
}
|
||||
return Gfx::FloatMatrix4x4(1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue