1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 09:27:34 +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

@ -26,16 +26,8 @@ namespace Web::Painting {
static void paint_node(Layout::Node const& layout_node, PaintContext& context, PaintPhase phase)
{
if (auto const* paintable = layout_node.paintable()) {
if (paintable->containing_block() && paintable->containing_block()->is_scrollable()) {
Gfx::PainterStateSaver saver(context.painter());
auto scroll_offset = -paintable->containing_block()->paintable_box()->scroll_offset();
context.painter().translate({ context.enclosing_device_pixels(scroll_offset.x()), context.enclosing_device_pixels(scroll_offset.y()) });
paintable->paint(context, phase);
} else {
paintable->paint(context, phase);
}
}
if (auto const* paintable = layout_node.paintable())
paintable->paint(context, phase);
}
StackingContext::StackingContext(Layout::Box& box, StackingContext* parent, size_t index_in_tree_order)