Skip to content

Truly independent web browser

LibWeb: Let a run's parent own its run cache key

Aliaksandr Kalenikee8527f82547
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index e883b5e436a..8c78cd004c9 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -4774,9 +4774,11 @@ impl<'pass> BlockFormattingContext<'pass> {
);
Some(formatting_context::ChildRunShape {
node: child,
- fc_type: plan.fc_type,
- input: plan.input,
- root_cells: cells.get(),
+ key: fc_run_cache::FcRunCacheKey {
+ fc_type: plan.fc_type,
+ input: plan.input,
+ root_cells: 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.rs
index c83a856ce44..7ad30154ac9 100644
--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs
@@ -11,12 +11,13 @@ use super::*;
/// value a parent hands a spawned run that the run reads is part of the
/// key. Viewport changes reach a run through that input or through the
/// normal style/layout epoch invalidation for viewport-dependent computed
-/// values.
-#[derive(Clone, PartialEq)]
-pub(super) struct FcRunCacheKey {
- fc_type: formatting_context::FormattingContextType,
- input: LayoutInput,
- root_cells: used_values::RootInputCells,
+/// values. The parent of the run holds it, and only a run whose outputs are
+/// stored copies it.
+#[derive(Clone, Debug, PartialEq)]
+pub(crate) struct FcRunCacheKey {
+ pub(crate) fc_type: formatting_context::FormattingContextType,
+ pub(crate) input: LayoutInput,
+ pub(crate) root_cells: used_values::RootInputCells,
}
/// The inputs a run never observed, at which its stored outputs are reused as they are.
@@ -115,26 +116,6 @@ fn root_input_cells_match_ignoring_unobserved(
}
impl FcRunCacheKey {
- pub(super) fn new(
- fc_type: formatting_context::FormattingContextType,
- input: LayoutInput,
- root_cells: used_values::RootInputCells,
- ) -> Self {
- Self {
- fc_type,
- input,
- root_cells,
- }
- }
-
- fn as_probe(&self) -> FcRunCacheProbe<'_> {
- FcRunCacheProbe {
- fc_type: self.fc_type,
- input: &self.input,
- root_cells: self.root_cells,
- }
- }
-
/// The key with the root's block paddings left out.
fn without_root_block_paddings(&self) -> Self {
let mut key = self.clone();
@@ -143,16 +124,11 @@ impl FcRunCacheKey {
key
}
- #[cfg(test)]
fn matches(&self, probe: &Self, unobserved: RunInputsTheStoredRunNeverObserved) -> bool {
- self.matches_probe(&probe.as_probe(), unobserved)
- }
-
- fn matches_probe(&self, probe: &FcRunCacheProbe<'_>, unobserved: RunInputsTheStoredRunNeverObserved) -> bool {
if self.fc_type != probe.fc_type {
return false;
}
- if self.root_cells == probe.root_cells && self.input == *probe.input {
+ if self.root_cells == probe.root_cells && self.input == probe.input {
return true;
}
if !unobserved.relaxes_any_input() {
@@ -163,31 +139,7 @@ impl FcRunCacheKey {
probe.root_cells,
unobserved.own_block_size,
unobserved.inline_space_around_root,
- ) && layout_inputs_match_ignoring_unobserved(&self.input, probe.input, unobserved)
- }
-}
-
-pub(super) struct FcRunCacheProbe<'input> {
- fc_type: formatting_context::FormattingContextType,
- input: &'input LayoutInput,
- root_cells: used_values::RootInputCells,
-}
-
-impl<'input> FcRunCacheProbe<'input> {
- pub(super) fn new(
- fc_type: formatting_context::FormattingContextType,
- input: &'input LayoutInput,
- root_cells: used_values::RootInputCells,
- ) -> Self {
- Self {
- fc_type,
- input,
- root_cells,
- }
- }
-
- fn key(&self) -> FcRunCacheKey {
- FcRunCacheKey::new(self.fc_type, self.input.clone(), self.root_cells)
+ ) && layout_inputs_match_ignoring_unobserved(&self.input, &probe.input, unobserved)
}
}
@@ -364,10 +316,10 @@ impl FcRunCacheEntry {
/// Whether the absolutely positioned boxes the stored run laid out against its root would be laid out against the
/// same root block size by the probed run, where they are all that observed the root's own block size.
- fn probe_leaves_root_with_block_size_its_abspos_were_laid_out_against(&self, probe: &FcRunCacheProbe<'_>) -> bool {
+ fn probe_leaves_root_with_block_size_its_abspos_were_laid_out_against(&self, probe: &FcRunCacheKey) -> bool {
self.outputs.inputs_never_observed.own_block_size
!= formatting_context::OwnBlockSizeObservation::ObservedOnlyByAbsposContainedByRoot
- || self.content_block_size_run_leaves_root_whose_cells_its_parent_owns(probe.input, probe.root_cells)
+ || self.content_block_size_run_leaves_root_whose_cells_its_parent_owns(&probe.input, probe.root_cells)
== self.content_block_size_run_leaves_root_whose_cells_its_parent_owns(
&self.key.input,
self.key.root_cells,
@@ -403,15 +355,14 @@ impl FcRunCacheEntry {
> LAYOUT_COMMITS_AN_UNCOMMITTED_ENTRY_SURVIVES_UNUSED
}
- fn answers_probe_for(&self, probe: &FcRunCacheProbe<'_>) -> bool {
+ fn answers_probe_for(&self, probe: &FcRunCacheKey) -> bool {
let unobserved = self.outputs.inputs_never_observed;
- (self.key.matches_probe(probe, unobserved)
- || (self.table_cell_block_paddings_unobserved && {
- let probe_key = probe.key().without_root_block_paddings();
- self.key
+ (self.key.matches(probe, unobserved)
+ || (self.table_cell_block_paddings_unobserved
+ && self
+ .key
.without_root_block_paddings()
- .matches_probe(&probe_key.as_probe(), unobserved)
- }))
+ .matches(&probe.without_root_block_paddings(), unobserved)))
&& self.probe_leaves_root_with_block_size_its_abspos_were_laid_out_against(probe)
}
}
@@ -620,7 +571,7 @@ impl FcRunCacheStore {
&self,
box_: Node,
validity: FcRunCacheValidity,
- probe: &FcRunCacheProbe<'_>,
+ key: &FcRunCacheKey,
) -> Option<std::sync::Arc<FcRunCacheEntry>> {
let structural_epoch_bumps = self.structural_epoch_bumps_of(box_);
let entry_was_damaged_since_stored = |entry: &FcRunCacheEntry| {
@@ -629,8 +580,8 @@ impl FcRunCacheStore {
entry.outputs.root.is_some()
&& structural_epoch_bumps_since_stored != 0
&& entry.validity.slot_generation == validity.slot_generation
- && entry.key.matches_probe(
- probe,
+ && entry.key.matches(
+ key,
entry
.outputs
.inputs_never_observed
@@ -830,7 +781,7 @@ impl FcRunCacheAttempt {
should_collect_devtools_layout_data: bool,
measurement_root_keeps_its_result: bool,
callbacks: &LayoutPass<'_>,
- probe: &FcRunCacheProbe<'_>,
+ key: &FcRunCacheKey,
) -> Result<Self, FcRunCacheHit> {
if !can_describe_run(
box_,
@@ -838,7 +789,7 @@ impl FcRunCacheAttempt {
should_collect_devtools_layout_data,
measurement_root_keeps_its_result,
callbacks,
- probe,
+ key,
) {
return Ok(Self::Bypass);
}
@@ -848,7 +799,7 @@ impl FcRunCacheAttempt {
if let Some(entry) = store.first_entry_where_summary_allows(
box_.slot_index(),
|summary| summary.may_answer_probe(validity, false),
- |entry| entry.validity == validity && entry.answers_probe_for(probe),
+ |entry| entry.validity == validity && entry.answers_probe_for(key),
) {
entry.note_used_at_layout_commit(callbacks.arena().layout_commit_count());
return Err(FcRunCacheHit { entry });
@@ -858,14 +809,14 @@ impl FcRunCacheAttempt {
if let Some(entry) = store.first_entry_where_summary_allows(
box_.slot_index(),
|summary| summary.may_answer_probe(validity, true),
- |entry| entry.validity == validity && entry.outputs.root.is_some() && entry.answers_probe_for(probe),
+ |entry| entry.validity == validity && entry.outputs.root.is_some() && entry.answers_probe_for(key),
) {
// NB: Once the replayed fragments are committed, the sweep keeps the entry beside later ones.
store.enqueue_for_sweep(box_.slot_index());
entry.note_used_at_layout_commit(callbacks.arena().layout_commit_count());
return Err(FcRunCacheHit { entry });
}
- let structurally_damaged_entry = store.structurally_damaged_entry(box_, validity, probe);
+ let structurally_damaged_entry = store.structurally_damaged_entry(box_, validity, key);
Ok(Self::Store {
validity,
structurally_damaged_entry,
@@ -878,7 +829,7 @@ impl FcRunCacheAttempt {
should_collect_devtools_layout_data: bool,
measurement_root_keeps_its_result: bool,
callbacks: &LayoutPass<'_>,
- probe: &FcRunCacheProbe<'_>,
+ key: &FcRunCacheKey,
) -> bool {
if !can_describe_run(
box_,
@@ -886,7 +837,7 @@ impl FcRunCacheAttempt {
should_collect_devtools_layout_data,
measurement_root_keeps_its_result,
callbacks,
- probe,
+ key,
) {
return false;
}
@@ -899,7 +850,7 @@ impl FcRunCacheAttempt {
|entry| {
entry.validity == validity
&& (!builds_fragments || entry.outputs.root.is_some())
- && entry.answers_probe_for(probe)
+ && entry.answers_probe_for(key)
},
)
.is_some()
@@ -922,7 +873,7 @@ impl FcRunCacheAttempt {
self,
callbacks: &LayoutPass<'_>,
box_: Node,
- probe: &FcRunCacheProbe<'_>,
+ key: &FcRunCacheKey,
outputs: formatting_context::RunOutputs,
) -> formatting_context::RunOutputsHandle {
let store = callbacks.fc_run_cache_store();
@@ -933,7 +884,7 @@ impl FcRunCacheAttempt {
return formatting_context::RunOutputsHandle::Stored(store.store(
box_,
FcRunCacheEntry {
- key: probe.key(),
+ key: key.clone(),
validity,
outputs,
table_cell_block_paddings_unobserved: false,
@@ -959,7 +910,7 @@ impl FcRunCacheAttempt {
&& outputs.root_outcome.parent_owns_root_input_cells()
&& !run_observes_root_block_padding(callbacks, box_, &outputs);
let entry = FcRunCacheEntry {
- key: probe.key(),
+ key: key.clone(),
validity,
outputs,
table_cell_block_paddings_unobserved,
@@ -978,10 +929,10 @@ pub(super) fn can_describe_run(
should_collect_devtools_layout_data: bool,
measurement_root_keeps_its_result: bool,
callbacks: &LayoutPass<'_>,
- probe: &FcRunCacheProbe<'_>,
+ key: &FcRunCacheKey,
) -> bool {
- let fc_type = probe.fc_type;
- let input = probe.input;
+ let fc_type = key.fc_type;
+ let input = &key.input;
if should_collect_devtools_layout_data
|| (input.participation == ParticipationInParentFormattingContext::Root && !measurement_root_keeps_its_result)
|| fc_type == formatting_context::FormattingContextType::InternalReplaced
@@ -1480,7 +1431,7 @@ mod tests {
fragment_cache_epoch: 3,
};
let damaged = store
- .structurally_damaged_entry(box_, damaged_validity, &at(300).as_probe())
+ .structurally_damaged_entry(box_, damaged_validity, &at(300))
.expect("the entry stored before the damage supplies its line data");
assert_eq!(
damaged.key.input.available_space.inline_size,
@@ -1489,7 +1440,7 @@ mod tests {
store.note_inline_layout_damage(box_);
assert!(
store
- .structurally_damaged_entry(box_, damaged_validity, &at(300).as_probe())
+ .structurally_damaged_entry(box_, damaged_validity, &at(300))
.is_none()
);
}
@@ -1505,7 +1456,11 @@ mod tests {
ContainingBlockConstraints::default(),
ParticipationInParentFormattingContext::Item,
);
- let key_of = |input| FcRunCacheKey::new(formatting_context::FormattingContextType::Block, input, root_cells);
+ let key_of = |input| FcRunCacheKey {
+ fc_type: formatting_context::FormattingContextType::Block,
+ input,
+ root_cells,
+ };
let stored = key_of(item_input.clone());
let mut adopting_input = item_input;
@@ -1624,9 +1579,9 @@ mod tests {
has_definite_block_size,
..used_values::RootInputCells::default()
};
- FcRunCacheKey::new(
- formatting_context::FormattingContextType::Block,
- LayoutInput::new(
+ FcRunCacheKey {
+ fc_type: formatting_context::FormattingContextType::Block,
+ input: LayoutInput::new(
AvailableSpace {
inline_size: AvailableSize::definite(px(300)),
block_size: if has_definite_block_size {
@@ -1639,7 +1594,7 @@ mod tests {
ParticipationInParentFormattingContext::Item,
),
root_cells,
- )
+ }
}
fn own_block_size(observation: formatting_context::OwnBlockSizeObservation) -> RunInputsTheStoredRunNeverObserved {
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index 8a08b24b094..d2d51876e33 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -3414,9 +3414,11 @@ impl<'pass> FlexFormattingContext<'pass> {
debug_assert_eq!(plan.fc_type, formatting_context::FormattingContextType::Block);
Some(formatting_context::ChildRunShape {
node,
- fc_type: plan.fc_type,
- input: plan.input,
- root_cells: cells,
+ key: fc_run_cache::FcRunCacheKey {
+ fc_type: plan.fc_type,
+ input: plan.input,
+ root_cells: 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.rs
index ae74dc0d453..2b9f2fe40ef 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -2031,6 +2031,11 @@ pub(super) fn run_formatting_context(
false,
);
}
+ let key = fc_run_cache::FcRunCacheKey {
+ fc_type,
+ input,
+ root_cells,
+ };
let attempt = fc_run_cache::FcRunCacheAttempt::probe(
box_,
subgrid_parent.is_some(),
@@ -2038,18 +2043,16 @@ pub(super) fn run_formatting_context(
should_collect_devtools_layout_data,
false,
&callbacks,
- &fc_run_cache::FcRunCacheProbe::new(fc_type, &input, root_cells),
+ &key,
);
run_formatting_context_after_probe(
parent_collects_fragments,
- root_cells,
box_,
root_containing_block,
subgrid_parent,
- fc_type,
should_collect_devtools_layout_data,
callbacks,
- input,
+ &key,
table_inline_layout,
attempt,
)
@@ -2058,19 +2061,21 @@ pub(super) fn run_formatting_context(
#[allow(clippy::too_many_arguments)]
fn run_formatting_context_after_probe(
parent_collects_fragments: bool,
- root_cells: used_values::RootInputCells,
box_: Node,
root_containing_block: Node,
subgrid_parent: Option<&grid_formatting_context::SubgridParent>,
- fc_type: FormattingContextType,
should_collect_devtools_layout_data: bool,
callbacks: LayoutPass<'_>,
- input: LayoutInput,
+ key: &fc_run_cache::FcRunCacheKey,
table_inline_layout: Option<table_formatting_context::TableInlineLayout>,
attempt: Result<fc_run_cache::FcRunCacheAttempt, fc_run_cache::FcRunCacheHit>,
) -> ChildLayout {
- let builds_fragments = run_builds_fragments(&input, parent_collects_fragments);
- let cache_probe = fc_run_cache::FcRunCacheProbe::new(fc_type, &input, root_cells);
+ let fc_run_cache::FcRunCacheKey {
+ fc_type,
+ ref input,
+ root_cells,
+ } = *key;
+ let builds_fragments = run_builds_fragments(input, parent_collects_fragments);
let cache_attempt = match attempt {
Ok(attempt) => attempt,
Err(hit) => {
@@ -2087,7 +2092,7 @@ fn run_formatting_context_after_probe(
&callbacks,
parent_collects_fragments,
box_,
- &input,
+ input,
root_cells,
RunOutputsHandle::Stored(hit.entry),
true,
@@ -2108,7 +2113,7 @@ fn run_formatting_context_after_probe(
fc_type,
should_collect_devtools_layout_data,
callbacks,
- &input,
+ input,
None,
table_inline_layout.clone(),
None,
@@ -2123,7 +2128,7 @@ fn run_formatting_context_after_probe(
fc_type,
should_collect_devtools_layout_data,
callbacks,
- &input,
+ input,
previous_line_data,
table_inline_layout,
None,
@@ -2136,7 +2141,7 @@ fn run_formatting_context_after_probe(
&callbacks,
box_,
root_cells,
- &input,
+ input,
&outputs,
|callbacks, other_root_cells, other_input| {
execute_formatting_context_run(
@@ -2156,12 +2161,12 @@ fn run_formatting_context_after_probe(
},
);
}
- let outputs = cache_attempt.conclude(&callbacks, box_, &cache_probe, outputs);
+ let outputs = cache_attempt.conclude(&callbacks, box_, key, outputs);
child_layout_from_outputs(
&callbacks,
parent_collects_fragments,
box_,
- &input,
+ input,
root_cells,
outputs,
false,
@@ -3126,10 +3131,8 @@ fn is_childless_box_sized_in_parent_run(facts: NodeFacts<'_>, created_fc_type: O
pub(crate) struct ChildRunJob {
child: Node,
- fc_type: FormattingContextType,
+ key: fc_run_cache::FcRunCacheKey,
root_containing_block: Node,
- input: LayoutInput,
- root_cells: used_values::RootInputCells,
parent_collects_fragments: bool,
should_collect_devtools_layout_data: bool,
attempt: Result<fc_run_cache::FcRunCacheAttempt, fc_run_cache::FcRunCacheHit>,
@@ -3185,21 +3188,24 @@ 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 attempt = fc_run_cache::FcRunCacheAttempt::probe(
child,
false,
- run_builds_fragments(&input, parent_collects_fragments),
+ run_builds_fragments(&key.input, parent_collects_fragments),
run.should_collect_devtools_layout_data,
false,
&run.callbacks,
- &fc_run_cache::FcRunCacheProbe::new(fc_type, &input, child_input_cells),
+ &key,
);
PlannedChildRun::Job(ChildRunJob {
child,
- fc_type,
+ key,
root_containing_block,
- input,
- root_cells: child_input_cells,
parent_collects_fragments,
should_collect_devtools_layout_data: run.should_collect_devtools_layout_data,
attempt,
@@ -3290,14 +3296,12 @@ impl ChildRunsLaidOutAhead {
pub(crate) fn lay_out_child_run_job(callbacks: LayoutPass<'_>, job: ChildRunJob) -> ChildLayout {
run_formatting_context_after_probe(
job.parent_collects_fragments,
- job.root_cells,
job.child,
job.root_containing_block,
None,
- job.fc_type,
job.should_collect_devtools_layout_data,
callbacks,
- job.input,
+ &job.key,
None,
job.attempt,
)
@@ -3306,11 +3310,11 @@ pub(crate) fn lay_out_child_run_job(callbacks: LayoutPass<'_>, job: ChildRunJob)
pub(crate) fn shape_would_reuse_stored_run(callbacks: &LayoutPass<'_>, shape: &ChildRunShape) -> bool {
fc_run_cache::FcRunCacheAttempt::would_reuse_stored_run(
shape.node,
- run_builds_fragments(&shape.input, false),
+ run_builds_fragments(&shape.key.input, false),
false,
true,
callbacks,
- &fc_run_cache::FcRunCacheProbe::new(shape.fc_type, &shape.input, shape.root_cells),
+ &shape.key,
)
}
@@ -3354,9 +3358,11 @@ pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding(
);
ChildRunShape {
node: cell,
- fc_type: plan.fc_type,
- input: plan.input,
- root_cells: cell_input_cells,
+ key: fc_run_cache::FcRunCacheKey {
+ fc_type: plan.fc_type,
+ input: plan.input,
+ root_cells: cell_input_cells,
+ },
root_containing_block: plan.root_containing_block,
}
}
@@ -3364,15 +3370,14 @@ pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding(
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct ChildRunShape {
pub(crate) node: Node,
- pub(crate) fc_type: FormattingContextType,
- pub(crate) input: LayoutInput,
- pub(crate) root_cells: used_values::RootInputCells,
+ pub(crate) key: fc_run_cache::FcRunCacheKey,
pub(crate) root_containing_block: Node,
}
impl ChildRunShape {
pub(crate) fn lays_out_at(&self, inline_size: CssPixels, constraints: ContainingBlockConstraints) -> bool {
- self.root_cells.content_inline_size == inline_size && self.input.containing_block_constraints == constraints
+ self.key.root_cells.content_inline_size == inline_size
+ && self.key.input.containing_block_constraints == constraints
}
}
@@ -3411,10 +3416,12 @@ impl ChildRunShape {
debug_assert_eq!(input.participation, ParticipationInParentFormattingContext::Root);
Self {
node,
- fc_type: independent_formatting_context_type(node, callbacks),
root_containing_block: callbacks.containing_block_for_child_run(node, &input.participation),
- input,
- root_cells,
+ key: fc_run_cache::FcRunCacheKey {
+ fc_type: independent_formatting_context_type(node, callbacks),
+ input,
+ root_cells,
+ },
}
}
}
@@ -3477,12 +3484,15 @@ pub(crate) fn lay_out_measurement_root_for_its_result(
pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: ChildRunShape) -> ChildLayoutResult {
let ChildRunShape {
node,
- fc_type,
- input,
- root_cells,
+ key,
root_containing_block,
} = shape;
- let builds_fragments = run_builds_fragments(&input, false);
+ let fc_run_cache::FcRunCacheKey {
+ fc_type,
+ ref input,
+ root_cells,
+ } = key;
+ let builds_fragments = run_builds_fragments(input, false);
let lay_out = |callbacks: LayoutPass<'_>, root_cells, input: &LayoutInput, previous_line_data| {
execute_formatting_context_run(
builds_fragments,
@@ -3507,31 +3517,23 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
result
};
if callbacks.reads_no_memoized_layout() {
- return result_with_host_findings(RunOutputsHandle::Owned(lay_out(callbacks, root_cells, &input, None)));
+ return result_with_host_findings(RunOutputsHandle::Owned(lay_out(callbacks, root_cells, input, None)));
}
// NB: The only shapes of table cells are those laid out ahead of the intrinsic block padding their table hands them.
let runs_ahead_of_intrinsic_block_padding = builds_fragments && NodeFacts::new(&callbacks, node).is_table_cell();
- let cache_probe = fc_run_cache::FcRunCacheProbe::new(fc_type, &input, root_cells);
- let cache_attempt = match fc_run_cache::FcRunCacheAttempt::probe(
- node,
- false,
- builds_fragments,
- false,
- true,
- &callbacks,
- &cache_probe,
- ) {
- Ok(attempt) => attempt,
- Err(hit) => {
- let action = if runs_ahead_of_intrinsic_block_padding {
- "READ RESULT AHEAD OF INTRINSIC BLOCK PADDING"
- } else {
- "READ RESULT"
- };
- let _trace = callbacks.layout_trace().run(node, fc_type, || action);
- return result_with_host_findings(RunOutputsHandle::Stored(hit.entry));
- }
- };
+ let cache_attempt =
+ match fc_run_cache::FcRunCacheAttempt::probe(node, false, builds_fragments, false, true, &callbacks, &key) {
+ Ok(attempt) => attempt,
+ Err(hit) => {
+ let action = if runs_ahead_of_intrinsic_block_padding {
+ "READ RESULT AHEAD OF INTRINSIC BLOCK PADDING"
+ } else {
+ "READ RESULT"
+ };
+ let _trace = callbacks.layout_trace().run(node, fc_type, || action);
+ return result_with_host_findings(RunOutputsHandle::Stored(hit.entry));
+ }
+ };
let action = if runs_ahead_of_intrinsic_block_padding {
"RUN AHEAD OF INTRINSIC BLOCK PADDING"
} else {
@@ -3540,8 +3542,8 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
let _trace = callbacks.layout_trace().run(node, fc_type, || action);
let previous_line_data = cache_attempt.previous_line_data();
let discarded_outputs =
- run_repeatability::lay_out_discarded_run(&callbacks, |callbacks| lay_out(callbacks, root_cells, &input, None));
- let outputs = lay_out(callbacks, root_cells, &input, previous_line_data);
+ run_repeatability::lay_out_discarded_run(&callbacks, |callbacks| lay_out(callbacks, root_cells, input, None));
+ let outputs = lay_out(callbacks, root_cells, input, previous_line_data);
if let Some(discarded_outputs) = &discarded_outputs {
run_repeatability::verify_repeated_run(node, discarded_outputs, &outputs);
}
@@ -3550,12 +3552,12 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
&callbacks,
node,
root_cells,
- &input,
+ input,
&outputs,
|callbacks, other_root_cells, other_input| lay_out(callbacks, other_root_cells, &other_input, None),
);
}
- let outputs = cache_attempt.conclude(&callbacks, node, &cache_probe, outputs);
+ let outputs = cache_attempt.conclude(&callbacks, node, &key, outputs);
result_with_host_findings(outputs)
}
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index 3134348c192..1deff2b0a89 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -4906,9 +4906,11 @@ impl<'pass> GridFormattingContext<'pass> {
);
formatting_context::ChildRunShape {
node: item.box_,
- fc_type: plan.fc_type,
- input: plan.input,
- root_cells: cells,
+ key: fc_run_cache::FcRunCacheKey {
+ fc_type: plan.fc_type,
+ input: plan.input,
+ root_cells: cells,
+ },
root_containing_block: plan.root_containing_block,
}
}