Skip to content

Truly independent web browser

LibWeb: Keep layout run cache entries of discarded column layouts

Aliaksandr Kalenikdc5dd1056448
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index 96d5c2caa70..75103717dd1 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -3770,15 +3770,7 @@ impl<'pass> BlockFormattingContext<'pass> {
early_break_before,
allows_early_break_requests,
));
- let journals_stored_entries = self.run.fragments.is_some();
- let fc_run_cache_store = self.run.callbacks.arena().fc_run_cache_store();
- if journals_stored_entries {
- fc_run_cache_store.begin_store_journal();
- }
let outputs = formatting_context::run_fragmentainer(&self.run, purpose, input, fragmentainer.clone());
- if journals_stored_entries {
- fc_run_cache_store.end_store_journal(fragmentainer.outcome_mut().needs_early_break_before.is_none());
- }
if outputs.result.depends_on_percentage_block_size {
self.used(self.run.box_)
.has_descendant_that_depends_on_percentage_block_size
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
index 7a551ea32be..24180fcd495 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -388,39 +388,9 @@ pub(crate) struct FcRunCacheArenaStore {
inline_layout_damage: RefCell<Vec<InlineLayoutDamage>>,
pending_sweep_slots: RefCell<Vec<u32>>,
enrolled_for_sweep: RefCell<Vec<bool>>,
- store_journals: RefCell<Vec<Vec<u32>>>,
}
impl FcRunCacheArenaStore {
- pub(crate) fn begin_store_journal(&self) {
- self.store_journals.borrow_mut().push(Vec::new());
- }
-
- pub(crate) fn end_store_journal(&self, keeps_stored_entries: bool) {
- let slots = self.store_journals.borrow_mut().pop().expect("a store journal is open");
- if keeps_stored_entries {
- if let Some(enclosing) = self.store_journals.borrow_mut().last_mut() {
- enclosing.extend(slots);
- }
- return;
- }
- for slot in slots {
- self.remove_entry(slot);
- }
- }
-
- pub(crate) fn remove_entries_stored_in_open_journal(&self, slots: impl IntoIterator<Item = u32>) {
- let stored: HashSet<u32> = match self.store_journals.borrow().last() {
- Some(journal) if !journal.is_empty() => journal.iter().copied().collect(),
- _ => return,
- };
- for slot in slots {
- if stored.contains(&slot) {
- self.remove_entry(slot);
- }
- }
- }
-
pub(super) fn enqueue_for_sweep(&self, slot: u32) {
let mut enrolled = self.enrolled_for_sweep.borrow_mut();
if enrolled.len() <= slot as usize {
@@ -565,9 +535,6 @@ impl FcRunCacheArenaStore {
drop(entries);
// The damage counts the structural changes since the stored entry's run.
self.forget_inline_layout_damage(slot);
- if let Some(journal) = self.store_journals.borrow_mut().last_mut() {
- journal.push(slot);
- }
// NB: Invalidation can occur between probing a run and storing its result.
self.enqueue_for_sweep(slot);
}
diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
index b131810f19e..a95927e304d 100644
--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs
@@ -1010,13 +1010,6 @@ impl<'context> InlineFormattingContext<'context> {
self.block_axis_float_clearance.set(clearance);
}
- fn forget_cached_runs_of_subtree(&self, node: Node) {
- let arena = self.callbacks.arena();
- let mut slots = Vec::new();
- arena.for_each_node_in_layout_subtree_in_pre_order(node, |node| slots.push(node.slot_index()));
- arena.fc_run_cache_store().remove_entries_stored_in_open_journal(slots);
- }
-
fn hide_atomic_inline_for_line_clamp(&self, node: Node) {
if let Some(fragments) = self.run.fragments.as_deref() {
fragments.discard_unplaced_subtree(node, self.used(node));
@@ -2175,7 +2168,6 @@ impl<'context> InlineFormattingContext<'context> {
}
for node in dropped_atomic_inlines.into_iter().chain(unconsumed_atomic_inlines) {
fragments.discard_unplaced_subtree(node, self.used(node));
- self.forget_cached_runs_of_subtree(node);
}
}
}