1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:27:35 +00:00

LibWeb: Add DOMMatrix string constructor and set matrix value

This commit is contained in:
Bastiaan van der Plaat 2024-01-06 18:05:21 +01:00 committed by Andreas Kling
parent 903d3c92c8
commit be7538961b
15 changed files with 336 additions and 120 deletions

View file

@ -8,3 +8,11 @@
8. {"a":10,"b":20,"c":50,"d":60,"e":130,"f":140,"m11":10,"m12":20,"m13":30,"m14":40,"m21":50,"m22":60,"m23":70,"m24":80,"m31":90,"m32":100,"m33":110,"m34":120,"m41":130,"m42":140,"m43":150,"m44":160,"is2D":false,"isIdentity":false}
9. Exception: TypeError
10. Exception: TypeError
11. {"a":1,"b":0,"c":0,"d":1,"e":10,"f":10,"m11":1,"m12":0,"m13":0,"m14":0,"m21":0,"m22":1,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":10,"m42":10,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
12. {"a":10,"b":0,"c":0,"d":10,"e":100,"f":100,"m11":10,"m12":0,"m13":0,"m14":0,"m21":0,"m22":10,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":100,"m42":100,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
13. {"a":2,"b":0,"c":0,"d":2,"e":0,"f":0,"m11":2,"m12":0,"m13":0,"m14":0,"m21":0,"m22":2,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":0,"m42":0,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
14. {"a":0.9396926164627075,"b":0.3420201241970062,"c":-0.3420201241970062,"d":0.9396926164627075,"e":5.976724624633789,"f":12.817127227783203,"m11":0.9396926164627075,"m12":0.3420201241970062,"m13":0,"m14":0,"m21":-0.3420201241970062,"m22":0.9396926164627075,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":5.976724624633789,"m42":12.817127227783203,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
15. Exception: SyntaxError
16. Exception: SyntaxError
17. Exception: SyntaxError
18. Exception: SyntaxError

View file

@ -0,0 +1,6 @@
1. {"a":1,"b":0,"c":0,"d":1,"e":0,"f":0,"m11":1,"m12":0,"m13":0,"m14":0,"m21":0,"m22":1,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":0,"m42":0,"m43":0,"m44":1,"is2D":true,"isIdentity":true}
2. {"a":1,"b":0,"c":0,"d":1,"e":10,"f":10,"m11":1,"m12":0,"m13":0,"m14":0,"m21":0,"m22":1,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":10,"m42":10,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
3. {"a":0.9848077297210693,"b":0.1736481785774231,"c":-0.1736481785774231,"d":0.9848077297210693,"e":8.11159610748291,"f":11.584559440612793,"m11":0.9848077297210693,"m12":0.1736481785774231,"m13":0,"m14":0,"m21":-0.1736481785774231,"m22":0.9848077297210693,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":8.11159610748291,"m42":11.584559440612793,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
4. {"a":0.19696155190467834,"b":0.03472963720560074,"c":-0.03472963720560074,"d":0.19696155190467834,"e":0,"f":0,"m11":0.19696155190467834,"m12":0.03472963720560074,"m13":0,"m14":0,"m21":-0.03472963720560074,"m22":0.19696155190467834,"m23":0,"m24":0,"m31":0,"m32":0,"m33":1,"m34":0,"m41":0,"m42":0,"m43":0,"m44":1,"is2D":true,"isIdentity":false}
5. Exception: SyntaxError
6. Exception: SyntaxError

View file

@ -40,5 +40,29 @@
// 10. Creating a DOMMatrix with fromFloat64Array wrong amount
testPart(() => DOMMatrix.fromFloat64Array(new Float64Array([10, 20, 30, 40])));
// 11. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('translate(10px, 10px)'));
// 12. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('scale(10) translate(10px, 10px)'));
// 13. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('scale(2)'));
// 14. Creating a DOMMatrix with CSS transform string
testPart(() => new DOMMatrix('rotate(20deg) translate(10px, 10px)'));
// 15. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('translate(2)'));
// 16. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('rotate(20)'));
// 17. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('rotate(20px)'));
// 18. Creating a DOMMatrix with CSS transform string with error
testPart(() => new DOMMatrix('matrix(1.0, 2.0deg, 3.0, 4.0, 5.0, 6.0)'));
});
</script>

View file

@ -0,0 +1,32 @@
<script src="../include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
try {
println(`${testCounter}. ${JSON.stringify(part())}`);
} catch (e) {
println(`${testCounter}. Exception: ${e.name}`);
}
testCounter++;
}
// 1. DOMMatrix set matrix value empty
testPart(() => new DOMMatrix().setMatrixValue(''));
// 2. DOMMatrix set matrix value
testPart(() => new DOMMatrix().setMatrixValue('translate(10px, 10px)'));
// 3. DOMMatrix set matrix value
testPart(() => new DOMMatrix().setMatrixValue('rotate(10deg) translate(10px, 10px)'));
// 4. DOMMatrix set matrix value
testPart(() => new DOMMatrix().setMatrixValue('scale(0.2) rotate(10deg)'));
// 5. DOMMatrix set matrix value wrong
testPart(() => new DOMMatrix().setMatrixValue('scale(2deg)'));
// 6. DOMMatrix set matrix value wrong
testPart(() => new DOMMatrix().setMatrixValue('translate(40%)'));
});
</script>