Skip to content

Truly independent web browser

LibWeb: Ignore min-height and max-height on table rows and cells

Andreas Kling4b58a6b21bd8
diff --git a/Libraries/LibWeb/Rust/src/layout/style_values.rs b/Libraries/LibWeb/Rust/src/layout/style_values.rs
index 833d8d7c623..275e21e1340 100644
--- a/Libraries/LibWeb/Rust/src/layout/style_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/style_values.rs
@@ -504,13 +504,28 @@ impl<'a> StyleValues<'a> {
.unwrap_or_else(|| unresolvable_anchor_size_or(self.unresolved_height(), auto_computed_size()))
}
+ /// Whether the box is a table row, row group or cell, whose 'min-height' and 'max-height' are ignored.
+ // NB: "In CSS 2.1, the effect of 'min-height' and 'max-height' on tables, inline tables, table cells, table rows,
+ // and row groups is undefined." https://www.w3.org/TR/CSS22/visudet.html#min-max-heights
+ // INTEROP: Other engines ignore them on table cells, rows and row groups.
+ fn ignores_min_and_max_height(self) -> bool {
+ let display = self.display();
+ display.is_table_cell() || display.is_table_row() || display.is_table_row_group_kind()
+ }
+
pub(crate) fn min_height(self) -> &'a ComputedSize {
+ if self.ignores_min_and_max_height() {
+ return auto_computed_size();
+ }
self.anchor_resolved_values
.and_then(|resolved| resolved.min_height.as_ref())
.unwrap_or_else(|| unresolvable_anchor_size_or(self.unresolved_min_height(), auto_computed_size()))
}
pub(crate) fn max_height(self) -> &'a ComputedSize {
+ if self.ignores_min_and_max_height() {
+ return none_computed_size();
+ }
self.anchor_resolved_values
.and_then(|resolved| resolved.max_height.as_ref())
.unwrap_or_else(|| unresolvable_anchor_size_or(self.unresolved_max_height(), none_computed_size()))
diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
index bd62efbeef0..8c981edb9e7 100644
--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
@@ -3045,9 +3045,7 @@ impl<'pass> TableFormattingContext<'pass> {
);
let cell_box = self.cell_layouts[cell_index].box_cells;
if self.needs_row_measurement {
- let min_size = style.min_height().to_px(participant_block_basis);
- let offsets = cell_box.border_box_top(collapsed) + cell_box.border_box_bottom(collapsed);
- let measured = cell_box.border_box_block_size(collapsed).max(min_size + offsets);
+ let measured = cell_box.border_box_block_size(collapsed);
self.cells[cell_index].outer_min_block_size = measured;
self.cells[cell_index].outer_max_block_size = measured;
}
diff --git a/Tests/LibWeb/Text/expected/table-cell-and-row-min-max-height-are-ignored.txt b/Tests/LibWeb/Text/expected/table-cell-and-row-min-max-height-are-ignored.txt
new file mode 100644
index 00000000000..6d31734d643
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/table-cell-and-row-min-max-height-are-ignored.txt
@@ -0,0 +1,11 @@
+1: 0+50 0+40 40+10
+2: 0+60 0+50 50+10
+3: 0+50 0+40 40+10
+4: 0+50 0+40 40+10
+5: 0+40 0+40
+6: 0+40 0+40
+7: 0+10 0+10
+8: 0+50 0+50
+9: 0+10 0+10
+10: 0+100
+11: 0+30 0+30
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/alignment/flex-align-baseline-table-001.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/alignment/flex-align-baseline-table-001.txt
index fee09bf88c0..f6b98ee0df9 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/alignment/flex-align-baseline-table-001.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-flexbox/alignment/flex-align-baseline-table-001.txt
@@ -2,13 +2,13 @@ Harness status: OK
Found 8 tests
-5 Pass
-3 Fail
+6 Pass
+2 Fail
Pass .target > * 1
Pass .target > * 2
Fail .target > * 3
Pass .target > * 4
-Fail .target > * 5
+Pass .target > * 5
Pass .target > * 6
Fail .target > * 7
Pass .target > * 8
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/input/table-cell-and-row-min-max-height-are-ignored.html b/Tests/LibWeb/Text/input/table-cell-and-row-min-max-height-are-ignored.html
new file mode 100644
index 00000000000..87a0c51785e
--- /dev/null
+++ b/Tests/LibWeb/Text/input/table-cell-and-row-min-max-height-are-ignored.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<style>
+body { margin: 0; }
+table { border-spacing: 0; width: 200px; }
+td { padding: 0; vertical-align: top; }
+.c { margin-bottom: 10px; }
+</style>
+<div id="cases">
+<div class="c"><table class="m"><tr class="m"><td style="box-sizing: border-box; min-height: 100px; padding: 20px"></td></tr><tr class="m" style="height: 10px"><td></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m"><td style="box-sizing: border-box; min-height: 100px; padding: 20px; border: 5px solid"></td></tr><tr class="m" style="height: 10px"><td></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m"><td style="min-height: 100px; padding: 20px"></td></tr><tr class="m" style="height: 10px"><td></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m"><td style="box-sizing: border-box; min-height: 30px; padding: 20px"></td></tr><tr class="m" style="height: 10px"><td></td></tr></table></div>
+<div class="c"><table class="m" style="table-layout: fixed"><tr class="m"><td style="box-sizing: border-box; min-height: 100px; padding: 20px"></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m"><td style="min-height: 100px; padding: 20px"></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m"><td style="min-height: 100px"><div style="height: 10px"></div></td><td><div style="height: 10px"></div></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m"><td style="max-height: 10px"><div style="height: 50px"></div></td></tr></table></div>
+<div class="c"><table class="m"><tr class="m" style="min-height: 100px"><td><div style="height: 10px"></div></td></tr></table></div>
+<div class="c"><div style="display: table; min-height: 100px; width: 200px" class="m"><div style="display: table-cell"><div style="height: 10px"></div></div></div></div>
+<div class="c"><table class="m"><tr class="m"><td style="height: 30px; min-height: 100px"><div style="height: 10px"></div></td></tr></table></div>
+</div>
+<script src="include.js"></script>
+<script>
+test(() => {
+ document.querySelectorAll(".c").forEach((c, i) => {
+ const o = c.getBoundingClientRect().top;
+ println(`${i + 1}: ` + [...c.querySelectorAll(".m")].map(e => { const r = e.getBoundingClientRect(); return `${Math.round(r.top - o)}+${Math.round(r.height)}`; }).join(" "));
+ });
+ document.getElementById("cases").remove();
+});
+</script>