Truly independent web browser
LibWeb: Size auto-filled columns of a multicol container by content
Aliaksandr Kalenik85dd48520e33
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex ce1661e8f4b..858b05f15a8 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -3006,7 +3006,7 @@ impl<'pass> BlockFormattingContext<'pass> {} = self.layout_column(self.run.purpose,column_input,- column_block_size,+ Some(column_block_size),incoming,column_origin(column_index),root_line_count,@@ -3036,7 +3036,11 @@ impl<'pass> BlockFormattingContext<'pass> {&root_line_data_of_columns,));}- let row_block_size = column_block_size.unwrap_or(content_block_size);+ let row_block_size = if style.column_fill() == column_fill::AUTO {+ content_block_size+ } else {+ column_block_size+ };root_used.rare_data_mut().multicol_layout_data = Some(std::sync::Arc::new(fragmentation::MulticolLayoutData {column_inline_size: geometry.inline_size,column_gap: geometry.gap,@@ -3056,7 +3060,7 @@ impl<'pass> BlockFormattingContext<'pass> {column_input: LayoutInput,geometry: fragmentation::ColumnGeometry,definite_block_size: Option<CssPixels>,- ) -> Option<CssPixels> {+ ) -> CssPixels {let root = self.run.box_;let style = self.style(root);let sizing = self.sizing();@@ -3082,9 +3086,12 @@ impl<'pass> BlockFormattingContext<'pass> {// https://drafts.csswg.org/css-multicol-1/#cf// auto: Fills columns sequentially.if style.column_fill() == column_fill::AUTO {- return maximum_block_size;+ return maximum_block_size.unwrap_or_else(|| {+ let (runs, _) = self.measure_runs_between_forced_breaks(column_input);+ runs.into_iter().max().unwrap_or_default()+ });}- Some(self.balanced_column_block_size(column_input, geometry, maximum_block_size))+ self.balanced_column_block_size(column_input, geometry, maximum_block_size)}fn balanced_column_block_size(diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-multicol/columnfill-auto-max-height-003.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-multicol/columnfill-auto-max-height-003.htmlnew file mode 100644index 00000000000..b4cc4f5d5af--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-multicol/columnfill-auto-max-height-003.html@@ -0,0 +1,10 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://www.w3.org/TR/css-multicol-1/#cf">+<link rel="match" href="../../../../expected/wpt-import/css/css-multicol/../reference/ref-filled-green-100px-square.xht">+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>+<div style="width:100px; height:100px; background:red;">+ <div style="columns:2; gap:0; column-fill:auto; max-height:200px; background:red;">+ <div style="width:200%; height:100px; background:green;"></div>+ </div>+</div>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-multicol/multicol-fill-auto-004.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-multicol/multicol-fill-auto-004.htmlnew file mode 100644index 00000000000..f59575ffff2--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-multicol/multicol-fill-auto-004.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<link rel="author" title="Morten Stenshorne" href="mailto:[email protected]">+<link rel="help" href="https://www.w3.org/TR/css-multicol-1/#cf">+<link rel="match" href="../../../../expected/wpt-import/css/css-multicol/../reference/ref-filled-green-100px-square.xht">+<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>+<div style="width:100px; height:100px; background:red;">+ <div style="columns:5; gap:10px; column-fill:auto; column-rule:10px solid green;">+ <div style="background:green;">+ <div style="height:10px;"></div>+ <div style="break-before:column; height:10px;"></div>+ <div style="break-before:column; height:10px;"></div>+ <div style="break-before:column; height:10px;"></div>+ <div style="break-before:column; height:100px;"></div>+ </div>+ </div>+</div>