mirror of
https://github.com/servo/servo.git
synced 2025-09-10 15:08:21 +01:00
script: preserve 2D on DOMMatrix invert (#39113)
More small geometry fixes. Testing: Covered by WPT (css/geometry/DOMMatrix-invert-preserves-2d.html) --------- Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
This commit is contained in:
parent
ff8be71335
commit
a44b98c358
2 changed files with 11 additions and 8 deletions
|
@ -409,12 +409,18 @@ impl DOMMatrixReadOnly {
|
||||||
// Step 2 in DOMMatrix.SkewYSelf
|
// Step 2 in DOMMatrix.SkewYSelf
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself
|
/// <https://drafts.fxtf.org/geometry-1/#dom-dommatrix-invertself>
|
||||||
pub(crate) fn invert_self(&self) {
|
pub(crate) fn invert_self(&self) {
|
||||||
let mut matrix = self.matrix.borrow_mut();
|
let mut matrix = self.matrix.borrow_mut();
|
||||||
// Step 1.
|
// Step 1. Invert the current matrix.
|
||||||
*matrix = matrix.inverse().unwrap_or_else(|| {
|
let inverted = match self.is2D() {
|
||||||
// Step 2.
|
true => matrix.to_2d().inverse().map(|m| m.to_3d()),
|
||||||
|
false => matrix.inverse(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Step 2. If the current matrix is not invertible set all attributes to NaN
|
||||||
|
// and set is 2D to false.
|
||||||
|
*matrix = inverted.unwrap_or_else(|| -> Transform3D<f64> {
|
||||||
self.is2D.set(false);
|
self.is2D.set(false);
|
||||||
Transform3D::new(
|
Transform3D::new(
|
||||||
f64::NAN,
|
f64::NAN,
|
||||||
|
@ -434,7 +440,7 @@ impl DOMMatrixReadOnly {
|
||||||
f64::NAN,
|
f64::NAN,
|
||||||
f64::NAN,
|
f64::NAN,
|
||||||
)
|
)
|
||||||
})
|
});
|
||||||
// Step 3 in DOMMatrix.InvertSelf
|
// Step 3 in DOMMatrix.InvertSelf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[DOMMatrix-invert-preserves-2d.html]
|
|
||||||
[scale]
|
|
||||||
expected: FAIL
|
|
Loading…
Add table
Add a link
Reference in a new issue