Truly independent web browser
LibWeb: Hand a table box its inline layout as a run input
Aliaksandr Kalenik909fc930f5f3
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rsindex f073df22eb3..f37d59cfb64 100644--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs@@ -2651,6 +2651,7 @@ impl<'pass> AbsposEngine<'pass> {ParticipationInParentFormattingContext::AbsolutelyPositioned(inputs.clone()),),cells,+ None,false,// https://drafts.csswg.org/css-sizing-3/#definite// "Additionally, the size of the containing block of an absolutely positioned element is always definitediff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex f3fd51a2784..657335af060 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -781,7 +781,7 @@ fn lay_out_in_flow_child_ahead(pass: LayoutPass<'_>, job: InFlowChildJob) -> Opttreat_block_axis_percentage_insets_as_auto_beyond_root,None,);- let flow = BlockFormattingContext::new(&run, root_cells, None);+ let flow = BlockFormattingContext::new(&run, root_cells, None, None);flow.block_offset_of_current_block_container.set(Some(CssPixels::default()));let containing_block_position_in_root = FfiCssPixelPoint {@@ -1037,7 +1037,7 @@ pub(crate) struct BlockFormattingContext<'pass> {table_box_in_wrapper_border_box_block_size: Cell<Option<CssPixels>>,/// The inline layout of the table box inside a table wrapper child, as sizing the wrapper last found it, which the/// child's run can reuse.- table_inline_layout_of_child: Cell<Option<(Node, table_formatting_context::TableInlineLayout)>>,+ table_inline_layout_of_child: Cell<Option<(Node, std::sync::Arc<table_formatting_context::TableInlineLayout>)>>,is_line_clamp_container: bool,clamped_content_is_scrollable_overflow: bool,max_lines: Cell<Option<usize>>,@@ -1225,6 +1225,7 @@ impl<'pass> BlockFormattingContext<'pass> {run: &FormattingContextRun<'pass>,root_cells: used_values::RootInputCells,previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,+ inline_layout_of_child_table_box: Option<std::sync::Arc<table_formatting_context::TableInlineLayout>>,) -> Self {let style = StyleValues::for_node(&run.pass, run.box_);let computed_continue = style.continue_();@@ -1253,7 +1254,10 @@ impl<'pass> BlockFormattingContext<'pass> {trailing_collapsed_margin: Cell::new(None),table_box_in_wrapper_border_box_inline_size: Cell::new(None),table_box_in_wrapper_border_box_block_size: Cell::new(None),- table_inline_layout_of_child: Cell::new(None),+ // NB: A table wrapper's run hands the inline layout of its table box on to the run of that box.+ table_inline_layout_of_child: Cell::new(+ inline_layout_of_child_table_box.map(|layout| (layout.table_box(), layout)),+ ),is_line_clamp_container,clamped_content_is_scrollable_overflow,// NB: Measurements at a definite inline size need the clamped block size, just like committed layout.@@ -1355,15 +1359,16 @@ impl<'pass> BlockFormattingContext<'pass> {}/// Keeps `layout`, the inline layout of the table box inside `child`, for the run of `child`.- pub(crate) fn keep_table_inline_layout_of(&self, child: Node, layout: table_formatting_context::TableInlineLayout) {- self.table_inline_layout_of_child.set(Some((child, layout)));+ fn keep_table_inline_layout_of(&self, child: Node, layout: table_formatting_context::TableInlineLayout) {+ self.table_inline_layout_of_child+ .set(Some((child, std::sync::Arc::new(layout))));}/// The inline layout of the table box inside `child` this formatting context keeps for the run of `child`, if any.pub(crate) fn take_table_inline_layout_of(&self,child: Node,- ) -> Option<table_formatting_context::TableInlineLayout> {+ ) -> Option<std::sync::Arc<table_formatting_context::TableInlineLayout>> {take_table_inline_layout_kept_for(&self.table_inline_layout_of_child, child)}@@ -3058,6 +3063,7 @@ impl<'pass> BlockFormattingContext<'pass> {participation: ParticipationInParentFormattingContext::Item,},marker_cells,+ None,true,list_item.percentage_block_insets_have_definite_basis,);@@ -3158,6 +3164,7 @@ impl<'pass> BlockFormattingContext<'pass> {sized_child.node,input,self.metrics_of(sized_child),+ self.take_table_inline_layout_of(sized_child.node),force_independent_context_run,block_container.percentage_block_insets_have_definite_basis,);@@ -7553,9 +7560,9 @@ pub(crate) fn floor_list_item_automatic_block_size_by_marker_line_height(/// The inline layout of the table box inside `child` that `kept` holds for the run of `child`, which stays kept for/// another child.pub(crate) fn take_table_inline_layout_kept_for(- kept: &Cell<Option<(Node, table_formatting_context::TableInlineLayout)>>,+ kept: &Cell<Option<(Node, std::sync::Arc<table_formatting_context::TableInlineLayout>)>>,child: Node,-) -> Option<table_formatting_context::TableInlineLayout> {+) -> Option<std::sync::Arc<table_formatting_context::TableInlineLayout>> {let (kept_for, layout) = kept.take()?;if kept_for != child {kept.set(Some((kept_for, layout)));diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rsindex 5491d423b2e..d01e7b7a6ae 100644--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs@@ -4285,6 +4285,7 @@ impl<'pass> FlexFormattingContext<'pass> {node,input,cells,+ None,false,percentage_block_insets_have_definite_basis,)diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex e258339bbf4..932150dde82 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -1660,20 +1660,15 @@ impl<'pass> FormattingContextAlgorithms<'pass> {subgrid_parent: Option<&grid_formatting_context::SubgridParent<'pass>>,fc_type: FormattingContextType,previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,- inline_layout_of_child_table_box: Option<table_formatting_context::TableInlineLayout>,+ inline_layout_of_child_table_box: Option<std::sync::Arc<table_formatting_context::TableInlineLayout>>,) -> &mut dyn FormattingContextAlgorithm<'pass> {match fc_type {- FormattingContextType::Block => {- let context = self.block.insert(block_formatting_context::BlockFormattingContext::new(- run,- root_cells_in_own_frame,- previous_line_data,- ));- if let Some(layout) = inline_layout_of_child_table_box {- context.keep_table_inline_layout_of(layout.table_box(), layout);- }- context- }+ FormattingContextType::Block => self.block.insert(block_formatting_context::BlockFormattingContext::new(+ run,+ root_cells_in_own_frame,+ previous_line_data,+ inline_layout_of_child_table_box,+ )),FormattingContextType::Flex => self.flex.insert(flex_formatting_context::FlexFormattingContext::new(run,root_cells_in_own_frame,@@ -2201,7 +2196,8 @@ impl RunCaller {#[derive(Clone, Default)]pub(crate) struct RunSideInputs<'a> {pub(crate) subgrid_parent: Option<&'a grid_formatting_context::SubgridParent<'a>>,- pub(crate) table_inline_layout: Option<table_formatting_context::TableInlineLayout>,+ /// For a table wrapper or its table box, the inline layout of the table box its parent found while sizing it.+ pub(crate) table_inline_layout: Option<std::sync::Arc<table_formatting_context::TableInlineLayout>>,pub(crate) fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,}@@ -2609,7 +2605,7 @@ fn lay_out_run_root_and_contents<'pass>(root_input: input,root_cells: own_root.get(),flex_self_block_size_resolution_space,- table_inline_layout: inline_layout_of_root_table_box,+ table_inline_layout: inline_layout_of_root_table_box.map(std::sync::Arc::unwrap_or_clone),},)};@@ -3150,8 +3146,9 @@ impl ChildLayout {}}-/// Lays out `child` with the input cells its parent sized it to: hands them to the child's run, or sizes the child in-/// them here where it needs no run of its own.+/// Lays out `child` with the input cells its parent sized it to: hands them to the child's run, with the inline layout+/// `table_inline_layout` the parent found for a table wrapper or table box, or sizes the child in them here where it+/// needs no run of its own.#[allow(clippy::too_many_arguments)]pub(crate) fn layout_inside_child_with_input_cells(run: &FormattingContextRun,@@ -3160,6 +3157,7 @@ pub(crate) fn layout_inside_child_with_input_cells(child: Node,input: LayoutInput,child_input_cells: used_values::RootInputCells,+ table_inline_layout: Option<std::sync::Arc<table_formatting_context::TableInlineLayout>>,force_independent_context_run: bool,percentage_block_insets_of_containing_block_have_definite_basis: bool,) -> ChildLayout {@@ -3212,9 +3210,7 @@ pub(crate) fn layout_inside_child_with_input_cells(.and_then(|grid| grid.subgrid_parent_of(child));let side = RunSideInputs {subgrid_parent: subgrid_parent.as_ref(),- table_inline_layout: parent_block- .and_then(|block| block.take_table_inline_layout_of(child))- .or_else(|| parent_grid.and_then(|grid| grid.take_table_inline_layout_of(child))),+ table_inline_layout,fragmentainer: None,};run_formatting_context(diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rsindex bfd7d3e3c7a..23610286805 100644--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs@@ -1120,7 +1120,7 @@ pub(crate) struct GridFormattingContext<'pass> {>,/// The inline layout of the table box inside a table wrapper item, as resolving the wrapper's inline size last/// found it, which the item's run can reuse.- table_inline_layout_of_item: Cell<Option<(Node, table_formatting_context::TableInlineLayout)>>,+ table_inline_layout_of_item: Cell<Option<(Node, std::sync::Arc<table_formatting_context::TableInlineLayout>)>>,derived_baselines_of_root_box: DerivedBaselines,container_style: StyleValues<'pass>,parent_grid: Option<ParentGridData<'pass>>,@@ -3995,10 +3995,10 @@ impl<'pass> GridFormattingContext<'pass> {}/// The inline layout of the table box inside `item` this grid keeps for the run of `item`, if any.- pub(crate) fn take_table_inline_layout_of(+ fn take_table_inline_layout_of(&self,item: Node,- ) -> Option<table_formatting_context::TableInlineLayout> {+ ) -> Option<std::sync::Arc<table_formatting_context::TableInlineLayout>> {block_formatting_context::take_table_inline_layout_kept_for(&self.table_inline_layout_of_item, item)}@@ -4019,7 +4019,7 @@ impl<'pass> GridFormattingContext<'pass> {formatting_context::TableWrapperInlineSizeMode::UseTableUsedInlineSizeIfNotAuto,);self.table_inline_layout_of_item- .set(Some((item.box_, table_inline_layout)));+ .set(Some((item.box_, std::sync::Arc::new(table_inline_layout))));let wrapper_style = self.item_style(item);let table_box = self.sizing().table_box_inside_wrapper(item.box_);let table_style = self.style(table_box);@@ -4905,6 +4905,7 @@ impl<'pass> GridFormattingContext<'pass> {item.box_,input,cells,+ self.take_table_inline_layout_of(item.box_),false,percentage_block_insets_have_definite_basis,)diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rsindex f3089da2100..4a5d23417f0 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs@@ -1478,6 +1478,7 @@ impl<'context> InlineFormattingContext<'context> {node,input,cells,+ self.parent.take_table_inline_layout_of(node),false,self.block_container.percentage_block_insets_have_definite_basis,);diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rsindex 8d9fb2e4602..2ffd87ba2c6 100644--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs@@ -121,7 +121,7 @@ pub(super) fn content_sizes_of_inline_content(child_constraints,ParticipationInParentFormattingContext::BlockLevel,);- let parent = block_formatting_context::BlockFormattingContext::new(run, scope.root_cells(), None);+ let parent = block_formatting_context::BlockFormattingContext::new(run, scope.root_cells(), None, None);let mut context = inline_formatting_context::InlineFormattingContext::new_with_rust_parent(run,block_formatting_context::BlockContainer::root_of(run, scope.root_cells()),diff --git a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rsindex 35805dc4e46..b90cc344cf2 100644--- a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs@@ -2210,6 +2210,7 @@ impl<'pass> MathFormattingContext<'pass> {child,input,child_cells,+ None,true,run.percentage_block_insets_of_root_children_have_definite_basis(&self.root_cells),);diff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rsindex e9087c987e1..7cb0fcb21f9 100644--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs@@ -2120,6 +2120,7 @@ impl<'pass> SvgFormattingContext<'pass> {child,child_input,child_cells,+ None,true,self.percentage_block_insets_of_run_root_children_have_definite_basis,);diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rsindex c2695bde565..6207d08265b 100644--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs@@ -2937,6 +2937,7 @@ impl<'pass> TableFormattingContext<'pass> {cell.box_,layout_input,self.cell_box_cells[cell_index],+ None,false,// NB: A table cell is a containing block of its own to the percentage block insets of its descendants.run.percentage_block_insets_of_root_children_have_definite_basis(&self.table_box_cells),