From 9c8aa5b777563a27a1864a40ffb5c82abb40c3fa Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 7 Aug 2022 23:28:14 +0100 Subject: [PATCH] LibWeb: Fix resolution of CSS clip rect Previously the clip rect was not relative to the top/left egdes of the element, which lead to it being positioned incorrectly. This fixes the clip-rect-auto-004 and clip-rect-auto-005 web platform tests. --- Userland/Libraries/LibWeb/CSS/StyleValue.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp index debeddd600..bc744d7f80 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.cpp @@ -849,11 +849,15 @@ Gfx::FloatRect EdgeRect::resolved(Layout::Node const& layout_node, Gfx::FloatRec // widths for , and the same as the used value of the width plus the sum of the // horizontal padding and border widths for , such that four 'auto' values result in the // clipping region being the same as the element's border box). + auto left = border_box.left() + (left_edge.is_auto() ? 0 : left_edge.to_px(layout_node)); + auto top = border_box.top() + (top_edge.is_auto() ? 0 : top_edge.to_px(layout_node)); + auto right = border_box.left() + (right_edge.is_auto() ? border_box.width() : right_edge.to_px(layout_node)); + auto bottom = border_box.top() + (bottom_edge.is_auto() ? border_box.height() : bottom_edge.to_px(layout_node)); return Gfx::FloatRect { - left_edge.is_auto() ? 0 : left_edge.to_px(layout_node), - top_edge.is_auto() ? 0 : top_edge.to_px(layout_node), - right_edge.is_auto() ? border_box.width() : right_edge.to_px(layout_node) - left_edge.to_px(layout_node), - bottom_edge.is_auto() ? border_box.height() : bottom_edge.to_px(layout_node) - top_edge.to_px(layout_node) + left, + top, + right - left, + bottom - top }; }