Truly independent web browser
LibWeb: Hand absolutely positioned placements their layout inputs
Aliaksandr Kalenik74ddacb899c8
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rsindex a4d8da80cb8..a97ef7fc8e8 100644--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs@@ -3174,9 +3174,6 @@ impl<'pass> AbsposEngine<'pass> {}}self.records.set_used_insets(node, used_insets);- if self.fragments.is_some() {- self.used(node).rare_data_mut().abspos_layout_inputs = Some(inputs);- }formatting_context::place_child_in_containing_block(run,node,@@ -3186,6 +3183,7 @@ impl<'pass> AbsposEngine<'pass> {y: used_offset.block_offset,},None,+ Some(inputs),);}diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex a38166f4068..e763c15598a 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -359,15 +359,17 @@ pub(crate) fn place_child(containing_line_box_fragment: Option<used_values::LineBoxFragmentCoordinate>,) -> Option<fragment_tree::PlacedFragment> {let containing_block = run.callbacks.in_flow_containing_block(node);- place_child_in_containing_block(run, node, containing_block, offset, containing_line_box_fragment)+ place_child_in_containing_block(run, node, containing_block, offset, containing_line_box_fragment, None)}+/// Places `node` in `containing_block`. An absolutely positioned box hands its link the inputs it was laid out with.pub(crate) fn place_child_in_containing_block(run: &FormattingContextRun,node: Node,containing_block: Node,offset: FfiCssPixelPoint,containing_line_box_fragment: Option<used_values::LineBoxFragmentCoordinate>,+ abspos_layout_inputs: Option<abspos_inputs::AbsposLayoutInputs>,) -> Option<fragment_tree::PlacedFragment> {let records = run.records;let callbacks = &run.callbacks;@@ -387,8 +389,8 @@ pub(crate) fn place_child_in_containing_block(fragment.clone(),reuses_subtree,(!containing_block.is_invalid()).then_some(containing_block),- used,facts_decided_by_parent,+ abspos_layout_inputs,containing_block_is_placed_or_outside_run(records, containing_block),resolve_containing_line_box_index(records, callbacks, node, containing_block, containing_line_box_fragment),point_add(@@ -426,6 +428,7 @@ pub(crate) fn place_child_in_containing_block((!containing_block.is_invalid()).then_some(containing_block),used,records.facts_decided_by_parent_of(node),+ abspos_layout_inputs,containing_block_is_placed_or_outside_run(records, containing_block),resolve_containing_line_box_index(records, callbacks, node, containing_block, containing_line_box_fragment),point_add(@@ -461,8 +464,8 @@ pub(crate) fn place_reused_child(fragment,true,(!containing_block.is_invalid()).then_some(containing_block),- records.used_values(node),records.facts_decided_by_parent_of(node),+ None,containing_block_is_placed_or_outside_run(records, containing_block),None,point_add(@@ -3513,6 +3516,7 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {None,root_used,facts_decided_by_parent,+ None,false,None,placement.content_offset_in_containing_block,diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rsindex fa5acdc4f3c..762a4a3825d 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs@@ -544,13 +544,12 @@ pub(crate) struct PlacementData {impl PlacementData {fn of_box(- used: &UsedValues,facts: &run_records::FactsDecidedByParent,+ abspos_layout_inputs: Option<abspos_inputs::AbsposLayoutInputs>,containing_line_box_index: Option<usize>,committed_offset: FfiCssPixelPoint,frame: geometry::Frame,) -> Self {- let rare = used.rare_data.get().map(|cell| cell.borrow());Self {frame,committed_offset,@@ -559,7 +558,7 @@ impl PlacementData {inset_top: facts.used_insets.top,inset_bottom: facts.used_insets.bottom,containing_line_box_index,- abspos_layout_inputs: rare.as_ref().and_then(|rare| rare.abspos_layout_inputs),+ abspos_layout_inputs,default_scroll_shift: facts.default_scroll_shift,containing_block: facts.placement@@ -576,9 +575,9 @@ impl PlacementData {frame: geometry::Frame,) -> Self {Self::of_box(- records.used_values(node),&records.facts_decided_by_parent_of(node),None,+ None,records.content_offset_or_origin(node),frame,)@@ -1255,6 +1254,7 @@ impl RunFragmentBuilder {containing_block: Option<crate::layout::node_data::NodeSlotId>,used: &UsedValues,facts: run_records::FactsDecidedByParent,+ abspos_layout_inputs: Option<abspos_inputs::AbsposLayoutInputs>,containing_block_is_sealed: bool,containing_line_box_index: Option<usize>,committed_offset: FfiCssPixelPoint,@@ -1281,8 +1281,8 @@ impl RunFragmentBuilder {let link = link_fragment(fragment.clone(),PlacementData::of_box(- used,&facts,+ abspos_layout_inputs,containing_line_box_index,committed_offset,callbacks.frame,@@ -1367,8 +1367,8 @@ impl RunFragmentBuilder {fragment: std::sync::Arc<Fragment>,reuses_subtree: bool,containing_block: Option<crate::layout::node_data::NodeSlotId>,- used: &UsedValues,facts: run_records::FactsDecidedByParent,+ abspos_layout_inputs: Option<abspos_inputs::AbsposLayoutInputs>,containing_block_is_sealed: bool,containing_line_box_index: Option<usize>,committed_offset: FfiCssPixelPoint,@@ -1386,7 +1386,13 @@ impl RunFragmentBuilder {);let link = link_fragment(fragment,- PlacementData::of_box(used, &facts, containing_line_box_index, committed_offset, frame),+ PlacementData::of_box(+ &facts,+ abspos_layout_inputs,+ containing_line_box_index,+ committed_offset,+ frame,+ ),);self.attach(&mut inner, link, containing_block, containing_block_is_sealed);if reuses_subtree {diff --git a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rsindex 82bc8f39d89..fd445073d28 100644--- a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs+++ b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs@@ -308,7 +308,6 @@ fn rare_payloads_match(math_paint_data,used_grid_tracks,collapsed_table_borders,- abspos_layout_inputs,orthogonal_flow_baselines,} = left;computed_svg_path.as_deref() == right.computed_svg_path.as_deref()@@ -320,7 +319,6 @@ fn rare_payloads_match(&& math_paint_data.as_deref() == right.math_paint_data.as_deref()&& used_grid_tracks.as_deref() == right.used_grid_tracks.as_deref()&& collapsed_table_borders.as_deref() == right.collapsed_table_borders.as_deref()- && *abspos_layout_inputs == right.abspos_layout_inputs&& *orthogonal_flow_baselines == right.orthogonal_flow_baselines}diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rsindex e9acb997bd4..179e1ecab69 100644--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs@@ -246,7 +246,6 @@ pub(crate) struct UsedValuesRareData {pub(crate) math_paint_data: Option<std::sync::Arc<math_formatting_context::MathPaintData>>,pub(crate) used_grid_tracks: Option<std::sync::Arc<grid_formatting_context::OwnedUsedGridTracks>>,pub(crate) collapsed_table_borders: Option<std::sync::Arc<table_formatting_context::OwnedCollapsedTableBorders>>,- pub(crate) abspos_layout_inputs: Option<abspos_inputs::AbsposLayoutInputs>,/// For a box that establishes an orthogonal flow, its baselines as distances along the horizontal axis of the frame/// it is laid out in, from the left edge of its content box.pub(crate) orthogonal_flow_baselines: Option<DerivedBaselines>,@@ -264,13 +263,8 @@ impl UsedValuesRareData {math_paint_data,used_grid_tracks,collapsed_table_borders,- abspos_layout_inputs,orthogonal_flow_baselines,} = self;- debug_assert!(- abspos_layout_inputs.is_none(),- "a run authored a parent-owned rare payload on its root record"- );if computed_svg_path.is_none()&& svg_text_character_cells.is_none()&& svg == CommittedSvgFacts::default()