mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:27:35 +00:00
LibWeb: Use offset of nearest scrollable ancestor for positioned boxes
Because positioned descendants are painted out-of-order we need to separately apply offset of nearest scrollable box for them. Fixes https://github.com/SerenityOS/serenity/issues/20554
This commit is contained in:
parent
2952f01e84
commit
6b79508c08
5 changed files with 167 additions and 0 deletions
|
@ -226,6 +226,13 @@ void StackingContext::paint_internal(PaintContext& context) const
|
|||
: TraversalDecision::Continue;
|
||||
}
|
||||
|
||||
// Apply scroll offset of nearest scrollable ancestor before painting the positioned descendant.
|
||||
PaintableBox const* nearest_scrollable_ancestor = nullptr;
|
||||
if (paintable.is_paintable_box())
|
||||
nearest_scrollable_ancestor = static_cast<PaintableBox const&>(paintable).nearest_scrollable_ancestor();
|
||||
if (nearest_scrollable_ancestor)
|
||||
nearest_scrollable_ancestor->apply_scroll_offset(context, PaintPhase::Foreground);
|
||||
|
||||
// At this point, `paintable_box` is a positioned descendant with z-index: auto.
|
||||
// FIXME: This is basically duplicating logic found elsewhere in this same function. Find a way to make this more elegant.
|
||||
auto exit_decision = TraversalDecision::Continue;
|
||||
|
@ -247,6 +254,9 @@ void StackingContext::paint_internal(PaintContext& context) const
|
|||
if (containing_block_paintable)
|
||||
containing_block_paintable->clear_clip_overflow_rect(context, PaintPhase::Foreground);
|
||||
|
||||
if (nearest_scrollable_ancestor)
|
||||
nearest_scrollable_ancestor->reset_scroll_offset(context, PaintPhase::Foreground);
|
||||
|
||||
return exit_decision;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue