layout: Cache SameFormattingContextBlock layout results (#42904)

Add a cache for `SameFormattingContextBlock`s: A new kind of cache
is added which allows reusing fragments for
`SameFormattingContextBlock` (the majority of block level elements).
This can reduce the amount of fragment tree construction during
incremental layout (although with a 40 byte overhead per
`SameFormattingContextBlock`).

Testing: This change adds a new Servo-specific WPT test that verifies
that
the minimal number of `Fragment`s are rebuilt after an incremental
layout.
Previously, when running `flexbox-deeply-nested-column-flow.html` from
`tests/blink_perf_tests/perf_tests/layout/`, performance would degrade
with successive test runs. This is due to how slow inline layout is.
This change
removes that progressive degradation, though we may be able to remove
this cache with improvements to inline layout.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson
2026-04-16 14:04:39 +02:00
committed by GitHub
parent 562609f876
commit 8da073a80c
19 changed files with 327 additions and 64 deletions

View File

@@ -626,8 +626,13 @@ impl ReflowPhasesRun {
#[derive(Debug, Default)]
pub struct ReflowStatistics {
/// A count of the number of fragments that have been completely rebuilt.
pub rebuilt_fragment_count: u32,
/// A count of the number of fragments that are reused, but have had their style change.
pub restyle_fragment_count: u32,
/// A count of the number of fragments that are reused, but may have had their final
/// position change.
pub possibly_moved_fragment_count: u32,
}
/// Information needed for a script-initiated reflow that requires a restyle