From 877ddaa016514d1413160c6ff3f091774f197e6b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 23 Oct 2021 16:06:29 +0200 Subject: [PATCH] LibWeb: Fix off-by-one in initial containing block overflow calculation We're using the outermost right and bottom child edges to determine the width and height of the ICB. However, since these edges are *within* the respective child's rectangle, we have to add 1 when turning them into width and height values. This fixes an issue where scrolling a document would shrink its viewport rect by 1 pixel (on both axes) on every scroll step. --- Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp index 97668287ea..039700a7ed 100644 --- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp @@ -589,7 +589,8 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) { auto& overflow_data = icb.ensure_overflow_data(); overflow_data.scrollable_overflow_rect = viewport_rect.to_type(); - overflow_data.scrollable_overflow_rect.set_size(right_edge, bottom_edge); + // NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height. + overflow_data.scrollable_overflow_rect.set_size(right_edge + 1, bottom_edge + 1); } else { icb.clear_overflow_data(); }