Skip to content

Commit

Permalink
LibWeb: Properly handle thead and tfooter HTML tags
Browse files Browse the repository at this point in the history
As the spec for the table fixup algorythm says:

> Treat table-row-groups in this spec also encompass the specialized
> table-header-groups and table-footer-groups.
  • Loading branch information
ant1441 authored and awesomekling committed Apr 19, 2021
1 parent c32b588 commit ae02acb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Userland/Libraries/LibWeb/Layout/TreeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ static bool is_table_track(CSS::Display display)

static bool is_table_track_group(CSS::Display display)
{
return display == CSS::Display::TableRowGroup || display == CSS::Display::TableColumnGroup;
// Unless explicitly mentioned otherwise, mentions of table-row-groups in this spec also encompass the specialized
// table-header-groups and table-footer-groups.
return display == CSS::Display::TableRowGroup || display == CSS::Display::TableHeaderGroup || display == CSS::Display::TableFooterGroup
|| display == CSS::Display::TableColumnGroup;
}

static bool is_not_proper_table_child(const Node& node)
Expand Down Expand Up @@ -290,6 +293,18 @@ void TreeBuilder::generate_missing_child_wrappers(NodeWithStyle& root)
wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
});
});
// Unless explicitly mentioned otherwise, mentions of table-row-groups in this spec also encompass the specialized
// table-header-groups and table-footer-groups.
for_each_in_tree_with_display<CSS::Display::TableHeaderGroup>(root, [&](auto& parent) {
for_each_sequence_of_consecutive_children_matching(parent, is_not_table_row, [&](auto& sequence, auto nearest_sibling) {
wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
});
});
for_each_in_tree_with_display<CSS::Display::TableFooterGroup>(root, [&](auto& parent) {
for_each_sequence_of_consecutive_children_matching(parent, is_not_table_row, [&](auto& sequence, auto nearest_sibling) {
wrap_in_anonymous<TableRowBox>(sequence, nearest_sibling);
});
});

// An anonymous table-cell box must be generated around each sequence of consecutive children of a table-row box which are not table-cell boxes. !Testcase
for_each_in_tree_with_display<CSS::Display::TableRow>(root, [&](auto& parent) {
Expand Down

0 comments on commit ae02acb

Please sign in to comment.