Truly independent web browser
LibWeb: Hand a table cell its intrinsic padding in its input cells
Aliaksandr Kalenikcdd5dd2e2db9
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex 75ad2c1c504..69d1fe1b5f6 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -135,14 +135,11 @@ impl FcRunCacheKey {}}- /// The key with the intrinsic block padding a table hands its cell taken out of the root's block paddings.- fn without_table_cell_intrinsic_block_padding(&self) -> Self {+ /// The key with the root's block paddings left out.+ fn without_root_block_paddings(&self) -> Self {let mut key = self.clone();- if let Some((padding_top, padding_bottom)) = key.input.sizing.table_cell_intrinsic_block_padding {- key.root_cells.padding_top -= padding_top;- key.root_cells.padding_bottom -= padding_bottom;- key.input.sizing.table_cell_intrinsic_block_padding = Some((CssPixels::default(), CssPixels::default()));- }+ key.root_cells.padding_top = CssPixels::default();+ key.root_cells.padding_bottom = CssPixels::default();key}@@ -293,7 +290,6 @@ fn sizing_directives_match_ignoring_unobserved(forced_content_block_size,forced_min_border_box_block_size,block_parent_resolved_content_inline_size,- table_cell_intrinsic_block_padding,table_box_content_block_offset_in_wrapper,content_block_size_after_run,outer_float_intrusion_before_list_item_children,@@ -304,7 +300,6 @@ fn sizing_directives_match_ignoring_unobserved(forced_content_block_size == b.forced_content_block_size&& forced_min_border_box_block_size == b.forced_min_border_box_block_size&& block_parent_resolved_content_inline_size == b.block_parent_resolved_content_inline_size- && table_cell_intrinsic_block_padding == b.table_cell_intrinsic_block_padding&& table_box_content_block_offset_in_wrapper == b.table_box_content_block_offset_in_wrapper&& (content_block_size_after_run == b.content_block_size_after_run|| content_block_size_adopted_after_run_unobserved)@@ -331,9 +326,10 @@ pub(super) struct FcRunCacheEntry {key: FcRunCacheKey,validity: FcRunCacheValidity,pub(super) outputs: formatting_context::RunOutputs,- /// Whether the run is a table cell's that did not observe the intrinsic block padding its table hands it (see- /// run_observes_root_block_padding), so that it stands for runs with any such padding.- table_cell_intrinsic_block_padding_unobserved: bool,+ /// 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.+ table_cell_block_paddings_unobserved: bool,last_used_at_layout_commit: std::sync::atomic::AtomicU64,structural_epoch_bumps_when_stored: u32,}@@ -419,10 +415,10 @@ impl FcRunCacheEntry {fn answers_probe_for(&self, probe: &FcRunCacheProbe<'_>) -> bool {let unobserved = self.outputs.inputs_never_observed;self.key.matches_probe(probe, unobserved)- || (self.table_cell_intrinsic_block_padding_unobserved && {- let probe_key = probe.key().without_table_cell_intrinsic_block_padding();+ || (self.table_cell_block_paddings_unobserved && {+ let probe_key = probe.key().without_root_block_paddings();self.key- .without_table_cell_intrinsic_block_padding()+ .without_root_block_paddings().matches_probe(&probe_key.as_probe(), unobserved)})}@@ -912,7 +908,7 @@ impl FcRunCacheAttempt {key: probe.key(),validity,outputs,- table_cell_intrinsic_block_padding_unobserved: false,+ table_cell_block_paddings_unobserved: false,last_used_at_layout_commit: std::sync::atomic::AtomicU64::new(callbacks.arena().layout_commit_count(),),@@ -931,15 +927,14 @@ impl FcRunCacheAttempt {if outputs.root.is_none() {return formatting_context::RunOutputsHandle::Owned(outputs);}- let table_cell_intrinsic_block_padding_unobserved =- probe.input.sizing.table_cell_intrinsic_block_padding.is_some()- && outputs.root_outcome.parent_owns_root_input_cells()- && !run_observes_root_block_padding(callbacks, box_, &outputs);+ let table_cell_block_paddings_unobserved = NodeFacts::new(callbacks, box_).is_table_cell()+ && outputs.root_outcome.parent_owns_root_input_cells()+ && !run_observes_root_block_padding(callbacks, box_, &outputs);let entry = FcRunCacheEntry {key: probe.key(),validity,outputs,- table_cell_intrinsic_block_padding_unobserved,+ table_cell_block_paddings_unobserved,last_used_at_layout_commit: std::sync::atomic::AtomicU64::new(callbacks.arena().layout_commit_count()),structural_epoch_bumps_when_stored: 0,};@@ -1082,7 +1077,7 @@ mod tests {host_findings: None,laid_out_abspos_contained_by_root: false,},- table_cell_intrinsic_block_padding_unobserved: false,+ table_cell_block_paddings_unobserved: false,last_used_at_layout_commit: std::sync::atomic::AtomicU64::new(layout_commit_count),structural_epoch_bumps_when_stored: 0,}diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex a6a207431f5..38cea889fdc 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -2999,22 +2999,13 @@ pub(crate) fn layout_inside_child_with_input_cells(parent_grid: Option<&grid_formatting_context::GridFormattingContext>,child: Node,input: LayoutInput,- mut child_input_cells: used_values::RootInputCells,+ child_input_cells: used_values::RootInputCells,force_independent_context_run: bool,percentage_block_insets_of_containing_block_have_definite_basis: bool,) -> ChildLayout {let facts = NodeFacts::new(&run.callbacks, child);let created_fc_type = formatting_context_type_created_by_box(facts);let child_run_builds_fragments = run_builds_fragments(&input, run.fragments.is_some());- if let Some((padding_top, padding_bottom)) = input.sizing.table_cell_intrinsic_block_padding {- debug_assert!(facts.is_table_cell());- debug_assert!(matches!(- input.participation,- ParticipationInParentFormattingContext::Item- ));- child_input_cells.padding_top += padding_top;- child_input_cells.padding_bottom += padding_bottom;- }let skipped = |out_of_flow_root_used_insets| ChildLayoutOutcome::Skipped {depends_on_percentage_block_size: run.sizing().skipped_child_depends_on_percentage_block_size(child),out_of_flow_root_used_insets,@@ -3107,13 +3098,12 @@ pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding(table_box: &impl BoxMetricCells,cell: Node,cell_input_cells: used_values::RootInputCells,- mut input: LayoutInput,+ input: LayoutInput,) -> ChildRunShape {debug_assert!(matches!(input.participation,ParticipationInParentFormattingContext::Item));- input.sizing.table_cell_intrinsic_block_padding = Some((CssPixels::default(), CssPixels::default()));// NB: A table cell is a containing block of its own to the percentage block insets of its descendants.let plan = child_run_plan(run,@@ -3280,8 +3270,8 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chiif callbacks.reads_no_memoized_layout() {return result_with_host_findings(RunOutputsHandle::Owned(lay_out(callbacks, root_cells, &input, None)));}- let runs_ahead_of_intrinsic_block_padding =- builds_fragments && input.sizing.table_cell_intrinsic_block_padding.is_some();+ // 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,diff --git a/Libraries/LibWeb/Rust/src/layout/geometry.rs b/Libraries/LibWeb/Rust/src/layout/geometry.rsindex 8ca7c9906c5..c144e35ba19 100644--- a/Libraries/LibWeb/Rust/src/layout/geometry.rs+++ b/Libraries/LibWeb/Rust/src/layout/geometry.rs@@ -360,9 +360,6 @@ pub(crate) struct RootSizingDirectives {// Input-only: the parent block formatting context supplies the inline size it resolved while// positioning an independent child, so the child's run prelude can commit it without resolving it again.pub(crate) block_parent_resolved_content_inline_size: PackedOptionalCssPixels,- // Input-only: the table formatting context supplies the cell's intrinsic block padding- // (the vertical-alignment stretch) before laying out the cell's contents.- pub(crate) table_cell_intrinsic_block_padding: Option<(CssPixels, CssPixels)>,// Input-only: the wrapper's BFC tells the table formatting context where the table box's// content box sits in the wrapper, so rows and row groups (whose containing block is the// wrapper) can be placed in wrapper coordinates.diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rsindex 9aa15c4fba0..2620bd7348b 100644--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs@@ -2822,7 +2822,6 @@ impl<'pass> TableFormattingContext<'pass> {cell_index: usize,input: AvailableSpace,adopt_automatic_content_block_size: bool,- intrinsic_block_padding: Option<(CssPixels, CssPixels)>,) -> (DerivedBaselines, Option<fragment_tree::RunRootFragment>) {let layout_input = LayoutInput {available_space: input,@@ -2833,7 +2832,6 @@ impl<'pass> TableFormattingContext<'pass> {} else {geometry::ContentBlockSizeAfterRun::HandedOver},- table_cell_intrinsic_block_padding: intrinsic_block_padding,..RootSizingDirectives::default()},participation: ParticipationInParentFormattingContext::Item,@@ -3058,7 +3056,7 @@ impl<'pass> TableFormattingContext<'pass> {content_baselines = Some(measured.baselines);}} else {- let (baselines, fragment_arrival) = self.layout_inside_cell(run, cell_index, inner, true, None);+ let (baselines, fragment_arrival) = self.layout_inside_cell(run, cell_index, inner, true);self.keep_fragment_arrival_of_cell(cell_index, fragment_arrival);content_baselines = Some(baselines);}@@ -3454,15 +3452,13 @@ impl<'pass> TableFormattingContext<'pass> {// it; restore the pre-layout size so the cell's children resolve percentages against// the same basis the measurement saw.let pre_layout_content_block_size = self.cell_pre_layout_content_block_sizes[cell_index];- self.cell_box_cells[cell_index].set_content_block_size(pre_layout_content_block_size);+ let cell_box = &mut self.cell_box_cells[cell_index];+ cell_box.set_content_block_size(pre_layout_content_block_size);+ cell_box.padding_top += intrinsic_block_padding.0;+ cell_box.padding_bottom += intrinsic_block_padding.1;let inner = self.cell_inside_layout_inputs[cell_index];- let (_, fragment_arrival) = self.layout_inside_cell(- run,- cell_index,- inner,- adopt_automatic_content_block_size,- Some(intrinsic_block_padding),- );+ let (_, fragment_arrival) =+ self.layout_inside_cell(run, cell_index, inner, adopt_automatic_content_block_size);self.keep_fragment_arrival_of_cell(cell_index, fragment_arrival);if adopt_automatic_content_block_size {debug_assert_eq!(