LibWeb: Skip cells layout in table box width calculation

There is no need to run full table layout if we are only interested in
calculating its width.

This change reduces compute_table_box_width_inside_table_wrapper()
from ~30% to ~15% in profiles of "File changed" pages on github.
This commit is contained in:
Aliaksandr Kalenik 2024-03-19 10:18:49 +01:00 committed by Andreas Kling
commit 6fc59039c4
Notes: sideshowbarker 2024-07-17 03:10:07 +09:00
3 changed files with 23 additions and 9 deletions

View file

@ -1577,12 +1577,10 @@ void TableFormattingContext::finish_grid_initialization(TableGrid const& table_g
}
}
void TableFormattingContext::run(Box const& box, LayoutMode layout_mode, AvailableSpace const& available_space)
void TableFormattingContext::run_until_width_calculation(Box const& box, AvailableSpace const& available_space)
{
m_available_space = available_space;
auto total_captions_height = run_caption_layout(layout_mode, CSS::CaptionSide::Top);
// Determine the number of rows/columns the table requires.
finish_grid_initialization(TableGrid::calculate_row_column_grid(box, m_cells, m_rows));
@ -1603,6 +1601,15 @@ void TableFormattingContext::run(Box const& box, LayoutMode layout_mode, Availab
// Compute the width of the table.
compute_table_width();
}
void TableFormattingContext::run(Box const& box, LayoutMode layout_mode, AvailableSpace const& available_space)
{
m_available_space = available_space;
auto total_captions_height = run_caption_layout(layout_mode, CSS::CaptionSide::Top);
run_until_width_calculation(box, available_space);
if (available_space.width.is_intrinsic_sizing_constraint() && !available_space.height.is_intrinsic_sizing_constraint()) {
return;