ladybird/Libraries/LibWeb/Painting/NavigableContainerViewportPaintable.h
Aliaksandr Kalenik 8569124b87 LibWeb: Fix scroll state refresh in cached display list for iframes
6507d23 introduced a bug when snapshot for iframe is saved in
`PaintNestedDisplayList` and, since display lists are immutable, it's
not possible to update before the next repaint.

This change fixes the issue by moving `ScrollStateSnapshot` for
nested display lists from `PaintNestedDisplayList` to
`HashMap<NonnullRefPtr<DisplayList>, ScrollStateSnapshot>` that is
placed into pending rendering task, making it possible to update
snapshots for all display lists before the next repaint.

This change doesn't have a test because it's really hard to make a ref
test that will specifically check scenario when scroll offset of an
iframe is advanced after display list is cached. We already have
`Tests/LibWeb/Ref/input/scroll-iframe.html` but unfortunately it did
not catch this bug.

Fixes https://github.com/LadybirdBrowser/ladybird/issues/5486
2025-07-26 11:53:21 -04:00

34 lines
1 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Layout/NavigableContainerViewport.h>
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
class NavigableContainerViewportPaintable final : public PaintableBox {
GC_CELL(NavigableContainerViewportPaintable, PaintableBox);
GC_DECLARE_ALLOCATOR(NavigableContainerViewportPaintable);
public:
virtual bool is_navigable_container_viewport_paintable() const override { return true; }
static GC::Ref<NavigableContainerViewportPaintable> create(Layout::NavigableContainerViewport const&);
virtual void paint(PaintContext&, PaintPhase) const override;
Layout::NavigableContainerViewport const& layout_box() const;
private:
NavigableContainerViewportPaintable(Layout::NavigableContainerViewport const&);
};
template<>
inline bool Paintable::fast_is<NavigableContainerViewportPaintable>() const { return is_navigable_container_viewport_paintable(); }
}