Skip to content
Permalink
Browse files
Implement CSSTransformValue.toMatrix
https://bugs.webkit.org/show_bug.cgi?id=246173
rdar://100868409

Reviewed by Antoine Quint.

Implement the toMatrix method of CSSTransformValue.

* LayoutTests/imported/w3c/web-platform-tests/css/css-typed-om/stylevalue-subclasses/cssTransformValue-toMatrix-expected.txt:
* Source/WebCore/css/typedom/transform/CSSTransformValue.cpp:
(WebCore::CSSTransformValue::toMatrix):

Canonical link: https://commits.webkit.org/255299@main
  • Loading branch information
grorg committed Oct 7, 2022
1 parent b1df66e commit 76aa139eb22f8a04743020ab3a5f66ca1045b30a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
@@ -1,4 +1,4 @@

FAIL CSSTransformValue.toMatrix() multiplies its component matrices assert_array_approx_equals: property 0, expected 10 +/- 0.000001, expected 10 but got 1
FAIL CSSTransformValue.toMatrix() respects is2D changes in its components assert_array_approx_equals: property 0, expected -6 +/- 0.000001, expected -6 but got 1
PASS CSSTransformValue.toMatrix() multiplies its component matrices
PASS CSSTransformValue.toMatrix() respects is2D changes in its components

@@ -82,8 +82,20 @@ bool CSSTransformValue::is2D() const

ExceptionOr<Ref<DOMMatrix>> CSSTransformValue::toMatrix()
{
// FIXME: add correct behavior here.
return DOMMatrix::fromMatrix(DOMMatrixInit { });
auto matrix = TransformationMatrix();
auto is2D = DOMMatrixReadOnly::Is2D::Yes;

for (auto component : m_components) {
auto componentMatrixOrException = component->toMatrix();
if (componentMatrixOrException.hasException())
return componentMatrixOrException.releaseException();
auto componentMatrix = componentMatrixOrException.returnValue();
if (!componentMatrix->is2D())
is2D = DOMMatrixReadOnly::Is2D::No;
matrix.multiply(componentMatrix->transformationMatrix());
}

return DOMMatrix::create(WTFMove(matrix), is2D);
}

CSSTransformValue::CSSTransformValue(Vector<RefPtr<CSSTransformComponent>>&& transforms)

0 comments on commit 76aa139

Please sign in to comment.