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.
This commit is contained in:
Andreas Kling 2021-10-23 16:06:29 +02:00
commit 877ddaa016
Notes: sideshowbarker 2024-07-18 02:13:10 +09:00

View file

@ -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<float>();
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();
}