mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 19:59:17 +00:00
LibWeb: Don't crash with non-<col> table-column
This commit is contained in:
parent
5b522c096e
commit
863092afdc
Notes:
github-actions[bot]
2025-07-01 09:19:36 +00:00
Author: https://github.com/Gingeh
Commit: 863092afdc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5262
4 changed files with 50 additions and 6 deletions
|
@ -74,7 +74,7 @@ void TableFormattingContext::compute_constrainedness()
|
||||||
if (computed_values.width().is_length()) {
|
if (computed_values.width().is_length()) {
|
||||||
m_columns[column_index].is_constrained = true;
|
m_columns[column_index].is_constrained = true;
|
||||||
}
|
}
|
||||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*column_box.dom_node());
|
auto const& col_node = static_cast<HTML::HTMLElement const&>(*column_box.dom_node());
|
||||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||||
column_index += span;
|
column_index += span;
|
||||||
});
|
});
|
||||||
|
@ -191,7 +191,7 @@ void TableFormattingContext::compute_outer_content_sizes()
|
||||||
m_columns[column_index].min_size = max(min_width, width);
|
m_columns[column_index].min_size = max(min_width, width);
|
||||||
// The outer max-content width of a table-column or table-column-group is max(min-width, min(max-width, width)).
|
// The outer max-content width of a table-column or table-column-group is max(min-width, min(max-width, width)).
|
||||||
m_columns[column_index].max_size = max(min_width, min(max_width, width));
|
m_columns[column_index].max_size = max(min_width, min(max_width, width));
|
||||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*column_box.dom_node());
|
auto const& col_node = static_cast<HTML::HTMLElement const&>(*column_box.dom_node());
|
||||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||||
column_index += span;
|
column_index += span;
|
||||||
});
|
});
|
||||||
|
@ -1393,7 +1393,7 @@ void TableFormattingContext::BorderConflictFinder::collect_conflicting_col_eleme
|
||||||
size_t column_index = 0;
|
size_t column_index = 0;
|
||||||
for (auto* child_of_column_group = child->first_child(); child_of_column_group; child_of_column_group = child_of_column_group->next_sibling()) {
|
for (auto* child_of_column_group = child->first_child(); child_of_column_group; child_of_column_group = child_of_column_group->next_sibling()) {
|
||||||
VERIFY(child_of_column_group->display().is_table_column());
|
VERIFY(child_of_column_group->display().is_table_column());
|
||||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*child_of_column_group->dom_node());
|
auto const& col_node = static_cast<HTML::HTMLElement const&>(*child_of_column_group->dom_node());
|
||||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||||
m_col_elements_by_index.resize(column_index + span);
|
m_col_elements_by_index.resize(column_index + span);
|
||||||
for (size_t i = column_index; i < column_index + span; ++i) {
|
for (size_t i = column_index; i < column_index + span; ++i) {
|
||||||
|
@ -1792,7 +1792,7 @@ void TableFormattingContext::initialize_intrinsic_percentages_from_rows_or_colum
|
||||||
auto width_percentage = computed_values.width().is_percentage() ? computed_values.width().percentage().value() : 0;
|
auto width_percentage = computed_values.width().is_percentage() ? computed_values.width().percentage().value() : 0;
|
||||||
m_columns[column_index].has_intrinsic_percentage = computed_values.max_width().is_percentage() || computed_values.width().is_percentage();
|
m_columns[column_index].has_intrinsic_percentage = computed_values.max_width().is_percentage() || computed_values.width().is_percentage();
|
||||||
m_columns[column_index].intrinsic_percentage = min(width_percentage, max_width_percentage);
|
m_columns[column_index].intrinsic_percentage = min(width_percentage, max_width_percentage);
|
||||||
auto const& col_node = static_cast<HTML::HTMLTableColElement const&>(*column_box.dom_node());
|
auto const& col_node = static_cast<HTML::HTMLElement const&>(*column_box.dom_node());
|
||||||
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
unsigned span = col_node.get_attribute_value(HTML::AttributeNames::span).to_number<unsigned>().value_or(1);
|
||||||
column_index += span;
|
column_index += span;
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,8 +65,9 @@ TableGrid TableGrid::calculate_row_column_grid(Box const& box, Vector<Cell>& cel
|
||||||
|
|
||||||
auto process_col_group = [&](auto& col_group) {
|
auto process_col_group = [&](auto& col_group) {
|
||||||
auto dom_node = col_group.dom_node();
|
auto dom_node = col_group.dom_node();
|
||||||
dom_node->template for_each_in_subtree_of_type<HTML::HTMLTableColElement>([&](auto&) {
|
dom_node->for_each_in_subtree([&](auto& descendant) {
|
||||||
x_width += 1;
|
if (descendant.layout_node() && descendant.layout_node()->display().is_table_column())
|
||||||
|
x_width += 1;
|
||||||
return TraversalDecision::Continue;
|
return TraversalDecision::Continue;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
22
Tests/LibWeb/Layout/expected/display-table-column-crash.txt
Normal file
22
Tests/LibWeb/Layout/expected/display-table-column-crash.txt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x16 [BFC] children: not-inline
|
||||||
|
BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <body> at (8,8) content-size 784x0 children: not-inline
|
||||||
|
BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
TableWrapper <(anonymous)> at (8,8) content-size 0x0 [BFC] children: not-inline
|
||||||
|
Box <(anonymous)> at (8,8) content-size 0x0 table-box [TFC] children: not-inline
|
||||||
|
BlockContainer <div#test> (not painted) table-column-group children: not-inline
|
||||||
|
BlockContainer <div.col> (not painted) children: not-inline
|
||||||
|
BlockContainer <div.col> (not painted) children: not-inline
|
||||||
|
BlockContainer <(anonymous)> (not painted) children: inline
|
||||||
|
TextNode <#text>
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x16]
|
||||||
|
PaintableWithLines (BlockContainer(anonymous)) [0,0 800x0]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0]
|
||||||
|
PaintableWithLines (BlockContainer(anonymous)) [8,8 784x0]
|
||||||
|
PaintableWithLines (TableWrapper(anonymous)) [8,8 0x0]
|
||||||
|
PaintableBox (Box(anonymous)) [8,8 0x0]
|
21
Tests/LibWeb/Layout/input/display-table-column-crash.html
Normal file
21
Tests/LibWeb/Layout/input/display-table-column-crash.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
#test {
|
||||||
|
display: table-column-group;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col {
|
||||||
|
display: table-column;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="test">
|
||||||
|
<div class="col"></div>
|
||||||
|
<div class="col"></div>
|
||||||
|
</div>
|
||||||
|
</body>
|
Loading…
Add table
Add a link
Reference in a new issue