diff --git a/Tests/LibWeb/Ref/css-transform-box.html b/Tests/LibWeb/Ref/css-transform-box.html
new file mode 100644
index 0000000000..9ca3dbcf38
--- /dev/null
+++ b/Tests/LibWeb/Ref/css-transform-box.html
@@ -0,0 +1,36 @@
+
+
+
+
Hi
+Hi
+
diff --git a/Tests/LibWeb/Ref/reference/css-transform-box-ref.html b/Tests/LibWeb/Ref/reference/css-transform-box-ref.html
new file mode 100644
index 0000000000..57ae32963b
--- /dev/null
+++ b/Tests/LibWeb/Ref/reference/css-transform-box-ref.html
@@ -0,0 +1,15 @@
+
+
+
diff --git a/Tests/LibWeb/Ref/reference/images/css-transform-box-ref.png b/Tests/LibWeb/Ref/reference/images/css-transform-box-ref.png
new file mode 100644
index 0000000000..58fe5260b5
Binary files /dev/null and b/Tests/LibWeb/Ref/reference/images/css-transform-box-ref.png differ
diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp
index c2b19b2c34..886524f794 100644
--- a/Userland/Libraries/LibWeb/Layout/LayoutState.cpp
+++ b/Userland/Libraries/LibWeb/Layout/LayoutState.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2022-2023, Andreas Kling
+ * Copyright (c) 2024, Sam Atkins
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -12,6 +13,7 @@
#include
#include
#include
+#include
#include
namespace Web::Layout {
@@ -369,8 +371,70 @@ void LayoutState::resolve_layout_dependent_properties()
}
auto const& transform_origin = paintable_box.computed_values().transform_origin();
- // FIXME: respect transform-box property
- auto const& reference_box = paintable_box.absolute_border_box_rect();
+ // https://www.w3.org/TR/css-transforms-1/#transform-box
+ auto transform_box = paintable_box.computed_values().transform_box();
+ // For SVG elements without associated CSS layout box, the used value for content-box is fill-box and for
+ // border-box is stroke-box.
+ // FIXME: This currently detects any SVG element except the