LibWeb: Introduce a new class responsible for scroll state

It's good to have a wrapper for scroll and sticky state instead of
directly mutating vectors with frames.

No behavior change.
This commit is contained in:
Aliaksandr Kalenik 2024-10-11 19:32:32 +02:00 committed by Alexander Kalenik
commit d07643b122
Notes: github-actions[bot] 2024-10-12 11:14:12 +00:00
7 changed files with 86 additions and 29 deletions

View file

@ -5584,12 +5584,12 @@ RefPtr<Painting::DisplayList> Document::record_display_list(PaintConfig config)
display_list->set_device_pixels_per_css_pixel(page().client().device_pixels_per_css_pixel());
Vector<RefPtr<Painting::ScrollFrame>> scroll_state;
scroll_state.resize(viewport_paintable.scroll_state.size() + viewport_paintable.sticky_state.size());
for (auto& [_, scrollable_frame] : viewport_paintable.scroll_state) {
scroll_state[scrollable_frame->id()] = scrollable_frame;
scroll_state.resize(viewport_paintable.scroll_state().scroll_frames().size() + viewport_paintable.scroll_state().sticky_frames().size());
for (auto const& scroll_frame : viewport_paintable.scroll_state().scroll_frames()) {
scroll_state[scroll_frame->id()] = scroll_frame;
}
for (auto& [_, scrollable_frame] : viewport_paintable.sticky_state) {
scroll_state[scrollable_frame->id()] = scrollable_frame;
for (auto const& scroll_frame : viewport_paintable.scroll_state().sticky_frames()) {
scroll_state[scroll_frame->id()] = scroll_frame;
}
display_list->set_scroll_state(move(scroll_state));