From 0e1da540b66a464cba01d1ad0a4c8fbfef3b50d1 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 8 Jan 2023 00:57:57 +0300 Subject: LibWeb: Move cells positioning in separate function in TFC --- .../LibWeb/Layout/TableFormattingContext.cpp | 54 ++++++++++++---------- .../LibWeb/Layout/TableFormattingContext.h | 1 + 2 files changed, 30 insertions(+), 25 deletions(-) (limited to 'Userland/Libraries/LibWeb') diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index df0568502c..b3cbd1b62f 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -446,38 +446,14 @@ void TableFormattingContext::position_row_boxes() }); } -void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const& available_space) +void TableFormattingContext::position_cell_boxes() { - m_available_space = available_space; - - CSSPixels total_content_height = 0; - - // Determine the number of rows/columns the table requires. - calculate_row_column_grid(box); - - // Compute the minimum width of each column. - compute_table_measures(); - - if (available_space.width.is_intrinsic_sizing_constraint()) { - determine_intrisic_size_of_table_container(available_space); - return; - } - - // Compute the width of the table. - compute_table_width(); - - // Distribute the width of the table among columns. - distribute_width_to_columns(); - CSSPixels left_column_offset = 0; for (auto& column : m_columns) { column.left_offset = left_column_offset; left_column_offset += column.used_width; } - calculate_row_heights(); - position_row_boxes(); - for (auto& cell : m_cells) { auto& cell_state = m_state.get_mutable(cell.box); auto& row_state = m_state.get(m_rows[cell.row_index].box); @@ -506,6 +482,34 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons cell_state.offset = row_state.offset.translated(cell_state.border_box_left() + m_columns[cell.column_index].left_offset, cell_state.border_box_top()); } +} + +void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const& available_space) +{ + m_available_space = available_space; + + CSSPixels total_content_height = 0; + + // Determine the number of rows/columns the table requires. + calculate_row_column_grid(box); + + // Compute the minimum width of each column. + compute_table_measures(); + + if (available_space.width.is_intrinsic_sizing_constraint()) { + determine_intrisic_size_of_table_container(available_space); + return; + } + + // Compute the width of the table. + compute_table_width(); + + // Distribute the width of the table among columns. + distribute_width_to_columns(); + + calculate_row_heights(); + position_row_boxes(); + position_cell_boxes(); m_state.get_mutable(context_box()).set_content_height(total_content_height); diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h index ce905f31f6..11f1e739ec 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h @@ -27,6 +27,7 @@ private: void determine_intrisic_size_of_table_container(AvailableSpace const& available_space); void calculate_row_heights(); void position_row_boxes(); + void position_cell_boxes(); CSSPixels m_automatic_content_height { 0 }; -- cgit v1.2.3