Truly independent web browser
LibWeb: Don’t let a trailing negative margin shorten columns
sideshowbarkerd1357dd76a3a
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 75f41bb05dd..16f73d5b6f0 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -5354,24 +5354,29 @@ impl<'pass> BlockFormattingContext<'pass> {if fragmentainer.keeps_box_layouts {return self.in_flow_reuse_storing_layout(key, validity, containing_block_position_in_root);}- return fragmentainer+ let Some(layout) = fragmentainer.box_layouts.layout_of(node)- .filter(|layout| {- layout.entry.validity == validity- && layout.entry.key == key- && self.column_box_layout_stays_unbroken_here(- node,- block_container,- fragmentainer,- layout,- containing_block_position_in_root,- )- })- .map_or(InFlowReuse::Ineligible, |layout| InFlowReuse::Hit {- entry: layout.entry.clone(),- fragment: layout.fragment.clone(),- });+ .filter(|layout| layout.entry.validity == validity && layout.entry.key == key)+ else {+ return InFlowReuse::Ineligible;+ };+ let Some(block_end) = self.column_box_layout_block_end_here(+ node,+ block_container,+ fragmentainer,+ &layout,+ containing_block_position_in_root,+ ) else {+ return InFlowReuse::Ineligible;+ };+ // NB: The stored layout places the box's contents without laying them out, so the column notes how far+ // they reach here.+ fragmentainer.note_content_block_end(block_end);+ return InFlowReuse::Hit {+ entry: layout.entry.clone(),+ fragment: layout.fragment.clone(),+ };}if self.run.pass.in_flow_block_cache_store().is_none()|| !self.in_flow_child_may_be_reused(node, block_container, containing_line_box_fragment)@@ -5420,22 +5425,23 @@ impl<'pass> BlockFormattingContext<'pass> {}}- /// Whether placing `layout` at the next position in this flow leaves every block end a column tests in the box- /// within this column, with nothing about the start of the column changing how the box lays out.- fn column_box_layout_stays_unbroken_here(+ /// How far the box of `layout` reaches when placed at the next position in this flow, where that leaves every+ /// block end a column tests in the box within this column, with nothing about the start of the column changing how+ /// the box lays out.+ fn column_box_layout_block_end_here(&self,node: Node,block_container: Node,fragmentainer: &fragmentation::Fragmentainer<'_>,layout: &fragmentation::ColumnBoxLayout,containing_block_position_in_root: FfiCssPixelPoint,- ) -> bool {+ ) -> Option<CssPixels> {let entry = &layout.entry;if self.discard_block_start_margin_of_next_child.get()|| self.margin_state().has_open_top_margin_group()|| !self.floats_read_by_contents_still_stand(node, entry, containing_block_position_in_root){- return false;+ return None;}self.rebuild_float_bands();let flow_position = self.flow_position();@@ -5466,7 +5472,8 @@ impl<'pass> BlockFormattingContext<'pass> {+ self.block_offset_adjustment_from_pending_ancestor_block_start_margins(block_container)+ position_past_floats.unwrap_or(flow_position)+ block_start_margin;- !fragmentainer.exceeds(border_box_block_start_in_root + layout.block_size_that_stays_unbroken)+ let block_end = border_box_block_start_in_root + layout.block_size_that_stays_unbroken;+ (!fragmentainer.exceeds(block_end)).then_some(block_end)}pub(crate) fn keeps_column_box_layouts(&self) -> bool {@@ -6485,6 +6492,7 @@ impl<'pass> BlockFormattingContext<'pass> {let Some(outcome) = outcome else {return FragmentationStep::LayOut;};+ let nested_lines_block_end = fragmentainer.take_pending_nested_lines_block_end();if let Some(broken) = &outcome.broken_inside {if self.allows_unforced_breaks() {let content_block_end = state.container_content_box_block_start_in_root@@ -6501,6 +6509,12 @@ impl<'pass> BlockFormattingContext<'pass> {}fragmentainer.outcome_mut().overflows = true;}+ fragmentainer.note_content_block_end(content_block_end);+ if let Some(nested_lines_block_end) = nested_lines_block_end {+ fragmentainer.note_content_block_end(nested_lines_block_end);+ }+ } else if let Some(nested_lines_block_end) = nested_lines_block_end {+ fragmentainer.note_pending_nested_lines_block_end(nested_lines_block_end);}self.fragmentainer_has_content.set(true);state.container_stop_token = self.stop_fragmentainer(@@ -6537,6 +6551,17 @@ impl<'pass> BlockFormattingContext<'pass> {}fragmentainer.outcome_mut().overflows = true;}+ // NB: A box that its margins collapse through holds no content, and where it ends is only provisional: A+ // later sibling's margin can still move it.+ if !outcome.collapses_through {+ fragmentainer.note_content_block_end(block_end);+ }+ if let Some(nested_lines_block_end) = nested_lines_block_end {+ fragmentainer.note_content_block_end(nested_lines_block_end);+ }+ } else if let Some(nested_lines_block_end) = nested_lines_block_end {+ // NB: Inside a box that avoids breaks, the step after that box decides if its lines stay.+ fragmentainer.note_pending_nested_lines_block_end(nested_lines_block_end);}let break_after = self.propagated_break_after(child);if fragmentation::is_forced_column_break(break_after) {@@ -6734,6 +6759,7 @@ impl<'pass> BlockFormattingContext<'pass> {fragmentainer.note_space_shortage(line_block_end_in_root);}if is_kept {+ fragmentainer.note_content_block_end(line_block_end_in_root);self.fragmentainer_has_content.set(true);}}@@ -6744,18 +6770,33 @@ impl<'pass> BlockFormattingContext<'pass> {}}- pub(crate) fn note_unbreakable_line_root(&self, line_root: Node, lines_block_end_in_root: CssPixels) {- if line_root != self.run.box_ {+ /// Notes how far the lines of `line_root` reach where the run lays them out without breaks, as inside a box that+ /// avoids breaks or has size containment.+ pub(crate) fn note_unfragmented_line_root(&self, line_root: Node, lines_block_end_in_root: CssPixels) {+ if line_root == self.run.box_ {return;}+ if let Some(fragmentainer) = self.run.fragmentainer.as_ref() {+ fragmentainer.note_pending_nested_lines_block_end(lines_block_end_in_root);+ }+ }++ pub(crate) fn note_unbreakable_line_root(&self, line_root: Node, lines_block_end_in_root: CssPixels) {let Some(fragmentainer) = self.run.fragmentainer.as_ref() else {return;};+ // NB: A line root inside a box of the run breaks, or doesn't, with that box: Its lines reach as far as they do+ // only if that box stays in the fragmentainer, which the step after the box decides.+ if line_root != self.run.box_ {+ fragmentainer.note_pending_nested_lines_block_end(lines_block_end_in_root);+ return;+ }fragmentainer.note_unbreakable_block_size(lines_block_end_in_root);if fragmentainer.exceeds(lines_block_end_in_root) {fragmentainer.note_space_shortage(lines_block_end_in_root);fragmentainer.outcome_mut().overflows = true;}+ fragmentainer.note_content_block_end(lines_block_end_in_root);}pub(crate) fn note_overflowing_content(&self) {@@ -7340,9 +7381,15 @@ impl<'pass> BlockFormattingContext<'pass> {}// NB: Only the attempt that is kept tells the host what it found out.self.run.pass.receive_residue(layout.residue);+ // NB: A column is as tall as the content it holds reaches, even where the content ends with a negative+ // margin: That margin moves up only what follows it in the column, and nothing does.+ let consumed_block_size = layout+ .outcome+ .automatic_content_block_size+ .max(outcome.content_block_end);return ColumnLayout {outcome,- consumed_block_size: layout.outcome.automatic_content_block_size,+ consumed_block_size,baselines: layout.outcome.baselines,root_line_data,contents,diff --git a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs b/Libraries/LibWeb/Rust/src/layout/fragmentation.rsindex 12906a08b98..0e9bb9c6a51 100644--- a/Libraries/LibWeb/Rust/src/layout/fragmentation.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragmentation.rs@@ -257,6 +257,12 @@ pub(crate) struct FragmentainerOutcome {pub(crate) tallest_unbreakable_block_size: CssPixels,pub(crate) violates_break_avoidance: bool,pub(crate) overflows: bool,+ /// How far the in-flow content laid out in the fragmentainer reaches: the furthest block end of its boxes and lines,+ /// which a negative margin after them doesn't take back.+ pub(crate) content_block_end: CssPixels,+ /// The furthest block end of the unbreakable lines of a line root inside the box being laid out, which counts toward+ /// `content_block_end` only once that box stays in the fragmentainer.+ pub(crate) pending_nested_lines_block_end: Option<CssPixels>,}/// The space a fragmentainer run lays out in: the fragmentainer's size, the break the run continues from, how it@@ -335,6 +341,24 @@ impl<'run> Fragmentainer<'run> {let mut outcome = self.outcome.borrow_mut();outcome.tallest_unbreakable_block_size = outcome.tallest_unbreakable_block_size.max(block_size);}++ pub(crate) fn note_content_block_end(&self, block_end: CssPixels) {+ let mut outcome = self.outcome.borrow_mut();+ outcome.content_block_end = outcome.content_block_end.max(block_end);+ }++ pub(crate) fn note_pending_nested_lines_block_end(&self, block_end: CssPixels) {+ let mut outcome = self.outcome.borrow_mut();+ outcome.pending_nested_lines_block_end = Some(+ outcome+ .pending_nested_lines_block_end+ .map_or(block_end, |end| end.max(block_end)),+ );+ }++ pub(crate) fn take_pending_nested_lines_block_end(&self) -> Option<CssPixels> {+ self.outcome.borrow_mut().pending_nested_lines_block_end.take()+ }}/// What the run of a fragmentainer hands the run of the box the fragmentainer belongs to.diff --git a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rsindex cbc15b97196..5c36c46854d 100644--- a/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/inline_formatting_context.rs@@ -3682,6 +3682,10 @@ impl<'context> InlineFormattingContext<'context> {self.discard_unplaced_atomic_inline(node);}}+ } else if let Some(last_line) = self.line_data().line_boxes.iter().rfind(|line| !line.is_empty()) {+ let lines_block_end_in_root = self.content_box_position_in_bfc_root().y + last_line.block_end;+ self.parent+ .note_unfragmented_line_root(self.containing_block, lines_block_end_in_root);}if lines_are_fragmented {let stop = kept_lines_end.unwrap_or(fragmentation::LinePosition::AFTER_LAST_LINE);diff --git a/Tests/LibWeb/Text/expected/multicol-box-reuse-geometry.txt b/Tests/LibWeb/Text/expected/multicol-box-reuse-geometry.txtindex 226a68b0ce9..bfb7243e27c 100644--- a/Tests/LibWeb/Text/expected/multicol-box-reuse-geometry.txt+++ b/Tests/LibWeb/Text/expected/multicol-box-reuse-geometry.txt@@ -4,12 +4,12 @@ own padding end past the column end after block-in-inline lines, lead 30: heightown padding end past the column end after block-in-inline lines, lead 45: height 130: 0,0 200x45 | 0,45 200x30 | 210,0 200x60 | 210,0 40.6875x10 + 210,10 200x10 + 210,20 26.515625x10 | 210,10 200x10 | 210,60 200x40 | 210,100 200x30own padding end past the column end after block-in-inline lines, lead 60: height 130: 0,0 200x60 | 0,60 200x30 | 210,0 200x60 | 210,0 40.6875x10 + 210,10 200x10 + 210,20 26.515625x10 | 210,10 200x10 | 210,60 200x40 | 210,100 200x30own padding end past the column end after block-in-inline lines, lead 75: height 130: 0,0 200x75 | 0,75 200x30 | 210,0 200x60 | 210,0 40.6875x10 + 210,10 200x10 + 210,20 26.515625x10 | 210,10 200x10 | 210,60 200x40 | 210,100 200x30-avoid box with overflowing lines after an empty formatting context, lead 0: height 50: 0,0 200x0 | 0,0 200x40 | 0,40 200x0 | 0,40 200x10 | 210,0 200x30-avoid box with overflowing lines after an empty formatting context, lead 15: height 48: 0,0 200x15 | 0,15 200x32.5 + 210,0 200x7.5 | 210,7.5 200x0 | 210,7.5 200x10 | 210,17.5 200x30-avoid box with overflowing lines after an empty formatting context, lead 30: height 55: 0,0 200x30 | 0,30 200x25 + 210,0 200x15 | 210,15 200x0 | 210,15 200x10 | 210,25 200x30-avoid box with overflowing lines after an empty formatting context, lead 45: height 63: 0,0 200x45 | 0,45 200x17.5 + 210,0 200x22.5 | 210,22.5 200x0 | 210,22.5 200x10 | 210,32.5 200x30-avoid box with overflowing lines after an empty formatting context, lead 60: height 70: 0,0 200x60 | 0,60 200x10 + 210,0 200x30 | 210,30 200x0 | 210,30 200x10 | 210,40 200x30-avoid box with overflowing lines after an empty formatting context, lead 75: height 78: 0,0 200x75 | 0,75 200x2.5 + 210,0 200x37.5 | 210,37.5 200x0 | 210,37.5 200x10 | 210,47.5 200x30+avoid box with overflowing lines after an empty formatting context, lead 0: height 145: 0,0 200x0 | 0,0 200x40 | 0,40 200x0 | 0,40 200x10 | 0,50 200x30+avoid box with overflowing lines after an empty formatting context, lead 15: height 153: 0,0 200x15 | 0,15 200x40 | 0,55 200x0 | 0,55 200x10 | 0,65 200x30+avoid box with overflowing lines after an empty formatting context, lead 30: height 160: 0,0 200x30 | 0,30 200x40 | 0,70 200x0 | 0,70 200x10 | 0,80 200x30+avoid box with overflowing lines after an empty formatting context, lead 45: height 168: 0,0 200x45 | 0,45 200x40 | 0,85 200x0 | 0,85 200x10 | 0,95 200x30+avoid box with overflowing lines after an empty formatting context, lead 60: height 175: 0,0 200x60 | 0,60 200x40 | 0,100 200x0 | 0,100 200x10 | 0,110 200x30+avoid box with overflowing lines after an empty formatting context, lead 75: height 183: 0,0 200x75 | 0,75 200x40 | 0,115 200x0 | 0,115 200x10 | 0,125 200x30clear box with a float and a negative margin, lead 0: height 90: 0,0 30x30 | 0,0 200x0 | 0,0 200x40 | 0,30 200x60 + 210,0 200x0 | 210,0 30x90 | 0,30 200x10 | 210,0 200x30clear box with a float and a negative margin, lead 15: height 90: 0,0 30x30 | 0,0 200x15 | 0,15 200x40 | 0,30 200x60 + 210,0 200x0 | 210,0 30x90 | 0,30 200x10 | 210,0 200x30clear box with a float and a negative margin, lead 30: height 90: 0,0 30x30 | 0,0 200x30 | 0,30 200x40 | 0,30 200x60 + 210,0 200x0 | 210,0 30x90 | 0,30 200x10 | 210,0 200x30@@ -23,11 +23,11 @@ float past the end of the box that contains it, lead 45: height 80: 0,0 200x45 |float past the end of the box that contains it, lead 60: height 85: 0,0 200x60 | 0,60 200x25 + 210,0 200x5 | 210,5 200x20 | 210,5 30x80 | 210,25 200x40 | 210,65 200x20float past the end of the box that contains it, lead 75: height 93: 0,0 200x75 | 0,75 200x17.5 + 210,0 200x12.5 | 210,12.5 200x20 | 210,12.5 30x80 | 210,32.5 200x40 | 210,72.5 200x20descendant box past the end of its fixed-height parent, lead 0: height 60: 0,0 200x0 | 0,0 200x30 | 0,30 200x20 + 210,0 200x0 | 0,30 200x30 + 210,0 200x60 | 210,0 200x40 | 210,40 200x20-descendant box past the end of its fixed-height parent, lead 15: height 70: 0,0 200x15 | 0,15 200x30 | 0,45 200x20 + 210,0 200x0 | 0,45 200x25 + 210,0 200x65 | 210,0 200x40 | 210,40 200x20-descendant box past the end of its fixed-height parent, lead 30: height 80: 0,0 200x30 | 0,30 200x30 | 0,60 200x20 + 210,0 200x0 | 0,60 200x20 + 210,0 200x70 | 210,0 200x40 | 210,40 200x20-descendant box past the end of its fixed-height parent, lead 45: height 88: 0,0 200x45 | 0,45 200x30 | 0,75 200x12.5 + 210,0 200x7.5 | 0,75 200x12.5 + 210,0 200x77.5 | 210,7.5 200x40 | 210,47.5 200x20+descendant box past the end of its fixed-height parent, lead 15: height 68: 0,0 200x15 | 0,15 200x30 | 0,45 200x20 + 210,0 200x0 | 0,45 200x22.5 + 210,0 200x67.5 | 210,0 200x40 | 210,40 200x20+descendant box past the end of its fixed-height parent, lead 30: height 75: 0,0 200x30 | 0,30 200x30 | 0,60 200x15 + 210,0 200x5 | 0,60 200x15 + 210,0 200x75 | 210,5 200x40 | 210,45 200x20+descendant box past the end of its fixed-height parent, lead 45: height 83: 0,0 200x45 | 0,45 200x30 | 0,75 200x7.5 + 210,0 200x12.5 | 0,75 200x7.5 + 210,0 200x82.5 | 210,12.5 200x40 | 210,52.5 200x20descendant box past the end of its fixed-height parent, lead 60: height 90: 0,0 200x60 | 0,60 200x30 | 210,0 200x20 | 210,0 200x90 | 210,20 200x40 | 210,60 200x20-descendant box past the end of its fixed-height parent, lead 75: height 103: 0,0 200x75 | 0,75 200x27.5 + 210,0 200x2.5 | 210,2.5 200x20 | 210,2.5 200x90 | 210,22.5 200x40 | 210,62.5 200x20+descendant box past the end of its fixed-height parent, lead 75: height 98: 0,0 200x75 | 0,75 200x22.5 + 210,0 200x7.5 | 210,7.5 200x20 | 210,7.5 200x90 | 210,27.5 200x40 | 210,67.5 200x20lines past the end of their fixed-height parent, lead 0: height 80: 0,0 200x0 | 0,0 200x30 | 0,30 200x20 + 210,0 200x0 | 210,0 200x40 | 210,40 200x20lines past the end of their fixed-height parent, lead 15: height 85: 0,0 200x15 | 0,15 200x30 | 0,45 200x20 + 210,0 200x0 | 210,0 200x40 | 210,40 200x20lines past the end of their fixed-height parent, lead 30: height 90: 0,0 200x30 | 0,30 200x30 | 0,60 200x20 + 210,0 200x0 | 210,0 200x40 | 210,40 200x20@@ -116,11 +116,11 @@ percentage block sizes in a wrapper that breaks, lead 0: height 130: 0,0 200x130percentage block sizes in a wrapper that breaks, lead 15: height 130: 0,0 200x130 + 210,0 200x110 | 0,0 200x15 | 0,15 200x48 | 0,63 200x67 + 210,0 200x5 | 210,5 200x60 | 210,65 200x24 | 210,110 200x20percentage block sizes in a wrapper that breaks, lead 30: height 130: 0,0 200x130 + 210,0 200x110 | 0,0 200x30 | 0,30 200x48 | 0,78 200x52 + 210,0 200x20 | 210,20 200x60 | 210,80 200x24 | 210,110 200x20percentage block sizes in a wrapper that breaks, lead 45: height 130: 0,0 200x130 + 210,0 200x110 | 0,0 200x45 | 0,45 200x48 | 0,93 200x37 + 210,0 200x35 | 210,35 200x60 | 210,95 200x24 | 210,110 200x20-percentage block sizes in a wrapper that breaks, lead 60: height 134: 0,0 200x134 + 210,0 200x106 | 0,0 200x60 | 0,60 200x48 | 0,108 200x26 + 210,0 200x46 | 210,46 200x60 | 210,106 200x24 | 210,106 200x20-percentage block sizes in a wrapper that breaks, lead 75: height 149: 0,0 200x149 + 210,0 200x91 | 0,0 200x75 | 0,75 200x48 | 0,123 200x26 + 210,0 200x46 | 210,46 200x60 | 210,106 200x24 | 210,91 200x20+percentage block sizes in a wrapper that breaks, lead 60: height 132: 0,0 200x132 + 210,0 200x108 | 0,0 200x60 | 0,60 200x48 | 0,108 200x24 + 210,0 200x48 | 210,48 200x60 | 210,108 200x24 | 210,108 200x20+percentage block sizes in a wrapper that breaks, lead 75: height 140: 0,0 200x139.5 + 210,0 200x100.5 | 0,0 200x75 | 0,75 200x48 | 0,123 200x16.5 + 210,0 200x55.5 | 210,55.5 200x60 | 210,115.5 200x24 | 210,100.5 200x20empty boxes and size containment, lead 0: height 82: 0,0 200x0 | 0,7 200x0 | 0,7 200x30 | 0,42 200x40 | 0,82 200x0 | 210,0 200x40 | 210,45 200x15 | 210,60 200x10empty boxes and size containment, lead 15: height 97: 0,0 200x15 | 0,22 200x0 | 0,22 200x30 | 0,57 200x40 | 0,97 200x0 | 210,0 200x40 | 210,45 200x15 | 210,60 200x10empty boxes and size containment, lead 30: height 110: 0,0 200x30 | 0,37 200x0 | 0,37 200x30 | 210,0 200x40 | 210,40 200x0 | 210,40 200x40 | 210,85 200x15 | 210,100 200x10empty boxes and size containment, lead 45: height 110: 0,0 200x45 | 0,52 200x0 | 0,52 200x30 | 210,0 200x40 | 210,40 200x0 | 210,40 200x40 | 210,85 200x15 | 210,100 200x10-empty boxes and size containment, lead 60: height 110: 0,0 200x60 | 0,67 200x0 | 0,67 200x30 | 210,0 200x40 | 210,40 200x0 | 210,40 200x40 | 210,85 200x15 | 210,100 200x10-empty boxes and size containment, lead 75: height 116: 0,0 200x75 | 0,82 200x0 | 0,82 200x30 | 210,0 200x40 | 210,40 200x0 | 210,40 200x40 | 210,85 200x15 | 210,100 200x10+empty boxes and size containment, lead 60: height 111: 0,0 200x60 | 0,67 200x0 | 0,67 200x30 | 210,0 200x40 | 210,40 200x0 | 210,40 200x40 | 210,85 200x15 | 210,100 200x10+empty boxes and size containment, lead 75: height 119: 0,0 200x75 | 0,82 200x0 | 0,82 200x30 | 210,0 200x40 | 210,40 200x0 | 210,40 200x40 | 210,85 200x15 | 210,100 200x10diff --git a/Tests/LibWeb/Text/expected/multicol-content-ending-in-negative-margin.txt b/Tests/LibWeb/Text/expected/multicol-content-ending-in-negative-margin.txtnew file mode 100644index 00000000000..c046e765628--- /dev/null+++ b/Tests/LibWeb/Text/expected/multicol-content-ending-in-negative-margin.txt@@ -0,0 +1,21 @@+minus-10: height 48, last at 0,24+minus-1: height 48, last at 0,24+two-columns: height 48, last at 150,24+two-columns-minus-24: height 48, last at 150,24+collapsing-through: height 48, last at 0,24+empty-last-child: height 48, last at 0,24+lines-overflowing-a-box: height 48, last at 0,24+lines-overflowing-an-unbreakable-box: height 49, last at 0,25+lines-overflowing-a-nested-unbreakable-box: height 49, last at 0,25+lines-in-a-block-of-an-unbreakable-box: height 49, last at 0,25+lines-in-an-unbreakable-box-with-a-positioned-child: height 49, last at 0,25+lines-in-an-unbreakable-box-before-a-forced-break: height 49, last at 0,25+fill-auto: height 100, last at 0,0+fill-auto-two-columns: height 100, last at 0,0+empty-box-margin-taken-back: height 24, last at 0,0+empty-box-margin-taken-back-balanced: height 24, last at 0,0+trailing-box: height 68, last at 0,48+overlapping-boxes: height 24, last at 0,-16+negative-top-margin: height 38, last at 0,14+positive-margin: height 58, last at 0,24+definite-height: height 30, last at 0,0diff --git a/Tests/LibWeb/Text/input/multicol-content-ending-in-negative-margin.html b/Tests/LibWeb/Text/input/multicol-content-ending-in-negative-margin.htmlnew file mode 100644index 00000000000..18322667d2a--- /dev/null+++ b/Tests/LibWeb/Text/input/multicol-content-ending-in-negative-margin.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<script src="include.js"></script>+<style>+ body { margin: 0; }+ .multicol { columns: 1; column-gap: 0; width: 300px; margin-bottom: 100px; }+ .two { columns: 2; }+ .line { height: 24px; }+ .lines { line-height: 24px; font-size: 16px; }+</style>+<!-- The content ends with a negative margin, which doesn't take back the space its lines take. -->+<div class="multicol" id="minus-10"><div style="margin-bottom: -10px"><div class="line"></div><div class="line last"></div></div></div>+<div class="multicol" id="minus-1"><div style="margin-bottom: -1px"><div class="line"></div><div class="line last"></div></div></div>+<div class="multicol two" id="two-columns"><div style="margin-bottom: -10px"><div class="line"></div><div class="line"></div><div class="line"></div><div class="line last"></div></div></div>+<div class="multicol two" id="two-columns-minus-24"><div><div class="line"></div><div class="line"></div><div class="line"></div><div class="line last" style="margin-bottom: -24px"></div></div></div>+<div class="multicol" id="collapsing-through"><div><div class="line"></div><div class="line last" style="margin-bottom: -30px"></div></div></div>+<div class="multicol" id="empty-last-child"><div><div class="line"></div><div class="line last"></div><div style="margin-bottom: -40px"></div></div></div>+<div class="multicol" id="lines-overflowing-a-box"><div class="lines" style="height: 10px">First<br><span class="last" style="display: inline-block; width: 10px; height: 24px; vertical-align: top"></span></div></div>+<!-- The lines of a box that doesn't break reach as far as they do, too, where the box stays in the column. -->+<div class="multicol" id="lines-overflowing-an-unbreakable-box"><div style="height: 1px"></div><div class="lines" style="height: 10px; break-inside: avoid; margin-bottom: -1px">First<br><span class="last" style="display: inline-block; width: 10px; height: 24px; vertical-align: top"></span></div></div>+<div class="multicol" id="lines-overflowing-a-nested-unbreakable-box"><div style="height: 1px"></div><div><div class="lines" style="height: 10px; break-inside: avoid; margin-bottom: -1px">First<br><span class="last" style="display: inline-block; width: 10px; height: 24px; vertical-align: top"></span></div></div></div>+<div class="multicol" id="lines-in-a-block-of-an-unbreakable-box"><div style="height: 1px"></div><div style="height: 10px; break-inside: avoid; margin-bottom: -1px"><div class="lines">First<br><span class="last" style="display: inline-block; width: 10px; height: 24px; vertical-align: top"></span></div></div></div>+<div class="multicol" id="lines-in-an-unbreakable-box-with-a-positioned-child"><div style="height: 1px"></div><div style="position: relative; height: 10px; break-inside: avoid; margin-bottom: -1px"><div class="lines">First<br><span class="last" style="display: inline-block; width: 10px; height: 24px; vertical-align: top"></span></div><div style="position: absolute; top: 0; width: 1px; height: 1px"></div></div></div>+<div class="multicol" id="lines-in-an-unbreakable-box-before-a-forced-break"><div style="height: 1px"></div><div style="height: 10px; break-inside: avoid; margin-bottom: -1px"><div class="lines">First<br><span class="last" style="display: inline-block; width: 10px; height: 24px; vertical-align: top"></span></div><div style="break-before: column; height: 5px"></div></div></div>+<!-- Columns filled in order hold all of a box whose own content ends past it, too. -->+<div class="multicol" id="fill-auto" style="column-fill: auto"><div><div class="last" style="height: 100px; margin-bottom: -50px"></div><div style="height: 10px"></div></div></div>+<div class="multicol two" id="fill-auto-two-columns" style="column-fill: auto"><div><div class="last" style="height: 100px; margin-bottom: -50px"></div><div style="height: 10px"></div></div></div>+<!-- An empty box takes no space of its own where a later margin takes its margin back. -->+<div class="multicol" id="empty-box-margin-taken-back" style="column-fill: auto"><div><div style="margin-top: 100px"></div><div class="line last" style="margin-top: -100px"></div></div></div>+<div class="multicol" id="empty-box-margin-taken-back-balanced"><div><div style="margin-top: 100px"></div><div class="line last" style="margin-top: -100px"></div></div></div>+<!-- A box after the content still takes its space, but no more than where its margin ends. -->+<div class="multicol" id="trailing-box"><div><div class="line"></div><div class="line"></div><div class="last" style="height: 20px; margin-bottom: -40px"></div></div></div>+<div class="multicol" id="overlapping-boxes"><div><div class="line" style="margin-bottom: -40px"></div><div class="line last"></div></div></div>+<div class="multicol" id="negative-top-margin"><div style="margin-top: -10px"><div class="line"></div><div class="line last"></div></div></div>+<div class="multicol" id="positive-margin"><div style="margin-bottom: 10px"><div class="line"></div><div class="line last"></div></div></div>+<!-- A definite height still sends what doesn't fit into a column of its own. -->+<div class="multicol" id="definite-height" style="height: 30px"><div style="margin-bottom: -10px"><div class="line"></div><div class="line last"></div></div></div>+<script>+ test(() => {+ for (const multicol of document.querySelectorAll(".multicol")) {+ const origin = multicol.getBoundingClientRect();+ const last = multicol.querySelector(".last").getBoundingClientRect();+ println(`${multicol.id}: height ${origin.height}, last at ${last.x - origin.x},${last.y - origin.y}`);+ }+ });+</script>