Truly independent web browser
LibWeb: Keep fragment facts with the child that shows them
Aliaksandr Kalenik012a7b1acc75
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex aa79f2c4fc4..0c16f25db02 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -144,16 +144,23 @@ struct LaidOutBlockLevelBox {/// The box as its layout left it: as a run of its own handed it back, or as this flow laid it out in a record its/// layout owns.laid_out_box: run_records::LaidOutChildBox,+ /// What this flow decided the box's fragment shows of it.+ fragment_facts: run_records::FragmentFactsDecidedByParent,}impl LaidOutBlockLevelBox {- /// A box laid out as `laid_out_box`, which neither broke inside nor let margins collapse through it.- fn of_box(laid_out_box: run_records::LaidOutChildBox) -> Self {+ /// A box laid out as `laid_out_box` with `fragment_facts`, which neither broke inside nor let margins collapse+ /// through it.+ fn of_box(+ laid_out_box: run_records::LaidOutChildBox,+ fragment_facts: run_records::FragmentFactsDecidedByParent,+ ) -> Self {Self {broken_inside: None,has_unbreakable_lines: false,collapses_through: false,laid_out_box,+ fragment_facts,}}}@@ -2260,7 +2267,7 @@ impl<'pass> BlockFormattingContext<'pass> {cells,content_baselines,collapses_through: laid_out.collapses_through,- is_invisible_for_line_clamp: self.run.records.is_invisible_for_line_clamp(node),+ is_invisible_for_line_clamp: laid_out.fragment_facts.is_invisible_for_line_clamp,can_break_inside: self.box_can_break_inside(node, laid_out.has_unbreakable_lines),broken_inside: laid_out.broken_inside,baselines_in_containing_block,@@ -2337,7 +2344,6 @@ impl<'pass> BlockFormattingContext<'pass> {.track_percentage_block_size_dependency_while_laying_out(node);let mut fragment_facts = run_records::FragmentFactsDecidedByParent::default();if self.laying_out_invisible_line_clamp_content.get() {- self.run.records.hide_for_line_clamp(node);fragment_facts.is_invisible_for_line_clamp = true;}if facts.is_anonymous_button_content_wrapper() {@@ -2377,7 +2383,6 @@ impl<'pass> BlockFormattingContext<'pass> {cells.border_top = CssPixels::default();cells.padding_top = CssPixels::default();});- self.run.records.note_continues_from_previous_fragment(node);fragment_facts.continues_from_previous_fragment = true;}@@ -2400,9 +2405,11 @@ impl<'pass> BlockFormattingContext<'pass> {if let Some(floating_box) = self.floats.borrow().last() {*bottom_of_lowest_margin_box = (*bottom_of_lowest_margin_box).max(floating_box.bottom_margin_edge);}- return Some(LaidOutBlockLevelBox::of_box(float_handed_back_by_its_run.expect(- "a floating box of a block formatting context is laid out by a run of its own",- )));+ return Some(LaidOutBlockLevelBox::of_box(+ float_handed_back_by_its_run+ .expect("a floating box of a block formatting context is laid out by a run of its own"),+ fragment_facts,+ ));}let in_flow_reuse = match self.probe_in_flow_reuse(@@ -2422,6 +2429,7 @@ impl<'pass> BlockFormattingContext<'pass> {);return Some(LaidOutBlockLevelBox::of_box(Self::laid_out_box_in_record_its_layout_owns(sized_child),+ fragment_facts,));}attempt => attempt,@@ -2487,7 +2495,10 @@ impl<'pass> BlockFormattingContext<'pass> {);return Some(LaidOutBlockLevelBox {collapses_through: self.margins_collapse_through(sized_child, None),- ..LaidOutBlockLevelBox::of_box(Self::laid_out_box_in_record_its_layout_owns(sized_child))+ ..LaidOutBlockLevelBox::of_box(+ Self::laid_out_box_in_record_its_layout_owns(sized_child),+ fragment_facts,+ )});}// If first child margin top will collapse with margin-top of containing block then margin-top of child is 0@@ -2907,7 +2918,6 @@ impl<'pass> BlockFormattingContext<'pass> {used.padding_bottom.set(CssPixels::default());used.border_bottom.set(CssPixels::default());used.margin_bottom.set(CssPixels::default());- self.run.records.note_continues_in_next_fragment(node);fragment_facts.continues_in_next_fragment = true;std::rc::Rc::make_mut(&mut token).consumed_block_size = continuation.as_ref()@@ -3011,8 +3021,7 @@ impl<'pass> BlockFormattingContext<'pass> {};if !collapses_through {let mut margin_state = self.margin_state.borrow_mut();- if !margin_state.box_last_in_flow_child_margin_bottom_collapsed- || self.run.records.continues_in_next_fragment(node)+ if !margin_state.box_last_in_flow_child_margin_bottom_collapsed || fragment_facts.continues_in_next_fragment{margin_state.reset();}@@ -3048,6 +3057,7 @@ impl<'pass> BlockFormattingContext<'pass> {collapses_through,laid_out_box: laid_out_box_handed_back_by_its_run.unwrap_or_else(|| Self::laid_out_box_in_record_its_layout_owns(sized_child)),+ fragment_facts,})}diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rsindex 265a713c3c5..8ceae018d77 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs@@ -1103,7 +1103,6 @@ impl<'context> InlineFormattingContext<'context> {}fn hide_placed_atomic_inline_for_line_clamp(&self, node: Node) {- self.run.records.hide_for_line_clamp(node);self.update_placed_atomic_inline(node, |mut placed_child| {placed_child.facts_decided_by_parent@@ -2062,9 +2061,6 @@ impl<'context> InlineFormattingContext<'context> {&record_of_float_without_formatting_context_of_its_own,)};- if state_at_clamp_point.is_some() {- self.run.records.hide_for_line_clamp(item.node);- }self.clear_floating_boxes(item.node);line_builder.set_unbreakable_run_inline_size_interrupted_by_float(iterator.next_unbreakable_run_inline_size(self),diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rsindex 50de56ad2cb..760a01bfe0b 100644--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs@@ -716,64 +716,6 @@ impl<'arena> RunRecords<'arena> {}}- #[track_caller]- fn update_fragment_facts_decided_by_parent_of(- &self,- node: Node,- update: impl FnOnce(&mut FragmentFactsDecidedByParent),- ) {- assert!(- !self.is_root_with_record(node),- "what a box's fragment shows of its parent's layout is decided by the run of that parent"- );- let mut facts = self.facts_decided_by_parent_of(node);- update(&mut facts.fragment_facts);- self.keep_facts_decided_by_parent_of(node, facts);- }-- /// Places `node` in the table grid columns starting at `first_column_index`.- #[track_caller]- pub(crate) fn place_in_table_columns(&self, node: Node, first_column_index: u32, column_span: u32) {- self.update_fragment_facts_decided_by_parent_of(node, |facts| {- facts.table_column_index = first_column_index;- facts.table_column_span = column_span;- });- }-- #[track_caller]- pub(crate) fn set_hidden_by_collapsed_columns(&self, node: Node, hidden: bool) {- self.update_fragment_facts_decided_by_parent_of(node, |facts| facts.hidden_by_collapsed_columns = hidden);- }-- #[track_caller]- pub(crate) fn hide_for_line_clamp(&self, node: Node) {- self.update_fragment_facts_decided_by_parent_of(node, |facts| facts.is_invisible_for_line_clamp = true);- }-- #[track_caller]- pub(crate) fn is_invisible_for_line_clamp(&self, node: Node) -> bool {- self.facts_decided_by_parent_of(node)- .fragment_facts- .is_invisible_for_line_clamp- }-- #[track_caller]- pub(crate) fn note_continues_from_previous_fragment(&self, node: Node) {- self.update_fragment_facts_decided_by_parent_of(node, |facts| facts.continues_from_previous_fragment = true);- }-- #[track_caller]- pub(crate) fn note_continues_in_next_fragment(&self, node: Node) {- self.update_fragment_facts_decided_by_parent_of(node, |facts| facts.continues_in_next_fragment = true);- }-- #[track_caller]- pub(crate) fn continues_in_next_fragment(&self, node: Node) -> bool {- self.facts_decided_by_parent_of(node)- .fragment_facts- .continues_in_next_fragment- }-/// Where `node` is placed, if this run placed it.pub(crate) fn placement_of(&self, node: Node) -> Option<BoxPlacement> {self.kept_facts_decided_by_parent_of(node)?.placementdiff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rsindex 2eac50a5824..6868aace041 100644--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs@@ -1552,11 +1552,6 @@ impl<'pass> TableFormattingContext<'pass> {cells}).collect();- for cell in &self.cells {- self.run- .records- .place_in_table_columns(cell.box_, cell.column_index as u32, cell.column_span as u32);- }self.cell_fragment_facts = self.cells.iter()@@ -2857,9 +2852,6 @@ impl<'pass> TableFormattingContext<'pass> {// out like any other cell (with no inline size, see remove_collapsed_columns), and painting skips it.// https://www.w3.org/TR/CSS22/tables.html#dynamic-effectslet hidden_by_collapsed_columns = self.visible_spanned_columns(cell) == 0;- self.run- .records- .set_hidden_by_collapsed_columns(cell.box_, hidden_by_collapsed_columns);self.cell_fragment_facts[cell_index].hidden_by_collapsed_columns = hidden_by_collapsed_columns;let height = style.height();if !self.rows[cell.row_index].is_collapsed && height.is_length() {@@ -3498,9 +3490,6 @@ impl<'pass> TableFormattingContext<'pass> {} else {CssPixels::default()};- self.run- .records- .place_in_table_columns(node, start as u32, (end - start) as u32);let fragment_facts = run_records::FragmentFactsDecidedByParent {table_column_index: start as u32,table_column_span: (end - start) as u32,