Truly independent web browser
LibWeb: Key layout run cache entries by the parent's frame
Aliaksandr Kalenik4c9b0b4ae7a5
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 1c9125615ff..7b6bf23101f 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -4936,11 +4936,7 @@ impl<'pass> BlockFormattingContext<'pass> {);Some(formatting_context::ChildRunShape {node: child,- key: fc_run_cache::FcRunCacheKey {- fc_type: plan.fc_type,- input: plan.input,- root_cells: cells.get(),- },+ key: fc_run_cache::FcRunCacheKey::new(&self.run.pass, plan.fc_type, plan.input, cells.get()),root_containing_block: plan.root_containing_block,})}diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex b34df6ac47b..c9ff6c8ba58 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -18,6 +18,8 @@ pub(crate) struct FcRunCacheKey {pub(crate) fc_type: formatting_context::FormattingContextType,pub(crate) input: LayoutInput,pub(crate) root_cells: used_values::RootInputCells,+ /// The frame of the formatting context the run's root is laid out in, which holds the input and the root's cells.+ pub(crate) parent_frame: geometry::Frame,}/// The inputs a run never observed, at which its stored outputs are reused as they are.@@ -116,6 +118,21 @@ fn root_input_cells_match_ignoring_unobserved(}impl FcRunCacheKey {+ /// The key of a run probed in `pass`, whose frame is that of the formatting context the run's root is laid out in.+ pub(crate) fn new(+ pass: &LayoutPass<'_>,+ fc_type: formatting_context::FormattingContextType,+ input: LayoutInput,+ root_cells: used_values::RootInputCells,+ ) -> Self {+ Self {+ fc_type,+ input,+ root_cells,+ parent_frame: pass.frame,+ }+ }+/// The key with the root's block paddings left out.fn without_root_block_paddings(&self) -> Self {let mut key = self.clone();@@ -125,7 +142,7 @@ impl FcRunCacheKey {}fn matches(&self, probe: &Self, unobserved: RunInputsTheStoredRunNeverObserved) -> bool {- if self.fc_type != probe.fc_type {+ if self.fc_type != probe.fc_type || self.parent_frame != probe.parent_frame {return false;}if self.root_cells == probe.root_cells && self.input == probe.input {@@ -1014,6 +1031,7 @@ mod tests {ParticipationInParentFormattingContext::AtomicInline,),root_cells: used_values::RootInputCells::default(),+ parent_frame: geometry::Frame::PHYSICAL,}}@@ -1472,6 +1490,7 @@ mod tests {fc_type: formatting_context::FormattingContextType::Block,input,root_cells,+ parent_frame: geometry::Frame::PHYSICAL,};let stored = key_of(item_input.clone());@@ -1606,6 +1625,7 @@ mod tests {ParticipationInParentFormattingContext::Item,),root_cells,+ parent_frame: geometry::Frame::PHYSICAL,}}diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rsindex 1b16f978eab..1240a60f67f 100644--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs@@ -3284,11 +3284,7 @@ impl<'pass> FlexFormattingContext<'pass> {debug_assert_eq!(plan.fc_type, formatting_context::FormattingContextType::Block);Some(formatting_context::ChildRunShape {node,- key: fc_run_cache::FcRunCacheKey {- fc_type: plan.fc_type,- input: plan.input,- root_cells: cells,- },+ key: fc_run_cache::FcRunCacheKey::new(&self.run.pass, plan.fc_type, plan.input, cells),root_containing_block: plan.root_containing_block,})}diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex ba546b04228..c53e8740051 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -2067,11 +2067,7 @@ pub(super) fn run_formatting_context(false,);}- let key = fc_run_cache::FcRunCacheKey {- fc_type,- input,- root_cells,- };+ let key = fc_run_cache::FcRunCacheKey::new(&pass, fc_type, input, root_cells);let attempt = fc_run_cache::FcRunCacheAttempt::probe(box_,subgrid_parent.is_some(),@@ -2110,6 +2106,7 @@ fn run_formatting_context_after_probe(fc_type,ref input,root_cells,+ ..} = *key;let builds_fragments = run_builds_fragments(input, parent_collects_fragments);let cache_attempt = match attempt {@@ -3228,11 +3225,7 @@ pub(crate) fn plan_child_run(percentage_block_insets_of_containing_block_have_definite_basis,);let parent_collects_fragments = run.fragments.is_some();- let key = fc_run_cache::FcRunCacheKey {- fc_type,- input,- root_cells: child_input_cells,- };+ let key = fc_run_cache::FcRunCacheKey::new(&run.pass, fc_type, input, child_input_cells);let attempt = fc_run_cache::FcRunCacheAttempt::probe(child,false,@@ -3392,11 +3385,7 @@ pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding();ChildRunShape {node: cell,- key: fc_run_cache::FcRunCacheKey {- fc_type: plan.fc_type,- input: plan.input,- root_cells: cell_input_cells,- },+ key: fc_run_cache::FcRunCacheKey::new(&run.pass, plan.fc_type, plan.input, cell_input_cells),root_containing_block: plan.root_containing_block,}}@@ -3451,11 +3440,12 @@ impl ChildRunShape {Self {node,root_containing_block: pass.containing_block_for_child_run(node, &input.participation),- key: fc_run_cache::FcRunCacheKey {- fc_type: independent_formatting_context_type(node, pass),+ key: fc_run_cache::FcRunCacheKey::new(+ pass,+ independent_formatting_context_type(node, pass),input,root_cells,- },+ ),}}}@@ -3520,6 +3510,7 @@ pub(crate) fn lay_out_shape_for_its_result(pass: LayoutPass<'_>, shape: ChildRunfc_type,ref input,root_cells,+ ..} = key;let builds_fragments = run_builds_fragments(input, false);let lay_out = |pass: LayoutPass<'_>, root_cells, input: &LayoutInput, previous_line_data| {diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rsindex 60b8240c7c6..2cfd4d6ff71 100644--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs@@ -4802,11 +4802,7 @@ impl<'pass> GridFormattingContext<'pass> {);formatting_context::ChildRunShape {node: item.box_,- key: fc_run_cache::FcRunCacheKey {- fc_type: plan.fc_type,- input: plan.input,- root_cells: cells,- },+ key: fc_run_cache::FcRunCacheKey::new(&self.run.pass, plan.fc_type, plan.input, cells),root_containing_block: plan.root_containing_block,}}