mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Do not mutate display list while scroll offset application
Copy a display list item and apply scroll offset instead of mutating display list directly. It's a preparation for upcoming changes where a display list will be cached across repaints and used multiple times with different scroll offsets.
This commit is contained in:
parent
7ddb94c4d6
commit
e2ad568095
Notes:
github-actions[bot]
2024-08-19 16:58:23 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: e2ad568095
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1106
3 changed files with 32 additions and 24 deletions
|
@ -2128,13 +2128,15 @@ RefPtr<Painting::DisplayList> Navigable::record_display_list(PaintConfig config)
|
|||
|
||||
viewport_paintable.paint_all_phases(context);
|
||||
|
||||
Vector<Gfx::IntPoint> scroll_offsets_by_frame_id;
|
||||
scroll_offsets_by_frame_id.resize(viewport_paintable.scroll_state.size());
|
||||
for (auto [_, scrollable_frame] : viewport_paintable.scroll_state) {
|
||||
auto scroll_offset = context.rounded_device_point(scrollable_frame->cumulative_offset).to_type<int>();
|
||||
scroll_offsets_by_frame_id[scrollable_frame->id] = scroll_offset;
|
||||
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());
|
||||
for (auto& [_, scrollable_frame] : viewport_paintable.scroll_state) {
|
||||
scroll_state[scrollable_frame->id] = scrollable_frame;
|
||||
}
|
||||
display_list_recorder.display_list().apply_scroll_offsets(scroll_offsets_by_frame_id);
|
||||
|
||||
display_list->set_scroll_state(move(scroll_state));
|
||||
|
||||
m_needs_repaint = false;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue