mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1190705 - Ensure that canvas 2d matrix transforms are finite. r=Bas, r=jrmuizel
This commit is contained in:
parent
dc8799ee26
commit
6237df1a12
@ -1728,7 +1728,11 @@ CanvasRenderingContext2D::Scale(double x, double y, ErrorResult& error)
|
||||
}
|
||||
|
||||
Matrix newMatrix = mTarget->GetTransform();
|
||||
mTarget->SetTransform(newMatrix.PreScale(x, y));
|
||||
newMatrix.PreScale(x, y);
|
||||
if (!newMatrix.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
mTarget->SetTransform(newMatrix);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1740,8 +1744,11 @@ CanvasRenderingContext2D::Rotate(double angle, ErrorResult& error)
|
||||
return;
|
||||
}
|
||||
|
||||
Matrix rotation = Matrix::Rotation(angle);
|
||||
mTarget->SetTransform(rotation * mTarget->GetTransform());
|
||||
Matrix newMatrix = Matrix::Rotation(angle) * mTarget->GetTransform();
|
||||
if (!newMatrix.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
mTarget->SetTransform(newMatrix);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1753,7 +1760,12 @@ CanvasRenderingContext2D::Translate(double x, double y, ErrorResult& error)
|
||||
return;
|
||||
}
|
||||
|
||||
mTarget->SetTransform(Matrix(mTarget->GetTransform()).PreTranslate(x, y));
|
||||
Matrix newMatrix = mTarget->GetTransform();
|
||||
newMatrix.PreTranslate(x, y);
|
||||
if (!newMatrix.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
mTarget->SetTransform(newMatrix);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1767,8 +1779,12 @@ CanvasRenderingContext2D::Transform(double m11, double m12, double m21,
|
||||
return;
|
||||
}
|
||||
|
||||
Matrix matrix(m11, m12, m21, m22, dx, dy);
|
||||
mTarget->SetTransform(matrix * mTarget->GetTransform());
|
||||
Matrix newMatrix(m11, m12, m21, m22, dx, dy);
|
||||
newMatrix *= mTarget->GetTransform();
|
||||
if (!newMatrix.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
mTarget->SetTransform(newMatrix);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1784,6 +1800,9 @@ CanvasRenderingContext2D::SetTransform(double m11, double m12,
|
||||
}
|
||||
|
||||
Matrix matrix(m11, m12, m21, m22, dx, dy);
|
||||
if (!matrix.IsFinite()) {
|
||||
return;
|
||||
}
|
||||
mTarget->SetTransform(matrix);
|
||||
}
|
||||
|
||||
|
@ -265,6 +265,14 @@ public:
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
/* Verifies that the matrix contains no Infs or NaNs. */
|
||||
bool IsFinite() const
|
||||
{
|
||||
return mozilla::IsFinite(_11) && mozilla::IsFinite(_12) &&
|
||||
mozilla::IsFinite(_21) && mozilla::IsFinite(_22) &&
|
||||
mozilla::IsFinite(_31) && mozilla::IsFinite(_32);
|
||||
}
|
||||
|
||||
/* Returns true if the matrix is a rectilinear transformation (i.e.
|
||||
* grid-aligned rectangles are transformed to grid-aligned rectangles)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user