Truly independent web browser
LibWeb: Check the slot generation of committed fragment link reads
Andreas Kling1f7b256d1c6a
diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rsindex 1a526cd408c..478542dc2b8 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs@@ -384,7 +384,7 @@ fn previously_committed_fragment_matching(}callbacks.arena()- .with_committed_fragment_link_during_layout(candidate.node, |previous_link| {+ .with_committed_fragment_link(candidate.node, |previous_link| {previous_link.filter(|previous_link| candidate.builds_identically_to(&previous_link.fragment)).map(|previous_link| previous_link.fragment.clone())diff --git a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rsindex 6ff7e612656..5217a0fc96c 100644--- a/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs+++ b/Libraries/LibWeb/Rust/src/layout/partial_relayout.rs@@ -430,7 +430,7 @@ impl LayoutNodeArena {let committed = if node_facts::node_style_view(data).is_some_and(|style| style.is_absolutely_positioned()) {self.saved_abspos_layout_inputs(data)?.containing_block} else {- self.with_committed_fragment_link_during_layout(node, |link| link.map(|link| link.containing_block))?+ self.with_committed_fragment_link(node, |link| link.map(|link| link.containing_block))?};(!committed.is_invalid() && committed == self.containing_block_by_walking_ancestors(node)).then_some(committed)}diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rsindex 06e73715982..aedd5bb1cf1 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_rows.rs@@ -554,8 +554,12 @@ where}impl CommittedFragmentLinkSlot {- pub(crate) fn link(&self) -> Option<&fragment_tree::FragmentLink> {- self.link.as_ref()+ /// The link this slot holds for the box with the given layout slot generation, if it holds+ /// one for that box and not for a box that held the slot before.+ pub(crate) fn link_for(&self, layout_slot_generation: u8) -> Option<&fragment_tree::FragmentLink> {+ (self.layout_slot_generation == layout_slot_generation)+ .then_some(self.link.as_ref())+ .flatten()}}@@ -626,8 +630,7 @@ impl PaintableRowStore {read(slots.get(layout_slot_index as usize)- .filter(|slot| slot.layout_slot_generation == layout_slot_generation)- .and_then(|slot| slot.link.as_ref()),+ .and_then(|slot| slot.link_for(layout_slot_generation)),)}@@ -797,24 +800,12 @@ impl LayoutNodeArena {PaintableRows { arena: self }}+ /// The fragment link committed for `node`. A layout reaches boxes whose paintable row is not populated yet, and a+ /// slot can still hold the link of the box that held it before, which belongs to no box of this generation.pub(crate) fn with_committed_fragment_link<R>(&self,node: NodeSlotId,read: impl FnOnce(Option<&fragment_tree::FragmentLink>) -> R,- ) -> R {- debug_assert!(self.paintable_row_is_populated(node));- let slots = self.paintable_rows.committed_fragment_links.borrow();- read(- slots- .get(node.slot_index() as usize)- .and_then(|entry| entry.link.as_ref()),- )- }-- pub(crate) fn with_committed_fragment_link_during_layout<R>(- &self,- node: NodeSlotId,- read: impl FnOnce(Option<&fragment_tree::FragmentLink>) -> R,) -> R {self.paintable_rows.with_committed_fragment_link(node.slot_index(), node.generation(), read)diff --git a/Libraries/LibWeb/Rust/src/painting/published_frame.rs b/Libraries/LibWeb/Rust/src/painting/published_frame.rsindex 145b0099a62..ad8d3563934 100644--- a/Libraries/LibWeb/Rust/src/painting/published_frame.rs+++ b/Libraries/LibWeb/Rust/src/painting/published_frame.rs@@ -109,11 +109,10 @@ impl PublishedRows {id: NodeSlotId,read: impl FnOnce(Option<&FragmentLink>) -> R,) -> R {- debug_assert!(self.paintable_row_is_populated(id));read(self.fragment_links.get(id.slot_index() as usize)- .and_then(CommittedFragmentLinkSlot::link),+ .and_then(|slot| slot.link_for(id.generation())),)}