Skip to content

Commit bdb1232

Browse files
committed
DOMMatrixReadOnly isIdentity property implemented
1 parent 1f54898 commit bdb1232

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="4.18.0" date="November xx, 2025" description="Chrome/Edge 141, Firefox 143, FirefoxESR 140, Bugfixes">
11+
<action type="add" dev="rbri">
12+
DOMMatrixReadOnly isIdentity property implemented.
13+
</action>
1114
<action type="fix" dev="RhinoTeam">
1215
core-js: improve global symbol registry handling.
1316
</action>

src/main/java/org/htmlunit/javascript/host/dom/DOMMatrixReadOnly.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,21 @@ public void setIs2D(final boolean is2D) {
468468
is2D_ = is2D;
469469
}
470470

471+
/**
472+
* @return true if m12 element, m13 element, m14 element, m21 element, m23 element, m24 element,
473+
* m31 element, m32 element, m34 element, m41 element, m42 element, m43 element are 0 or -0
474+
* and m11 element, m22 element, m33 element, m44 element are 1. Otherwise it returns false.
475+
*/
476+
@JsxGetter
477+
public boolean getIsIdentity() {
478+
return m11_ == 1 && m22_ == 1 && m33_ == 1 && m44_ == 1
479+
&& m12_ == 0 && m13_ == 0 && m14_ == 0
480+
&& m21_ == 0 && m23_ == 0 && m24_ == 0
481+
&& m31_ == 0 && m32_ == 0 && m34_ == 0
482+
&& m41_ == 0 && m42_ == 0 && m43_ == 0;
483+
}
484+
485+
471486
/**
472487
* @return a new matrix being the result of the original matrix flipped about the x-axis.
473488
* This is equivalent to multiplying the matrix by DOMMatrix(-1, 0, 0, 1, 0, 0).

src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18523,25 +18523,25 @@ public void styleMedia() throws Exception {
1852318523
+ "rotateFromVector(),scale(),scale3d(),scaleNonUniform(),skewX(),skewY(),"
1852418524
+ "toFloat32Array(),toFloat64Array(),toJSON(),toString(),transformPoint(),translate()")
1852518525
@HtmlUnitNYI(CHROME = "a[GCE],b[GCE],c[GCE],constructor(),d[GCE],e[GCE],f[GCE],flipX(),flipY(),"
18526-
+ "inverse(),is2D[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
18526+
+ "inverse(),is2D[GCE],isIdentity[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
1852718527
+ "m21[GCE],m22[GCE],m23[GCE],m24[GCE],m31[GCE],m32[GCE],m33[GCE],m34[GCE],"
1852818528
+ "m41[GCE],m42[GCE],m43[GCE],m44[GCE],multiply(),rotate(),rotateAxisAngle(),"
1852918529
+ "skewX(),skewY(),"
1853018530
+ "toFloat32Array(),toFloat64Array(),translate()",
1853118531
EDGE = "a[GCE],b[GCE],c[GCE],constructor(),d[GCE],e[GCE],f[GCE],flipX(),flipY(),"
18532-
+ "inverse(),is2D[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
18532+
+ "inverse(),is2D[GCE],isIdentity[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
1853318533
+ "m21[GCE],m22[GCE],m23[GCE],m24[GCE],m31[GCE],m32[GCE],m33[GCE],m34[GCE],"
1853418534
+ "m41[GCE],m42[GCE],m43[GCE],m44[GCE],multiply(),rotate(),rotateAxisAngle(),"
1853518535
+ "skewX(),skewY(),"
1853618536
+ "toFloat32Array(),toFloat64Array(),translate()",
1853718537
FF = "a[GCE],b[GCE],c[GCE],constructor(),d[GCE],e[GCE],f[GCE],flipX(),flipY(),"
18538-
+ "inverse(),is2D[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
18538+
+ "inverse(),is2D[GCE],isIdentity[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
1853918539
+ "m21[GCE],m22[GCE],m23[GCE],m24[GCE],m31[GCE],m32[GCE],m33[GCE],m34[GCE],"
1854018540
+ "m41[GCE],m42[GCE],m43[GCE],m44[GCE],multiply(),rotate(),rotateAxisAngle(),"
1854118541
+ "skewX(),skewY(),"
1854218542
+ "toFloat32Array(),toFloat64Array(),translate()",
1854318543
FF_ESR = "a[GCE],b[GCE],c[GCE],constructor(),d[GCE],e[GCE],f[GCE],flipX(),flipY(),"
18544-
+ "inverse(),is2D[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
18544+
+ "inverse(),is2D[GCE],isIdentity[GCE],m11[GCE],m12[GCE],m13[GCE],m14[GCE],"
1854518545
+ "m21[GCE],m22[GCE],m23[GCE],m24[GCE],m31[GCE],m32[GCE],m33[GCE],m34[GCE],"
1854618546
+ "m41[GCE],m42[GCE],m43[GCE],m44[GCE],multiply(),rotate(),rotateAxisAngle(),"
1854718547
+ "skewX(),skewY(),"

src/test/java/org/htmlunit/javascript/host/dom/DOMMatrixReadOnlyTest.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,4 +3128,61 @@ public void translate_withZ() throws Exception {
31283128

31293129
loadPageVerifyTitle2(html);
31303130
}
3131+
3132+
/**
3133+
* @throws Exception on test failure
3134+
*/
3135+
@Test
3136+
@Alerts({"true",
3137+
"false",
3138+
"false",
3139+
"false",
3140+
"false",
3141+
"false",
3142+
"false",
3143+
"false",
3144+
"true",
3145+
"true",
3146+
"false",
3147+
"true"})
3148+
public void isIdentity() throws Exception {
3149+
final String html = DOCTYPE_HTML
3150+
+ "<html>\n"
3151+
+ "<body>\n"
3152+
+ "<script>\n"
3153+
+ LOG_TITLE_FUNCTION
3154+
+ "let m = new DOMMatrixReadOnly();\n"
3155+
+ "log(m.isIdentity);\n"
3156+
3157+
+ "m = new DOMMatrixReadOnly([0, 0, 0, 0, 0, 0]);"
3158+
+ "log(m.isIdentity);\n"
3159+
3160+
+ "m = new DOMMatrixReadOnly([1, 0, 0, 0, 0, 0]);"
3161+
+ "log(m.isIdentity);\n"
3162+
+ "m = new DOMMatrixReadOnly([0, 1, 0, 0, 0, 0]);"
3163+
+ "log(m.isIdentity);\n"
3164+
+ "m = new DOMMatrixReadOnly([0, 0, 1, 0, 0, 0]);"
3165+
+ "log(m.isIdentity);\n"
3166+
+ "m = new DOMMatrixReadOnly([0, 0, 0, 1, 0, 0]);"
3167+
+ "log(m.isIdentity);\n"
3168+
+ "m = new DOMMatrixReadOnly([0, 0, 0, 0, 1, 0]);"
3169+
+ "log(m.isIdentity);\n"
3170+
+ "m = new DOMMatrixReadOnly([0, 0, 0, 0, 0, 1]);"
3171+
+ "log(m.isIdentity);\n"
3172+
3173+
+ "m = new DOMMatrixReadOnly([1, 0, 0, 1, 0, 0]);"
3174+
+ "log(m.isIdentity);\n"
3175+
+ "m = new DOMMatrixReadOnly([1, -0, -0, 1, -0, -0]);"
3176+
+ "log(m.isIdentity);\n"
3177+
3178+
+ "m = new DOMMatrixReadOnly([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);\n"
3179+
+ "log(m.isIdentity);\n"
3180+
+ "m = new DOMMatrixReadOnly([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);\n"
3181+
+ "log(m.isIdentity);\n"
3182+
3183+
+ "</script>\n"
3184+
+ "</body></html>";
3185+
3186+
loadPageVerifyTitle2(html);
3187+
}
31313188
}

0 commit comments

Comments
 (0)