From cf40b95be808c41ca3b797d75445f21a00f1224a Mon Sep 17 00:00:00 2001 From: Andi Gallo Date: Sun, 9 Jul 2023 04:57:03 +0000 Subject: [PATCH] LibWeb: Resolve table border conflicts with rows --- .../border-conflict-resolution-with-row.txt | 69 +++++++++++++++++++ .../border-conflict-resolution-with-row.html | 31 +++++++++ .../LibWeb/Layout/TableFormattingContext.cpp | 16 ++++- 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Layout/expected/table/border-conflict-resolution-with-row.txt create mode 100644 Tests/LibWeb/Layout/input/table/border-conflict-resolution-with-row.html diff --git a/Tests/LibWeb/Layout/expected/table/border-conflict-resolution-with-row.txt b/Tests/LibWeb/Layout/expected/table/border-conflict-resolution-with-row.txt new file mode 100644 index 0000000000..b8776c6000 --- /dev/null +++ b/Tests/LibWeb/Layout/expected/table/border-conflict-resolution-with-row.txt @@ -0,0 +1,69 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x600 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x130.40625 children: not-inline + TableWrapper <(anonymous)> at (8,8) content-size 114.8125x130.40625 [BFC] children: not-inline + Box at (8,8) content-size 114.8125x130.40625 table-box [TFC] children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box at (8,8) content-size 114.8125x130.40625 table-row-group children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box at (8,8) content-size 114.8125x43.46875 table-row children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (8,51.46875) content-size 114.8125x43.46875 table-row children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer
at (31,21) content-size 14.265625x17.46875 table-cell [BFC] children: inline + line 0 width: 14.265625, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [31,21 14.265625x17.46875] + "A" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (87.265625,21) content-size 12.546875x17.46875 table-cell [BFC] children: inline + line 0 width: 9.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [87.265625,21 9.34375x17.46875] + "B" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box
at (29,64.46875) content-size 16.265625x17.46875 table-cell [BFC] children: inline + line 0 width: 10.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [29,64.46875 10.3125x17.46875] + "C" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (87.265625,64.46875) content-size 14.546875x17.46875 table-cell [BFC] children: inline + line 0 width: 11.140625, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [87.265625,64.46875 11.140625x17.46875] + "D" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + Box at (8,94.9375) content-size 114.8125x43.46875 table-row children: not-inline + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (31,107.9375) content-size 14.265625x17.46875 table-cell [BFC] children: inline + line 0 width: 11.859375, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [31,107.9375 11.859375x17.46875] + "E" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer at (87.265625,107.9375) content-size 12.546875x17.46875 table-cell [BFC] children: inline + line 0 width: 12.546875, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 0, length: 1, rect: [87.265625,107.9375 12.546875x17.46875] + "F" + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> + BlockContainer <(anonymous)> (not painted) children: inline + TextNode <#text> diff --git a/Tests/LibWeb/Layout/input/table/border-conflict-resolution-with-row.html b/Tests/LibWeb/Layout/input/table/border-conflict-resolution-with-row.html new file mode 100644 index 0000000000..8047f06d70 --- /dev/null +++ b/Tests/LibWeb/Layout/input/table/border-conflict-resolution-with-row.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + +
AB
CD
EF
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index 9d25cb0276..be5ccc384c 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -1051,7 +1051,7 @@ Vector TableFormattingContext::BorderCo Cell const& cell, TableFormattingContext::ConflictingSide edge) const { // FIXME: Conflicting elements can be cells, rows, row groups, columns, column groups, and the table itself, - // but we only consider cells, 'col' elements in a 'colgroup' and the table itself for now. + // but we only consider cells, rows, 'col' elements in a 'colgroup' and the table itself for now. Vector result = {}; if (cell.column_index >= cell.column_span && edge == ConflictingSide::Left) { auto maybe_cell_to_left = m_context->m_cells_by_coordinate[cell.row_index][cell.column_index - cell.column_span]; @@ -1077,6 +1077,18 @@ Vector TableFormattingContext::BorderCo result.append({ maybe_cell_below->box, ConflictingSide::Top }); } } + if (edge == ConflictingSide::Top) { + result.append({ m_context->m_rows[cell.row_index].box, ConflictingSide::Top }); + } + if (edge == ConflictingSide::Bottom) { + result.append({ m_context->m_rows[cell.row_index].box, ConflictingSide::Bottom }); + } + if (cell.row_index >= cell.row_span && edge == ConflictingSide::Top) { + result.append({ m_context->m_rows[cell.row_index - cell.row_span].box, ConflictingSide::Bottom }); + } + if (cell.row_index + cell.row_span < m_context->m_rows.size() && edge == ConflictingSide::Bottom) { + result.append({ m_context->m_rows[cell.row_index + cell.row_span].box, ConflictingSide::Top }); + } if (m_col_elements_by_index[cell.column_index] && edge == ConflictingSide::Left) { result.append({ m_col_elements_by_index[cell.column_index], ConflictingSide::Left }); } @@ -1102,9 +1114,11 @@ Vector TableFormattingContext::BorderCo result.append({ &m_context->table_box(), ConflictingSide::Bottom }); } if (cell.column_index == 0 && edge == ConflictingSide::Left) { + result.append({ m_context->m_rows[cell.row_index].box, ConflictingSide::Left }); result.append({ &m_context->table_box(), ConflictingSide::Left }); } if (cell.column_index == m_context->m_columns.size() - 1 && edge == ConflictingSide::Right) { + result.append({ m_context->m_rows[cell.row_index].box, ConflictingSide::Right }); result.append({ &m_context->table_box(), ConflictingSide::Right }); } return result;