Skip to content
Browse files
CSSPerspective.toMatrix() should throw if its length is not compatibl…
…e with 'px' unit

Reviewed by Antoine Quint.

CSSPerspective.toMatrix() should throw a TypeError if its length is not compatible with 'px' unit:

* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformComponent-toMatrix-relative-units-expected.txt:
* Source/WebCore/css/typedom/transform/CSSPerspective.cpp:

Canonical link:
  • Loading branch information
cdumez committed Oct 22, 2022
1 parent 817e48d commit 02ba20dc48a2ce34a4429aa705e444497298c723
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
@@ -1,6 +1,4 @@

PASS CSSTranslate.toMatrix() containing relative units throws TypeError
FAIL CSSPerspective.toMatrix() containing relative units throws TypeError assert_throws_js: function "() => {
return new CSSPerspective(new CSSUnitValue(1, 'em')).toMatrix();
}" did not throw
PASS CSSPerspective.toMatrix() containing relative units throws TypeError

@@ -148,8 +148,12 @@ ExceptionOr<Ref<DOMMatrix>> CSSPerspective::toMatrix()
if (!is<CSSUnitValue>(length))
return Exception { TypeError };

auto valuePx = downcast<CSSUnitValue>(*length).convertTo(CSSUnitType::CSS_PX);
if (!valuePx)
return Exception { TypeError, "Length unit is not compatible with 'px'"_s };

TransformationMatrix matrix { };

return { DOMMatrix::create(WTFMove(matrix), DOMMatrixReadOnly::Is2D::No) };

0 comments on commit 02ba20d

Please sign in to comment.