Skip to content

Truly independent web browser

LibWeb: Pass the root to the check of its children's percentage insets

Aliaksandr Kalenikc2a5287137ea
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index 261d628ba45..86d210487aa 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -124,7 +124,7 @@ impl<'pass> BlockContainer<'pass> {
node: run.box_,
used: run.records.used_values(run.box_),
percentage_block_insets_have_definite_basis: run
- .percentage_block_insets_of_root_children_have_definite_basis(),
+ .percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
}
}
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index f890ca2d0ae..88e01f4730b 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -3155,7 +3155,9 @@ impl<'pass> FlexFormattingContext<'pass> {
node,
input,
false,
- self.run.percentage_block_insets_of_root_children_have_definite_basis(),
+ self.run.percentage_block_insets_of_root_children_have_definite_basis(
+ self.run.records.used_values(self.run.box_),
+ ),
);
debug_assert_eq!(plan.fc_type, formatting_context::FormattingContextType::Block);
Some(formatting_context::ChildRunShape {
@@ -3204,7 +3206,7 @@ impl<'pass> FlexFormattingContext<'pass> {
cells,
None,
false,
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
self.flex_items[index].cells = laid_out_box.cells;
self.flex_items[index].orthogonal_flow_baselines = laid_out_box.orthogonal_flow_baselines;
@@ -3221,7 +3223,7 @@ impl<'pass> FlexFormattingContext<'pass> {
inline_size: container_used.content_inline_size.get(),
block_size: container_used.content_block_size.get(),
},
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
(fragment_arrival, placed_item.with_in_flow_box_insets(insets))
}
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 924e5a9c1d4..f8d037f6d58 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -1344,13 +1344,16 @@ impl<'pass> FormattingContextRun<'pass> {
sizing_context::SizingContext::new(self.records, self.callbacks)
}
- /// Whether the block-axis percentage insets of the boxes whose containing block is the run's root resolve against a
- /// definite block size.
- pub(crate) fn percentage_block_insets_of_root_children_have_definite_basis(&self) -> bool {
+ /// Whether the block-axis percentage insets of the boxes whose containing block is the run's root, laid out in
+ /// `root`, resolve against a definite block size.
+ pub(crate) fn percentage_block_insets_of_root_children_have_definite_basis(
+ &self,
+ root: &impl BoxMetricCells,
+ ) -> bool {
percentage_block_insets_have_definite_basis_in(
&self.callbacks,
self.box_,
- || self.records.used_values(self.box_).has_definite_block_size(),
+ || root.has_definite_block_size(),
!self.treat_block_axis_percentage_insets_as_auto_beyond_root,
)
}
@@ -2961,6 +2964,7 @@ pub(crate) fn leave_child_unplaced(
/// fc_run_cache::run_observes_root_block_padding).
pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding(
run: &FormattingContextRun,
+ table_box: &impl BoxMetricCells,
cell: Node,
cell_input_cells: used_values::RootInputCells,
mut input: LayoutInput,
@@ -2976,7 +2980,7 @@ pub(crate) fn table_cell_run_shape_ahead_of_its_intrinsic_block_padding(
cell,
input,
false,
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(table_box),
);
ChildRunShape {
node: cell,
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index df708f8a789..1b6a7b90cdc 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -4415,7 +4415,9 @@ impl<'pass> GridFormattingContext<'pass> {
item.box_,
input,
false,
- self.run.percentage_block_insets_of_root_children_have_definite_basis(),
+ self.run.percentage_block_insets_of_root_children_have_definite_basis(
+ self.run.records.used_values(self.run.box_),
+ ),
);
formatting_context::ChildRunShape {
node: item.box_,
@@ -4489,7 +4491,7 @@ impl<'pass> GridFormattingContext<'pass> {
cells,
None,
false,
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
self.update_cells_of(item, |item_cells| *item_cells = laid_out_box.cells);
outcome.report_percentage_block_size_dependency_of(run, item.box_);
@@ -4513,7 +4515,7 @@ impl<'pass> GridFormattingContext<'pass> {
item.box_,
self.container_used(),
area.size,
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
let placed_item = placed_item.with_in_flow_box_insets(insets);
if self.item_participates_in_row_baseline_alignment(item)
diff --git a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
index 6e32791ae56..5cc27298532 100644
--- a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs
@@ -2170,7 +2170,7 @@ impl<'pass> MathFormattingContext<'pass> {
child_cells,
None,
true,
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
if let Some(fragment_arrival) = fragment_arrival {
self.fragment_arrivals_of_children.borrow_mut().push(fragment_arrival);
diff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
index 7f09a7f5861..b42fefc712a 100644
--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
@@ -2090,7 +2090,7 @@ impl<'pass> SvgFormattingContext<'pass> {
child_cells,
None,
true,
- run.percentage_block_insets_of_root_children_have_definite_basis(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
outcome.report_percentage_block_size_dependency_of(run, child);
assert!(
diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
index 5846eee7a26..e353ba487db 100644
--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
@@ -2693,7 +2693,7 @@ impl<'pass> TableFormattingContext<'pass> {
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(),
+ run.percentage_block_insets_of_root_children_have_definite_basis(run.records.used_values(run.box_)),
);
self.cell_box_cells[cell_index] = laid_out_box.cells;
self.content_baselines_of_handed_back_cells[cell_index] = Some(laid_out_box.baselines);
@@ -2784,6 +2784,7 @@ impl<'pass> TableFormattingContext<'pass> {
}
let shape = formatting_context::table_cell_run_shape_ahead_of_its_intrinsic_block_padding(
run,
+ run.records.used_values(run.box_),
cell.box_,
self.cell_box_cells[cell_index],
LayoutInput {