canvas: use Transform2D instead of Transform3D when possible (#37759)

While this makes our implementation deviate slightly from the
specification, this clarifies an invariant with the code itself. This
helps to resolve some confusion as seen in
https://github.com/servo/servo/issues/37695#issuecomment-3013823350.

Testing: This should not change behavior and is thus covered by existing
WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
sagudev 2025-07-02 10:44:56 +02:00 committed by GitHub
parent e2ad9c14c6
commit 944713ddd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 32 additions and 76 deletions

View file

@ -93,21 +93,14 @@ impl CanvasPatternMethods<crate::DomTypeHolder> for CanvasPattern {
!matrix.m12.is_finite() ||
!matrix.m21.is_finite() ||
!matrix.m22.is_finite() ||
!matrix.m41.is_finite() ||
!matrix.m42.is_finite()
!matrix.m31.is_finite() ||
!matrix.m32.is_finite()
{
return Ok(());
}
// Step 3. Reset the pattern's transformation matrix to matrix.
*self.transform.borrow_mut() = Transform2D::new(
matrix.m11 as f32,
matrix.m12 as f32,
matrix.m21 as f32,
matrix.m22 as f32,
matrix.m41 as f32,
matrix.m42 as f32,
);
*self.transform.borrow_mut() = matrix.cast();
Ok(())
}