Truly independent web browser
LibWeb: Begin a layout pass once its stage is prepared
Aliaksandr Kalenik984035f0b375
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 223a8a715f5..f9e92e33e75 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -3638,7 +3638,6 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo/// flex and grid items of the nodes marked for layout, and drops the cached intrinsic sizes of released slots.fn prepare_layout_stage(state: &mut super::ArenaHandle, kind: LayoutStageKind, root: NodeSlotId) {let arena = state.arena();- arena.begin_active_layout_pass();match kind {LayoutStageKind::Root { .. } => {// NB: The tree builder derives the facts of rebuilt subtrees. Unclassified invalidations@@ -3661,6 +3660,7 @@ fn prepare_layout_stage(state: &mut super::ArenaHandle, kind: LayoutStageKind, r}}drop_intrinsic_size_cache_entries_of_released_slots(arena, state.layout_scratch());+ arena.begin_active_layout_pass();}/// Drops the intrinsic size cache entries of the slots the arena let go of, or whose cache epoch wrapped, since thediff --git a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rsindex b4ef07bf6dd..825b003c5c7 100644--- a/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs+++ b/Libraries/LibWeb/Rust/src/layout/layout_node_arena.rs@@ -5588,10 +5588,9 @@ impl LayoutNodeArena {// ancestor. Preserve the structural proof along the same unbounded path as the fragment// epoch bumps so each affected inline context can reuse its unchanged line prefix.// NB: Bumps can legitimately run while another document's layout pass is on the stack (a- // parent pass sizing a child navigable's viewport invalidates the child document), so the- // helpers must not assert against the process-global pass flag. A bump landing between a- // run's probe and its store is handled by storing the probe-time validity, which turns it- // into a fail-safe miss.+ // parent pass sizing a child navigable's viewport invalidates the child document), so only+ // this arena's own pass may not see one. A bump landing between a run's probe and its store+ // is handled by storing the probe-time validity, which turns it into a fail-safe miss.fn invalidate_at_and_above(&self, mut node: NodeSlotId, invalidation: AncestorInvalidation) {while !node.is_invalid() {self.invalidate_one(node, invalidation);@@ -5617,9 +5616,10 @@ impl LayoutNodeArena {if epoch == 0 {self.paintable_rows.invalidate_committed_geometry(node.slot_index());}- if self.layout_pass_is_running() {- self.fragment_cache_epoch_changed_during_layout_pass.set(true);- }+ assert!(+ !self.layout_pass_is_running(),+ "a node's committed fragments became stale while a layout pass ran"+ );self.fc_run_cache_store.note_invalidated_entry(node);// NB: An in-flow block entry is valid for one epoch only, so it never matches again.self.in_flow_block_cache_store.remove_entry(node.slot_index());@@ -7025,11 +7025,6 @@ mod tests {arena.set_committed_fragment_link(node, moved, None);assert_eq!(current(&arena), None);- arena.begin_active_layout_pass();- arena.bump_fragment_cache_epoch_of_self_and_ancestors(node);- commit_from_layout(&arena);- assert!(arena.leave_active_layout_pass());- assert_eq!(current(&arena), None);arena.begin_active_layout_pass();commit_from_layout(&arena);assert!(arena.leave_active_layout_pass());@@ -7043,6 +7038,15 @@ mod tests {assert_eq!(current(&arena), None);}+ #[test]+ #[should_panic(expected = "a node's committed fragments became stale while a layout pass ran")]+ fn no_committed_fragment_goes_stale_while_a_layout_pass_runs() {+ let mut arena = LayoutNodeArena::new();+ let node = arena.allocate_for_test().slot;+ arena.begin_active_layout_pass();+ arena.bump_fragment_cache_epoch_of_self_and_ancestors(node);+ }+#[test]fn node_data_addresses_remain_stable_when_chunks_are_added() {let mut arena = LayoutNodeArena::new();