LibWeb: Exclude fixed positioned boxes from scrollable overflow

Sometimes fixed positioned boxes would extend the viewport's scrollable
overflow, which according to the spec should never happen. There are
some nuances to this, such as properly determining the fixed positioning
containing block for a fixed position box, but for now this prevents
some pages from being overly scrollable.

Fixes horizontal scrollability of https://tweakers.net.
This commit is contained in:
Jelle Raaijmakers 2025-04-25 11:54:15 +02:00 committed by Andreas Kling
commit 2fc1cafb8a
Notes: github-actions[bot] 2025-04-25 12:08:40 +00:00
3 changed files with 29 additions and 0 deletions

View file

@ -85,6 +85,13 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box)
if (child.containing_block() != &box)
return TraversalDecision::Continue;
// https://drafts.csswg.org/css-position/#fixed-positioning-containing-block
// [..] As a result, parts of fixed-positioned boxes that extend outside the layout viewport/page area
// cannot be scrolled to and will not print.
// FIXME: Properly establish the fixed positioning containing block for `position: fixed`
if (child.is_fixed_position())
return TraversalDecision::Continue;
auto child_border_box = child.paintable_box()->absolute_border_box_rect();
// Border boxes with zero area do not affect the scrollable overflow area.