LibWeb: Fix infinite repaint loop when cached display list is used

Before this change, `m_needs_repaint` was reset in
`Document::record_display_list()` only when the cached display list was
absent. This meant that if the last triggered repaint used the cached
display list, we would keep repainting indefinitely until the display
list was invalidated (We schedule a task that checks if repainting is
required 60/s).

This change also moves `m_needs_repaint` from Document to
TraversableNavigable as we only ever need to repaint a document that
belongs to traversable.
This commit is contained in:
Aliaksandr Kalenik 2025-02-01 19:33:18 +01:00 committed by Andreas Kling
commit 0c5b61b7e1
Notes: github-actions[bot] 2025-02-01 22:32:14 +00:00
9 changed files with 17 additions and 25 deletions

View file

@ -6093,8 +6093,6 @@ void Document::set_needs_display(CSSPixelRect const&, InvalidateDisplayList shou
// FIXME: Ignore updates outside the visible viewport rect.
// This requires accounting for fixed-position elements in the input rect, which we don't do yet.
m_needs_repaint = true;
if (should_invalidate_display_list == InvalidateDisplayList::Yes) {
invalidate_display_list();
}
@ -6104,6 +6102,7 @@ void Document::set_needs_display(CSSPixelRect const&, InvalidateDisplayList shou
return;
if (navigable->is_traversable()) {
navigable->traversable_navigable()->set_needs_repaint();
Web::HTML::main_thread_event_loop().schedule();
return;
}
@ -6188,8 +6187,6 @@ RefPtr<Painting::DisplayList> Document::record_display_list(PaintConfig config)
display_list->set_device_pixels_per_css_pixel(page().client().device_pixels_per_css_pixel());
display_list->set_scroll_state(viewport_paintable.scroll_state());
m_needs_repaint = false;
m_cached_display_list = display_list;
m_cached_display_list_paint_config = config;