at (8,49.46875) content-size 113.40625x41.46875 table-row children: not-inline
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+ BlockContainer at (31,62.46875) 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,62.46875 14.265625x17.46875]
+ "A"
+ TextNode <#text>
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+ BlockContainer | at (87.265625,62.46875) content-size 11.140625x17.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,62.46875 9.34375x17.46875]
+ "B"
+ TextNode <#text>
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+ Box |
at (8,90.9375) content-size 113.40625x41.46875 table-row children: not-inline
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+ BlockContainer at (31,101.9375) content-size 14.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: [31,101.9375 10.3125x17.46875]
+ "C"
+ TextNode <#text>
+ BlockContainer <(anonymous)> (not painted) children: inline
+ TextNode <#text>
+ BlockContainer | at (87.265625,101.9375) content-size 11.140625x17.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,101.9375 11.140625x17.46875]
+ "D"
+ 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-rowgroup.html b/Tests/LibWeb/Layout/input/table/border-conflict-resolution-with-rowgroup.html
new file mode 100644
index 0000000000..c99ceb6c2e
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/table/border-conflict-resolution-with-rowgroup.html
@@ -0,0 +1,32 @@
+
+
+
+
+ 0 |
+ 1 |
+
+
+
+ A |
+ B |
+
+
+ C |
+ D |
+
+
+
\ No newline at end of file
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
index be5ccc384c..adc9fa6827 100644
--- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -1025,6 +1026,7 @@ TableFormattingContext::BorderConflictFinder::BorderConflictFinder(TableFormatti
: m_context(context)
{
collect_conflicting_col_elements();
+ collect_conflicting_row_group_elements();
}
void TableFormattingContext::BorderConflictFinder::collect_conflicting_col_elements()
@@ -1047,11 +1049,29 @@ void TableFormattingContext::BorderConflictFinder::collect_conflicting_col_eleme
}
}
+void TableFormattingContext::BorderConflictFinder::collect_conflicting_row_group_elements()
+{
+ m_row_group_elements_by_index.resize(m_context->m_rows.size());
+ size_t current_row_index = 0;
+ for_each_child_box_matching(m_context->table_box(), is_table_row_group, [&](auto& row_group_box) {
+ auto start_row_index = current_row_index;
+ size_t row_count = 0;
+ for_each_child_box_matching(row_group_box, is_table_row, [&](auto&) {
+ ++row_count;
+ });
+ for_each_child_box_matching(row_group_box, is_table_row, [&](auto&) {
+ m_row_group_elements_by_index[current_row_index] = RowGroupInfo {
+ .row_group = &row_group_box, .start_index = start_row_index, .row_count = row_count
+ };
+ ++current_row_index;
+ return IterationDecision::Continue;
+ });
+ });
+}
+
Vector TableFormattingContext::BorderConflictFinder::conflicting_edges(
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, 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];
@@ -1089,6 +1109,25 @@ Vector TableFormattingContext::BorderCo
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 });
}
+ auto const& maybe_row_group = m_row_group_elements_by_index[cell.row_index];
+ if (maybe_row_group.has_value() && cell.row_index == maybe_row_group->start_index && edge == ConflictingSide::Top) {
+ result.append({ maybe_row_group->row_group, ConflictingSide::Top });
+ }
+ if (cell.row_index >= cell.row_span) {
+ auto const& maybe_row_group_above = m_row_group_elements_by_index[cell.row_index - cell.row_span];
+ if (maybe_row_group_above.has_value() && cell.row_index == maybe_row_group_above->start_index + maybe_row_group_above->row_count && edge == ConflictingSide::Top) {
+ result.append({ maybe_row_group_above->row_group, ConflictingSide::Bottom });
+ }
+ }
+ if (maybe_row_group.has_value() && cell.row_index == maybe_row_group->start_index + maybe_row_group->row_count - 1 && edge == ConflictingSide::Bottom) {
+ result.append({ maybe_row_group->row_group, ConflictingSide::Bottom });
+ }
+ if (cell.row_index + cell.row_span < m_row_group_elements_by_index.size()) {
+ auto const& maybe_row_group_below = m_row_group_elements_by_index[cell.row_index + cell.row_span];
+ if (maybe_row_group_below.has_value() && cell.row_index + cell.row_span == maybe_row_group_below->start_index && edge == ConflictingSide::Bottom) {
+ result.append({ maybe_row_group_below->row_group, 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 });
}
@@ -1115,10 +1154,16 @@ Vector TableFormattingContext::BorderCo
}
if (cell.column_index == 0 && edge == ConflictingSide::Left) {
result.append({ m_context->m_rows[cell.row_index].box, ConflictingSide::Left });
+ if (m_row_group_elements_by_index[cell.row_index].has_value()) {
+ result.append({ m_row_group_elements_by_index[cell.row_index]->row_group, 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 });
+ if (m_row_group_elements_by_index[cell.row_index].has_value()) {
+ result.append({ m_row_group_elements_by_index[cell.row_index]->row_group, ConflictingSide::Right });
+ }
result.append({ &m_context->table_box(), ConflictingSide::Right });
}
return result;
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h
index 1a20a1ab7c..87dceadcbd 100644
--- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h
@@ -143,8 +143,16 @@ private:
private:
void collect_conflicting_col_elements();
+ void collect_conflicting_row_group_elements();
+
+ struct RowGroupInfo {
+ Node const* row_group;
+ size_t start_index;
+ size_t row_count;
+ };
Vector m_col_elements_by_index;
+ Vector> m_row_group_elements_by_index;
TableFormattingContext const* m_context;
};
|