|
46 | 46 | #include <LibWeb/Loader/GeneratedPagesLoader.h>
|
47 | 47 | #include <LibWeb/Page/Page.h>
|
48 | 48 | #include <LibWeb/Painting/DisplayListPlayerSkia.h>
|
| 49 | +#include <LibWeb/Painting/NavigableContainerViewportPaintable.h> |
49 | 50 | #include <LibWeb/Painting/Paintable.h>
|
50 | 51 | #include <LibWeb/Painting/ViewportPaintable.h>
|
51 | 52 | #include <LibWeb/Platform/EventLoopPlugin.h>
|
@@ -2612,14 +2613,35 @@ void Navigable::start_display_list_rendering(Gfx::PaintingSurface& painting_surf
|
2612 | 2613 | callback();
|
2613 | 2614 | return;
|
2614 | 2615 | }
|
2615 |
| - document->paintable()->refresh_scroll_state(); |
2616 | 2616 | auto display_list = document->record_display_list(paint_config);
|
2617 | 2617 | if (!display_list) {
|
2618 | 2618 | callback();
|
2619 | 2619 | return;
|
2620 | 2620 | }
|
2621 |
| - auto scroll_state_snapshot = document->paintable()->scroll_state().snapshot(); |
2622 |
| - m_rendering_thread.enqueue_rendering_task(*display_list, move(scroll_state_snapshot), painting_surface, move(callback)); |
| 2621 | + |
| 2622 | + auto& document_paintable = *document->paintable(); |
| 2623 | + Painting::ScrollStateSnapshotByDisplayList scroll_state_snapshot_by_display_list; |
| 2624 | + document_paintable.refresh_scroll_state(); |
| 2625 | + auto scroll_state_snapshot = document_paintable.scroll_state().snapshot(); |
| 2626 | + scroll_state_snapshot_by_display_list.set(*display_list, move(scroll_state_snapshot)); |
| 2627 | + // Collect scroll state snapshots for each nested navigable |
| 2628 | + document_paintable.for_each_in_inclusive_subtree_of_type<Painting::NavigableContainerViewportPaintable>([&scroll_state_snapshot_by_display_list](auto& navigable_container_paintable) { |
| 2629 | + auto const* hosted_document = navigable_container_paintable.layout_box().dom_node().content_document_without_origin_check(); |
| 2630 | + if (!hosted_document || !hosted_document->paintable()) |
| 2631 | + return TraversalDecision::Continue; |
| 2632 | + // We are only interested in collecting scroll state snapshots for visible nested navigables, which is |
| 2633 | + // detectable by checking if they have a cached display list that should've been populated by |
| 2634 | + // record_display_list() on top-level document. |
| 2635 | + auto navigable_display_list = hosted_document->cached_display_list(); |
| 2636 | + if (!navigable_display_list) |
| 2637 | + return TraversalDecision::Continue; |
| 2638 | + const_cast<DOM::Document&>(*hosted_document).paintable()->refresh_scroll_state(); |
| 2639 | + auto navigable_scroll_state_snapshot = hosted_document->paintable()->scroll_state().snapshot(); |
| 2640 | + scroll_state_snapshot_by_display_list.set(*navigable_display_list, move(navigable_scroll_state_snapshot)); |
| 2641 | + return TraversalDecision::Continue; |
| 2642 | + }); |
| 2643 | + |
| 2644 | + m_rendering_thread.enqueue_rendering_task(*display_list, move(scroll_state_snapshot_by_display_list), painting_surface, move(callback)); |
2623 | 2645 | }
|
2624 | 2646 |
|
2625 | 2647 | RefPtr<Gfx::SkiaBackendContext> Navigable::skia_backend_context() const
|
|
0 commit comments