1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

LibWeb/Painting: Translate by scroll offset before painting descendants

Fixes painting of nested nodes in scrollable containers by moving
painter's scroll offset translation from paint_node() to
before_children_paint() and after_children_paint().
This commit is contained in:
Aliaksandr Kalenik 2023-08-08 15:02:35 +02:00 committed by Andreas Kling
parent 325d1553ca
commit cdf8b9e943
3 changed files with 17 additions and 10 deletions

View file

@ -429,6 +429,18 @@ Optional<CSSPixelRect> PaintableBox::calculate_overflow_clipped_rect() const
return m_clip_rect;
}
void PaintableBox::before_children_paint(PaintContext& context, PaintPhase) const
{
auto scroll_offset = -this->scroll_offset();
context.painter().translate({ context.enclosing_device_pixels(scroll_offset.x()), context.enclosing_device_pixels(scroll_offset.y()) });
}
void PaintableBox::after_children_paint(PaintContext& context, PaintPhase) const
{
auto scroll_offset = this->scroll_offset();
context.painter().translate({ context.enclosing_device_pixels(scroll_offset.x()), context.enclosing_device_pixels(scroll_offset.y()) });
}
void PaintableBox::apply_clip_overflow_rect(PaintContext& context, PaintPhase phase) const
{
if (!AK::first_is_one_of(phase, PaintPhase::Background, PaintPhase::Border, PaintPhase::Foreground))