Truly independent web browser
LibWeb: Make cold test recordings rebuild the visual context tree
Aliaksandr Kalenikba24bd602d41
diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex 5811b090d9f..569850df2fa 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -1657,8 +1657,9 @@ void Internals::record_display_list_for_testing(bool paint_overlay, bool cold)document.update_layout(DOM::UpdateLayoutReason::InternalsHitTest);if (!document.navigable() || !document.has_committed_viewport_box())return;+ // A recording against a visual context tree built fresh copies nothing from the published one.if (cold)- document.paint_state().invalidate_all_cached_paint(document);+ document.schedule_full_accumulated_visual_context_rebuild(Layout::RustFFI::VisualContextUpdateScope::FreshTree);(void)document.record_display_list(read, HTML::PaintConfig { .paint_overlay = paint_overlay }, document.navigable()->display_list_resource_storage(), Painting::PaintCommandCacheMode::ReadWrite);}diff --git a/Tests/LibWeb/BenchmarkDisplayListRecording.cpp b/Tests/LibWeb/BenchmarkDisplayListRecording.cppindex adb75f5edef..5cd3a7232e1 100644--- a/Tests/LibWeb/BenchmarkDisplayListRecording.cpp+++ b/Tests/LibWeb/BenchmarkDisplayListRecording.cpp@@ -352,8 +352,11 @@ void time_document_recordings(DocumentShape shape, StringView label, Optional<Muapply_mutation(loaded_page, *mutation);document.update_layout(Web::DOM::UpdateLayoutReason::Debugging);layout_samples.microseconds.append(layout_timer.elapsed_time().to_microseconds());- if (cache_state == CacheState::Cold)- document.paint_state().invalidate_all_cached_paint(document);+ // The fresh visual context tree is built before the timer starts, so only the recording is timed.+ if (cache_state == CacheState::Cold) {+ document.schedule_full_accumulated_visual_context_rebuild(Web::Layout::RustFFI::VisualContextUpdateScope::FreshTree);+ document.update_paint_and_hit_testing_properties_if_needed();+ }Web::Layout::ForcedReadScope read { document };auto timer = Core::ElapsedTimer::start_new(Core::TimerType::Precise);auto display_list = document.record_display_list(read, benchmark_paint_config(), loaded_page.display_list_resource_storage, Web::Painting::PaintCommandCacheMode::ReadWrite);diff --git a/Tests/LibWeb/Text/input/display_list/paint-cache-first-recording-and-relayout.html b/Tests/LibWeb/Text/input/display_list/paint-cache-first-recording-and-relayout.htmlindex 092cb9a3e0d..2754fda5b26 100644--- a/Tests/LibWeb/Text/input/display_list/paint-cache-first-recording-and-relayout.html+++ b/Tests/LibWeb/Text/input/display_list/paint-cache-first-recording-and-relayout.html@@ -25,7 +25,7 @@ displayListTest({name: "cold recording",cold: true,expect: `- damage: rows=0 moved=0 order=0 eligibility=0 all=true+ damage: rows=6 moved=0 order=0 eligibility=0 all=true@canvas RECORD (empty)@viewport RECORD@viewport/preamble RECORD (empty)