From dbe12662b8ff4e45ff9931357c8a5e927152d1bf Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Sat, 1 Oct 2022 01:57:54 +0100 Subject: [PATCH] LibWeb: Implement matrix3d transform function from css-transforms-2 --- .../Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 3 +++ Userland/Libraries/LibWeb/CSS/TransformFunctions.json | 3 +++ Userland/Libraries/LibWeb/Painting/StackingContext.cpp | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index db3bd4f4fa..1b80fd7811 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -458,6 +458,9 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(Layout: VERIFY(layout_node.paintable()); auto const& paintable_box = verify_cast(layout_node.paintable()); VERIFY(paintable_box->stacking_context()); + + // FIXME: This needs to serialize to matrix3d if the transformation matrix is a 3D matrix. + // https://w3c.github.io/csswg-drafts/css-transforms-2/#serialization-of-the-computed-value auto affine_matrix = paintable_box->stacking_context()->affine_transform_matrix(); NonnullRefPtrVector parameters; diff --git a/Userland/Libraries/LibWeb/CSS/TransformFunctions.json b/Userland/Libraries/LibWeb/CSS/TransformFunctions.json index f0dbe7022f..510f73bcdb 100644 --- a/Userland/Libraries/LibWeb/CSS/TransformFunctions.json +++ b/Userland/Libraries/LibWeb/CSS/TransformFunctions.json @@ -2,6 +2,9 @@ "matrix": { "parameters": "{6}" }, + "matrix3d": { + "parameters": "{16}" + }, "translate": { "parameters": "{1,2}" }, diff --git a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp index 53f1ce8c60..524cad258c 100644 --- a/Userland/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Userland/Libraries/LibWeb/Painting/StackingContext.cpp @@ -199,6 +199,13 @@ Gfx::FloatMatrix4x4 StackingContext::get_transformation_matrix(CSS::Transformati 0, 0, 1, 0, 0, 0, 0, 1); break; + case CSS::TransformFunction::Matrix3d: + if (count == 16) + return Gfx::FloatMatrix4x4(value(0), value(4), value(8), value(12), + value(1), value(5), value(9), value(13), + value(2), value(6), value(10), value(14), + value(3), value(7), value(11), value(15)); + break; case CSS::TransformFunction::Translate: if (count == 1) return Gfx::FloatMatrix4x4(1, 0, 0, value(0, width),