Truly independent web browser
LibWeb: Place a rendered legend from the value its layout returned
Aliaksandr Kalenik2638747c1295
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 53d352591bd..267424803ae 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -409,6 +409,8 @@ pub(crate) struct BlockFormattingContext<'pass> {block_offset_of_current_block_container: Cell<Option<CssPixels>>,pending_legend_flow_position: Cell<Option<geometry::LogicalOffset>>,pending_legend_fragment_arrival: Cell<Option<fragment_tree::ChildFragmentArrival>>,+ /// What placing the rendered legend takes from its layout, which the fieldset places after its other children.+ pending_legend_placed_child: Cell<Option<formatting_context::PlacedChild>>,margin_state: RefCell<BlockMarginState>,floats: RefCell<Vec<FloatingBox>>,bands: RefCell<SmallVec<[FloatBand; 4]>>,@@ -533,6 +535,7 @@ impl<'pass> BlockFormattingContext<'pass> {block_offset_of_current_block_container: Cell::new(None),pending_legend_flow_position: Cell::new(None),pending_legend_fragment_arrival: Cell::new(None),+ pending_legend_placed_child: Cell::new(None),margin_state: RefCell::new(BlockMarginState::default()),floats: RefCell::new(Vec::new()),bands: RefCell::new(smallvec![FloatBand::default()]),@@ -2829,18 +2832,19 @@ impl<'pass> BlockFormattingContext<'pass> {let insets = self.compute_inset(run, node, block_container);+ let placed_child = child_handed_back_by_its_run+ .unwrap_or_else(|| formatting_context::PlacedChild::of_record(self.used(node), &self.run))+ .with_in_flow_box_insets(insets)+ .with_fragment_facts(fragment_facts)+ .with_offset_from_relatively_positioned_inline_ancestors(+ interrupted_inline_content.map_or(FfiCssPixelPoint::default(), |interrupted| {+ interrupted.offset_from_relatively_positioned_inline_ancestors+ }),+ );let mut placed = match pending_position {Some(position) => self.place_laid_out_child_on_line(node,- child_handed_back_by_its_run- .unwrap_or_else(|| formatting_context::PlacedChild::of_record(self.used(node), &self.run))- .with_in_flow_box_insets(insets)- .with_fragment_facts(fragment_facts)- .with_offset_from_relatively_positioned_inline_ancestors(- interrupted_inline_content.map_or(FfiCssPixelPoint::default(), |interrupted| {- interrupted.offset_from_relatively_positioned_inline_ancestors- }),- ),+ placed_child,position,containing_line_box_fragment,fragment_arrival_of_child_with_own_formatting_context,@@ -2852,6 +2856,7 @@ impl<'pass> BlockFormattingContext<'pass> {);self.pending_legend_fragment_arrival.set(fragment_arrival_of_child_with_own_formatting_context);+ self.pending_legend_placed_child.set(Some(placed_child));None}};@@ -4211,10 +4216,11 @@ impl<'pass> BlockFormattingContext<'pass> {+ legend_border_box_centering_offset+ legend_metrics.border_box_top(false);let legend_fragment_arrival = self.pending_legend_fragment_arrival.take();+ let placed_legend = self.pending_legend_placed_child.take();if let Some(legend_flow_position) = self.pending_legend_flow_position.take() {self.place_laid_out_child(legend,- formatting_context::PlacedChild::read_from_records(&self.run, legend),+ placed_legend.expect("the rendered legend is laid out before the fieldset places it"),FfiCssPixelPoint {x: legend_flow_position.inline_offset,y: legend_content_block_offset,diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 8006c68e0d6..bacf7a5004b 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -427,43 +427,6 @@ impl PlacedChild {self.offset_from_relatively_positioned_inline_ancestors = offset;self}-- // FIXME: Remove this adapter once every caller hands placement the values it holds.- pub(crate) fn read_from_records(run: &FormattingContextRun, node: Node) -> Self {- let records = run.records;- // NB: A run that builds no fragments reads no geometry of the boxes it places.- let geometry = if run.fragments.is_some() {- records.fragment_geometry_of(node, &run.callbacks)- } else {- fragment_tree::FragmentGeometry {- cells: records.box_metrics_of(node).input_cells(),- line_data: None,- }- };- let callbacks = &run.callbacks;- let facts = NodeFacts::new(callbacks, node);- let mut offset_from_relatively_positioned_inline_ancestors = FfiCssPixelPoint::default();- if facts.is_in_flow() && facts.display().is_block_outside() {- let chain = inline_formatting_context::accumulated_relative_insets_from_inline_ancestor_chain(- callbacks,- callbacks.parent(node),- callbacks.in_flow_containing_block(node),- |ancestor| records.used_insets_of(ancestor),- );- if chain.found_fragmented_inline_node {- offset_from_relatively_positioned_inline_ancestors = FfiCssPixelPoint {- x: chain.offset_x,- y: chain.offset_y,- };- }- }- Self {- geometry,- frame: run.callbacks.frame,- facts_decided_by_parent: records.facts_decided_by_parent_of(node),- offset_from_relatively_positioned_inline_ancestors,- }- }}pub(crate) fn place_child(