Truly independent web browser
LibWeb: Remove the run cache rule for table cell block paddings
Aliaksandr Kalenik1f9badec59f8
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex b59b88068b8..6fd3624669a 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -36,10 +36,6 @@ pub(crate) struct RunInputsTheStoredRunNeverObserved {#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]pub(crate) struct RunObservations {pub(super) never_observed: RunInputsTheStoredRunNeverObserved,- /// Whether the run is a table cell's that did not observe its block paddings (see run_observes_root_block_padding),- /// so that it stands for runs at any of them, such as the intrinsic block padding its table hands it once its rows- /// are sized.- pub(super) table_cell_block_paddings_unobserved: bool,/// Whether the root's parent owns the root's input cells, which the run then leaves as they were handed to it but/// for the content block size the root adopts.pub(super) parent_owns_root_cells: bool,@@ -74,14 +70,13 @@ pub(crate) fn cells_at_probe(}/// What a run did besides its result that decides which of its inputs it observed.-pub(crate) struct RunObservationFacts<'a> {+pub(crate) struct RunObservationFacts {/// For an atomic inline root, the available inline sizes at or above which sizing the root repeats itself.pub(crate) definite_available_inline_sizes_at_or_above: Option<CssPixels>,/// Whether the run was handed a table inline layout, which its key does not hold.pub(crate) handed_table_inline_layout: bool,/// Whether the run laid out absolutely positioned boxes against the final sizes and box sides of its root.pub(crate) laid_out_abspos_contained_by_root: bool,- pub(crate) root: Option<&'a fragment_tree::RunRootFragment>,pub(crate) parent_owns_root_input_cells: bool,}@@ -90,7 +85,7 @@ pub(crate) fn observations_of(run: &formatting_context::FormattingContextRun,request: &formatting_context::RunRequest,result: &formatting_context::ChildLayoutResult,- facts: RunObservationFacts<'_>,+ facts: RunObservationFacts,) -> RunObservations {let fc_type = request.key.fc_type;let input = &request.key.input;@@ -123,14 +118,6 @@ pub(crate) fn observations_of(never_observed,parent_owns_root_cells: facts.parent_owns_root_input_cells,laid_out_abspos_contained_by_root: facts.laid_out_abspos_contained_by_root,- table_cell_block_paddings_unobserved: facts.parent_owns_root_input_cells- && NodeFacts::new(&run.pass, run.box_).is_table_cell()- && !run_observes_root_block_padding(- &run.pass,- run.box_,- facts.laid_out_abspos_contained_by_root,- facts.root,- ),}}@@ -336,14 +323,6 @@ impl LayoutRequest {}}- /// The key with the root's block paddings left out.- fn without_root_block_paddings(&self) -> Self {- let mut key = self.clone();- key.root_cells.padding_top = CssPixels::default();- key.root_cells.padding_bottom = CssPixels::default();- key- }-fn matches(&self, probe: &Self, unobserved: RunInputsTheStoredRunNeverObserved) -> bool {if self.fc_type != probe.fc_type || self.parent_frame != probe.parent_frame {return false;@@ -542,12 +521,7 @@ impl FcRunCacheEntry {fn answers_probe_for(&self, probe: &LayoutRequest) -> bool {let unobserved = self.result.observed.never_observed;- (self.key.matches(probe, unobserved)- || (self.result.observed.table_cell_block_paddings_unobserved- && self- .key- .without_root_block_paddings()- .matches(&probe.without_root_block_paddings(), unobserved)))+ self.key.matches(probe, unobserved)&& self.probe_leaves_root_with_block_size_its_abspos_were_laid_out_against(probe)}}@@ -1170,26 +1144,6 @@ pub(super) fn can_describe_run(!node_facts::has_flag(NodeFacts::new(pass, box_).data(), NodeFlag::InsetsUseAnchorFunctions)}-/// Whether a run's outputs may depend on its root's block paddings. They hold the content in content box coordinates,-/// so they stand for the same run at other block paddings unless the root is a scroll container, whose scrollable-/// overflow area is bounded by its padding box, places a rendered legend on its border box, lays out absolutely-/// positioned boxes against its padding box, or passes payloads on to its ancestors (out-of-flow descendants, their-/// containing block rects, anchors), which are placed against its padding box. Outputs without a root fragment cannot-/// show those payloads.-fn run_observes_root_block_padding(- pass: &LayoutPass<'_>,- box_: Node,- laid_out_abspos_contained_by_root: bool,- root: Option<&fragment_tree::RunRootFragment>,-) -> bool {- let facts = NodeFacts::new(pass, box_);- let places_rendered_legend_on_its_border_box = facts.is_fieldset_box() && !facts.rendered_legend().is_invalid();- facts.is_scroll_container()- || places_rendered_legend_on_its_border_box- || laid_out_abspos_contained_by_root- || root.is_none_or(|root| root.payloads_past_run.is_some())-}-#[cfg(test)]mod tests {use super::*;@@ -1259,7 +1213,6 @@ mod tests {percentage_block_basis_and_block_size_definiteness: true,..RunInputsTheStoredRunNeverObserved::default()},- table_cell_block_paddings_unobserved: false,parent_owns_root_cells: false,laid_out_abspos_contained_by_root: false,},diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 54ce0d0ad61..15f344b0010 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -2232,20 +2232,8 @@ impl RunRequest {)}- /// Whether the run is laid out for its result ahead of the intrinsic block padding its table hands its root, a- /// table cell.- fn runs_ahead_of_intrinsic_block_padding(&self, pass: &LayoutPass<'_>) -> bool {- // NB: The only shapes of table cells are those laid out ahead of the intrinsic block padding their table hands- // them.- self.caller == RunCaller::ResultQuery- && self.mode.builds_fragments()- && NodeFacts::new(pass, self.node).is_table_cell()- }-fn trace_action_of_reuse(&self, pass: &LayoutPass<'_>, entry: &fc_run_cache::FcRunCacheEntry) -> &'static str {- if self.runs_ahead_of_intrinsic_block_padding(pass) {- "READ RESULT AHEAD OF INTRINSIC BLOCK PADDING"- } else if self.caller == RunCaller::ResultQuery || !self.mode.builds_fragments() {+ if self.caller == RunCaller::ResultQuery || !self.mode.builds_fragments() {"READ RESULT"} else if entry.holds_committed_fragments(pass.arena(), self.node) {"REUSE SUBTREE"@@ -2253,14 +2241,6 @@ impl RunRequest {"REPLAY FRAGMENTS"}}-- fn trace_action_of_run(&self, pass: &LayoutPass<'_>, attempt: &fc_run_cache::FcRunCacheAttempt) -> &'static str {- if self.runs_ahead_of_intrinsic_block_padding(pass) {- "RUN AHEAD OF INTRINSIC BLOCK PADDING"- } else {- attempt.trace_action()- }- }}/// Runs the formatting context of the root of `request` for the root's parent.@@ -2307,7 +2287,7 @@ fn layout_after_probe(};let _trace = pass.layout_trace()- .run(box_, key.fc_type, || request.trace_action_of_run(&pass, &cache_attempt));+ .run(box_, key.fc_type, || cache_attempt.trace_action());let previous_line_data = cache_attempt.previous_line_data();let subgrid_parent = side.subgrid_parent;let discarded_outputs = run_repeatability::lay_out_discarded_run(&pass, |pass| {@@ -2755,7 +2735,6 @@ fn lay_out_run_root_and_contents<'pass>(atomic_root_sizing_repeats_for_available_inline_sizes_at_or_above,handed_table_inline_layout: run_is_handed_table_inline_layout_outside_its_key,laid_out_abspos_contained_by_root,- root: root.as_ref(),parent_owns_root_input_cells,},);diff --git a/Tests/LibWeb/Text/expected/table-missing-cells-incremental-fixup.txt b/Tests/LibWeb/Text/expected/table-missing-cells-incremental-fixup.txtindex b4ddedd5ebb..4fa6aeae2bf 100644--- a/Tests/LibWeb/Text/expected/table-missing-cells-incremental-fixup.txt+++ b/Tests/LibWeb/Text/expected/table-missing-cells-incremental-fixup.txt@@ -1,4 +1,4 @@-Measured cells: none+Laid out cells: noneControl position: 0,40Unchanged grid: trueGrow grid: truediff --git a/Tests/LibWeb/Text/input/layout-test-harness.html b/Tests/LibWeb/Text/input/layout-test-harness.htmlindex 67cc8c9775c..a1698a9512f 100644--- a/Tests/LibWeb/Text/input/layout-test-harness.html+++ b/Tests/LibWeb/Text/input/layout-test-harness.html@@ -73,8 +73,8 @@ test(() => {" Box<DIV>#item MEASURE max-content block (cache=miss)"," Box<DIV>#item/flex RUN (cache=bypass)"," Box<TABLE>#table/table RUN (cache=bypass)",- " BlockContainer<TD>.cell/block RUN AHEAD OF INTRINSIC BLOCK PADDING",- " BlockContainer<TD>.cell/block READ RESULT AHEAD OF INTRINSIC BLOCK PADDING",+ " BlockContainer<TD>.cell/block RUN (cache=miss)",+ " BlockContainer<TD>.cell/block READ RESULT"," BlockContainer<DIV> REUSE IN-FLOW SUBTREE","layout PARTIAL Box<DIV>#flex"," Box<DIV>#flex/flex REPLAY FRAGMENTS",@@ -90,8 +90,8 @@ test(() => {{ depth: 3, event: "measure", box: "Box<DIV>#item", size: "max-content block", cache: "miss" },{ depth: 4, event: "run", box: "Box<DIV>#item", formattingContext: "flex", action: "RUN", cache: "bypass" },{ depth: 3, event: "run", box: "Box<TABLE>#table", formattingContext: "table", action: "RUN", cache: "bypass" },- { depth: 4, event: "run", box: "BlockContainer<TD>.cell", formattingContext: "block", action: "RUN AHEAD OF INTRINSIC BLOCK PADDING" },- { depth: 4, event: "run", box: "BlockContainer<TD>.cell", formattingContext: "block", action: "READ RESULT AHEAD OF INTRINSIC BLOCK PADDING" },+ { depth: 4, event: "run", box: "BlockContainer<TD>.cell", formattingContext: "block", action: "RUN", cache: "miss" },+ { depth: 4, event: "run", box: "BlockContainer<TD>.cell", formattingContext: "block", action: "READ RESULT" },{ depth: 4, event: "reuse in-flow subtree", box: "BlockContainer<DIV>" },{ depth: 0, event: "layout", partial: true, box: "Box<DIV>#flex" },{ depth: 1, event: "run", box: "Box<DIV>#flex", formattingContext: "flex", action: "REPLAY FRAGMENTS" },diff --git a/Tests/LibWeb/Text/input/table-missing-cells-incremental-fixup.html b/Tests/LibWeb/Text/input/table-missing-cells-incremental-fixup.htmlindex c433d589314..f3d2ebd55cd 100644--- a/Tests/LibWeb/Text/input/table-missing-cells-incremental-fixup.html+++ b/Tests/LibWeb/Text/input/table-missing-cells-incremental-fixup.html@@ -25,7 +25,7 @@document.body.offsetHeight;const work = layoutWork(() => rows.rows[2].cells[0].append(control));- results.push(`Measured cells: ${work.boxes({ event: "run", action: "RUN AHEAD OF INTRINSIC BLOCK PADDING" }).join(", ") || "none"}`);+ results.push(`Laid out cells: ${work.boxes(event => event.event === "run" && event.box.startsWith("BlockContainer<TD>")).join(", ") || "none"}`);results.push(`Control position: ${control.getBoundingClientRect().x},${control.getBoundingClientRect().y}`);function checkTree(label, mutate) {