mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user