Skip to content

Truly independent web browser

LibWeb: Finalize an atomic root's block size from its own run

Aliaksandr Kalenik953f9947a67c
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index cffc0a368d2..6cf7c96e132 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -4303,7 +4303,7 @@ impl<'pass> BlockFormattingContext<'pass> {
context.run();
}
- pub(crate) fn compute_automatic_block_size_for_block_level_element(
+ fn compute_automatic_block_size_for_block_level_element(
&self,
node: Node,
available_space: AvailableSpace,
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 299e0601ad6..ce3b71cd67b 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -124,7 +124,6 @@ pub(crate) fn run_root_without_parent_fragments(
callbacks,
input,
None,
- None,
)
}
@@ -151,7 +150,6 @@ pub(crate) fn run_fragmentainer(
input,
None,
None,
- None,
Some(fragmentainer),
)
}
@@ -1813,7 +1811,6 @@ pub(super) fn run_formatting_context(
should_collect_devtools_layout_data: bool,
callbacks: LayoutPass<'_>,
input: LayoutInput,
- parent_block: Option<&block_formatting_context::BlockFormattingContext>,
table_inline_layout: Option<table_formatting_context::TableInlineLayout>,
) -> ChildLayoutResult {
if let Some(parent_fragments) = parent_fragments {
@@ -1837,7 +1834,6 @@ pub(super) fn run_formatting_context(
should_collect_devtools_layout_data,
callbacks,
input,
- parent_block,
None,
table_inline_layout,
None,
@@ -1908,7 +1904,6 @@ pub(super) fn run_formatting_context(
should_collect_devtools_layout_data,
callbacks,
input,
- parent_block,
None,
table_inline_layout.clone(),
None,
@@ -1924,7 +1919,6 @@ pub(super) fn run_formatting_context(
should_collect_devtools_layout_data,
callbacks,
input,
- parent_block,
previous_line_data,
table_inline_layout,
None,
@@ -1950,7 +1944,6 @@ pub(super) fn run_formatting_context(
should_collect_devtools_layout_data,
callbacks,
other_input,
- parent_block,
None,
None,
None,
@@ -2030,7 +2023,6 @@ fn execute_formatting_context_run(
should_collect_devtools_layout_data: bool,
callbacks: LayoutPass<'_>,
input: LayoutInput,
- parent_block: Option<&block_formatting_context::BlockFormattingContext>,
previous_line_data: Option<std::sync::Arc<inline_content::InlineContent>>,
table_inline_layout: Option<table_formatting_context::TableInlineLayout>,
fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,
@@ -2228,7 +2220,7 @@ fn execute_formatting_context_run(
finalize_float_root(run, &input, &result);
}
ParticipationInParentFormattingContext::AtomicInline => {
- finalize_atomic_root_block_size(run, &input, result.automatic_content_block_size, parent_block);
+ finalize_atomic_root_block_size(run, &input, result.automatic_content_block_size);
}
ParticipationInParentFormattingContext::AbsolutelyPositioned(abspos_inputs) => {
abspos_engine::AbsposEngine::for_run(run).finalize_out_of_flow_root_after_inside_layout(
@@ -2515,7 +2507,6 @@ fn finalize_atomic_root_block_size(
run: &FormattingContextRun,
input: &LayoutInput,
automatic_content_block_size_of_completed_body_run: CssPixels,
- parent_block: Option<&block_formatting_context::BlockFormattingContext>,
) {
let node = run.box_;
let available_space = input.available_space;
@@ -2525,28 +2516,25 @@ fn finalize_atomic_root_block_size(
return;
}
if sizing.should_treat_block_size_as_auto(node, available_space, constraints) {
- sizing.resolve_used_block_size_if_treated_as_auto(node, available_space, constraints, None, || {
- let available_inner_space = run
- .records
- .used_values(node)
- .available_inner_space_or_constraints_from(available_space);
- match parent_block {
- Some(parent) => parent.compute_automatic_block_size_for_block_level_element(
- node,
- available_inner_space,
- constraints,
- Some(automatic_content_block_size_of_completed_body_run),
- ),
- None => independent_root_automatic_block_size(
- run.records,
- &run.callbacks,
- node,
- available_inner_space,
- constraints,
- Some(automatic_content_block_size_of_completed_body_run),
- ),
- }
- });
+ let parent_lays_out_root_as_math_content =
+ formatting_context_type_created_by_box(NodeFacts::new(&run.callbacks, run.callbacks.parent(node)))
+ == Some(FormattingContextType::Math);
+ let automatic_block_size = if parent_lays_out_root_as_math_content {
+ automatic_content_block_size_of_completed_body_run
+ } else {
+ block_formatting_context::floor_list_item_automatic_block_size_by_marker_line_height(
+ run.callbacks,
+ node,
+ automatic_content_block_size_of_completed_body_run,
+ )
+ };
+ sizing.resolve_used_block_size_if_treated_as_auto(
+ node,
+ available_space,
+ constraints,
+ Some(automatic_block_size),
+ || unreachable!("a completed atomic run always supplies its automatic content block size"),
+ );
} else {
sizing.resolve_used_block_size_if_not_treated_as_auto(node, available_space, constraints);
}
@@ -2679,7 +2667,6 @@ pub(crate) fn layout_inside_child(
run.should_collect_devtools_layout_data,
run.callbacks,
input,
- parent_block,
run.records.take_table_inline_layout(child),
);
propagate_percentage_block_size_dependency_to_containing_block(
@@ -2845,7 +2832,6 @@ pub(crate) fn lay_out_shape_for_its_result(callbacks: LayoutPass<'_>, shape: Chi
false,
callbacks,
input,
- None,
previous_line_data,
None,
None,
@@ -3294,7 +3280,6 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
callbacks,
input,
None,
- None,
);
place_child(&entry_run, root_for_layout, FfiCssPixelPoint::default(), None);
finish_entry_pass(
@@ -3439,7 +3424,6 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {
*callbacks,
input,
None,
- None,
);
// The retained offset already includes relative positioning. Publish it directly instead
// of applying placement adjustments a second time.
diff --git a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs
index ee7098a3036..f3305c4acb8 100644
--- a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs
@@ -65,7 +65,6 @@ pub(super) fn layout_replaced_with_children(
participation: geometry::ParticipationInParentFormattingContext::Item,
},
None,
- None,
);
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
run.records,