mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 00:38:39 +09:00
Issue #2752 - Change DOMMatrix Rotate{Self}() to the current spec.
This changes Rotate{Self}(angle, translateX, translateY) to
Rotate{Self}(rotateX, rotateY, rotateZ) per the spec.
The resulting matrix will be a 3DMatrix
Resolves #2752
This commit is contained in:
parent
321b75a391
commit
2782cded29
3 changed files with 64 additions and 41 deletions
|
|
@ -320,12 +320,11 @@ DOMMatrixReadOnly::ScaleNonUniform(double aScaleX,
|
|||
}
|
||||
|
||||
already_AddRefed<DOMMatrix>
|
||||
DOMMatrixReadOnly::Rotate(double aAngle,
|
||||
double aOriginX ,
|
||||
double aOriginY) const
|
||||
{
|
||||
DOMMatrixReadOnly::Rotate(double aRotX,
|
||||
const Optional<double>& aRotY,
|
||||
const Optional<double>& aRotZ) const {
|
||||
RefPtr<DOMMatrix> retval = new DOMMatrix(mParent, *this);
|
||||
retval->RotateSelf(aAngle, aOriginX, aOriginY);
|
||||
retval->RotateSelf(aRotX, aRotY, aRotZ);
|
||||
|
||||
return retval.forget();
|
||||
}
|
||||
|
|
@ -893,28 +892,52 @@ DOMMatrix::RotateFromVectorSelf(double aX, double aY)
|
|||
return this;
|
||||
}
|
||||
|
||||
RotateSelf(atan2(aY, aX) / radPerDegree);
|
||||
const double angle = atan2(aY, aX);
|
||||
|
||||
if (fmod(angle, 2 * M_PI) == 0) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (mMatrix3D) {
|
||||
RotateAxisAngleSelf(0, 0, 1, angle / radPerDegree);
|
||||
} else {
|
||||
*mMatrix2D = mMatrix2D->PreRotate(angle);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
DOMMatrix*
|
||||
DOMMatrix::RotateSelf(double aAngle, double aOriginX, double aOriginY)
|
||||
{
|
||||
if (fmod(aAngle, 360) == 0) {
|
||||
return this;
|
||||
DOMMatrix* DOMMatrix::RotateSelf(double aRotX, const Optional<double>& aRotY,
|
||||
const Optional<double>& aRotZ) {
|
||||
double rotY;
|
||||
double rotZ;
|
||||
if (!aRotY.WasPassed() && !aRotZ.WasPassed()) {
|
||||
rotZ = aRotX;
|
||||
aRotX = 0;
|
||||
rotY = 0;
|
||||
} else {
|
||||
rotY = aRotY.WasPassed() ? aRotY.Value() : 0;
|
||||
rotZ = aRotZ.WasPassed() ? aRotZ.Value() : 0;
|
||||
}
|
||||
|
||||
TranslateSelf(aOriginX, aOriginY);
|
||||
if (aRotX != 0 || rotY != 0) {
|
||||
Ensure3DMatrix();
|
||||
}
|
||||
|
||||
if (mMatrix3D) {
|
||||
RotateAxisAngleSelf(0, 0, 1, aAngle);
|
||||
} else {
|
||||
*mMatrix2D = mMatrix2D->PreRotate(aAngle * radPerDegree);
|
||||
if (fmod(rotZ, 360) != 0) {
|
||||
mMatrix3D->RotateZ(rotZ * radPerDegree);
|
||||
}
|
||||
if (fmod(rotY, 360) != 0) {
|
||||
mMatrix3D->RotateY(rotY * radPerDegree);
|
||||
}
|
||||
if (fmod(aRotX, 360) != 0) {
|
||||
mMatrix3D->RotateX(aRotX * radPerDegree);
|
||||
}
|
||||
} else if (fmod(rotZ, 360) != 0) {
|
||||
*mMatrix2D = mMatrix2D->PreRotate(rotZ * radPerDegree);
|
||||
}
|
||||
|
||||
TranslateSelf(-aOriginX, -aOriginY);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue