diff --git a/Tests/LibWeb/Ref/reference/transform-box-ref.html b/Tests/LibWeb/Ref/reference/transform-box-ref.html
new file mode 100644
index 00000000000..39023f4a6c5
--- /dev/null
+++ b/Tests/LibWeb/Ref/reference/transform-box-ref.html
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/Tests/LibWeb/Ref/transform-box.html b/Tests/LibWeb/Ref/transform-box.html
new file mode 100644
index 00000000000..abe6dbb8f51
--- /dev/null
+++ b/Tests/LibWeb/Ref/transform-box.html
@@ -0,0 +1,10 @@
+
+
+
+
+
diff --git a/Userland/Libraries/LibWeb/CSS/Transformation.cpp b/Userland/Libraries/LibWeb/CSS/Transformation.cpp
index 1ca1aa957af..644c3dcbb03 100644
--- a/Userland/Libraries/LibWeb/CSS/Transformation.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Transformation.cpp
@@ -47,7 +47,7 @@ ErrorOr Transformation::to_matrix(Optionalabsolute_padding_box_rect();
+ auto reference_box = paintable_box->transform_box_rect();
width = reference_box.width();
height = reference_box.height();
}
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
index fd648c66280..6fd2fc27e85 100644
--- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
+++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
@@ -969,6 +969,72 @@ Optional PaintableBox::get_masking_area() const
return absolute_border_box_rect();
}
+// https://www.w3.org/TR/css-transforms-1/#transform-box
+CSSPixelRect PaintableBox::transform_box_rect() const
+{
+ auto transform_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