Truly independent web browser
LibWeb: Place inline boxes from their values
Aliaksandr Kalenika810a518d6a9
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex cb8b0572d05..22936a834fe 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -361,6 +361,16 @@ pub(crate) struct PlacedChild {}impl PlacedChild {+ /// A child whose fragment shows `geometry`, in `frame`, before its parent decided anything about it.+ pub(crate) fn new(geometry: fragment_tree::FragmentGeometry, frame: geometry::Frame) -> Self {+ Self {+ geometry,+ frame,+ facts_decided_by_parent: run_records::FactsDecidedByParent::default(),+ offset_from_relatively_positioned_inline_ancestors: FfiCssPixelPoint::default(),+ }+ }+/// A child whose run handed back the box `laid_out` with the lines `line_data`, in `frame`, before its parent/// decided anything about it.pub(crate) fn of_laid_out_box(@@ -368,22 +378,20 @@ impl PlacedChild {line_data: Option<std::sync::Arc<inline_content::InlineContent>>,frame: geometry::Frame,) -> Self {- Self {- geometry: fragment_tree::FragmentGeometry {+ Self::new(+ fragment_tree::FragmentGeometry {cells: laid_out.cells,line_data,},frame,- facts_decided_by_parent: run_records::FactsDecidedByParent::default(),- offset_from_relatively_positioned_inline_ancestors: FfiCssPixelPoint::default(),- }+ )}/// A box that `run` lays out in `record`, before its parent decided anything about it.pub(crate) fn of_record(record: &UsedValues, run: &FormattingContextRun) -> Self {let callbacks = &run.callbacks;- Self {- geometry: fragment_tree::FragmentGeometry {+ Self::new(+ fragment_tree::FragmentGeometry {cells: used_values::RecordInFrame::new(record, callbacks.frame).cells(),// NB: Only a run that builds fragments shows the lines it laid out in the boxes it places.line_data: run@@ -392,10 +400,8 @@ impl PlacedChild {.then(|| record.finish_line_data(callbacks)).flatten(),},- frame: callbacks.frame,- facts_decided_by_parent: run_records::FactsDecidedByParent::default(),- offset_from_relatively_positioned_inline_ancestors: FfiCssPixelPoint::default(),- }+ callbacks.frame,+ )}/// The child with the insets its parent resolved for it as an in-flow box.diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rsindex f47d5449622..e0970cf0c74 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs@@ -1005,8 +1005,8 @@ pub(crate) struct InlineFormattingContext<'context> {struct EnteredInlineBox {/// The sizes and box sides of the box.sides: used_values::RootInputCells,- /// The used insets of the box, which are zero unless it is relatively positioned.- used_insets: run_records::UsedInsets,+ /// What the insets of the box resolved to.+ insets: abspos_engine::InFlowBoxInsets,}impl<'context> InlineFormattingContext<'context> {@@ -1213,13 +1213,9 @@ impl<'context> InlineFormattingContext<'context> {sides: used_values::RootInputCells,insets: abspos_engine::InFlowBoxInsets,) {- self.entered_inline_boxes.borrow_mut().insert(- node,- EnteredInlineBox {- sides,- used_insets: insets.used_insets.unwrap_or_default(),- },- );+ self.entered_inline_boxes+ .borrow_mut()+ .insert(node, EnteredInlineBox { sides, insets });}fn entered_inline_box(&self, node: Node) -> Option<used_values::RootInputCells> {@@ -1236,12 +1232,30 @@ impl<'context> InlineFormattingContext<'context> {.expect("the inline formatting context entered the inline box")}+ /// What placing `node`, an inline box this context entered, takes.+ #[track_caller]+ fn placed_entered_inline_box(&self, node: Node) -> formatting_context::PlacedChild {+ let entered = *self+ .entered_inline_boxes+ .borrow()+ .get(&node)+ .expect("the inline formatting context entered the inline box");+ formatting_context::PlacedChild::new(+ fragment_tree::FragmentGeometry {+ cells: entered.sides,+ line_data: None,+ },+ self.callbacks.frame,+ )+ .with_in_flow_box_insets(entered.insets)+ }+/// The relative-position insets of the inline boxes this context entered from `first_ancestor` up to its/// containing block, summed.fn relative_insets_of_inline_ancestors(&self, first_ancestor: Node) -> InlineAncestorChainRelativeOffset {let used_insets_of_entered_inline_box = |ancestor| {if let Some(entered) = self.entered_inline_boxes.borrow().get(&ancestor) {- return entered.used_insets;+ return entered.insets.used_insets.unwrap_or_default();}// NB: A floated inline node can hold inline content this context lays out among its lines, while its// float's own layout resolves its insets.@@ -2258,7 +2272,7 @@ impl<'context> InlineFormattingContext<'context> {formatting_context::place_child(self.run,node,- formatting_context::PlacedChild::read_from_records(self.run, node),+ self.placed_entered_inline_box(node),FfiCssPixelPoint::default(),None,);diff --git a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rsindex ab78f9bdb50..a10677490d6 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_level_iterator.rs@@ -1020,7 +1020,7 @@ fn record_entered_inline_box(formatting_context::place_child(context.run,node,- formatting_context::PlacedChild::read_from_records(context.run, node),+ formatting_context::PlacedChild::of_record(used, context.run).with_in_flow_box_insets(insets),FfiCssPixelPoint::default(),None,);