From 7ddacef3b591999104a3900d75ddf8037c261130 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 19 Mar 2023 18:43:32 +0300 Subject: [PATCH] LibWeb: Apply border-radius clip only if overflow hidden for both axis Before this change `apply_clip_overflow_rect` might crash trying to access `clip_rect` that does not have value because we currently support calculation of visible rectangle when `overflow: hidden` is applied for both axis. --- .../expected/overflow-x-hidden-with-border-radius.txt | 6 ++++++ .../input/overflow-x-hidden-with-border-radius.html | 10 ++++++++++ Userland/Libraries/LibWeb/Painting/PaintableBox.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/overflow-x-hidden-with-border-radius.txt create mode 100644 Tests/LibWeb/Layout/input/overflow-x-hidden-with-border-radius.html diff --git a/Tests/LibWeb/Layout/expected/overflow-x-hidden-with-border-radius.txt b/Tests/LibWeb/Layout/expected/overflow-x-hidden-with-border-radius.txt new file mode 100644 index 0000000000..3924114199 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/overflow-x-hidden-with-border-radius.txt @@ -0,0 +1,6 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x118 children: not-inline + BlockContainer at (8,8) content-size 784x102 children: not-inline + BlockContainer at (9,9) content-size 100x100 positioned children: not-inline + BlockContainer <(anonymous)> at (8,110) content-size 784x0 children: inline + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/overflow-x-hidden-with-border-radius.html b/Tests/LibWeb/Layout/input/overflow-x-hidden-with-border-radius.html new file mode 100644 index 0000000000..ac73bdb735 --- /dev/null +++ b/Tests/LibWeb/Layout/input/overflow-x-hidden-with-border-radius.html @@ -0,0 +1,10 @@ +
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp index 21f5df6708..9e08873765 100644 --- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp +++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp @@ -363,7 +363,7 @@ void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase ph clip_overflow(); } - if (overflow_y == CSS::Overflow::Hidden || overflow_x == CSS::Overflow::Hidden) { + if (overflow_y == CSS::Overflow::Hidden && overflow_x == CSS::Overflow::Hidden) { auto border_radii_data = normalized_border_radii_data(ShrinkRadiiForBorders::Yes); if (border_radii_data.has_any_radius()) { auto corner_clipper = BorderRadiusCornerClipper::create(context, context.rounded_device_rect(*clip_rect), border_radii_data, CornerClip::Outside, BorderRadiusCornerClipper::UseCachedBitmap::No);