mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:28:12 +00:00
LibWeb: Add accessors for UsedValues::computed_{width,height}
This is preparation for doing some more work when assigning to these values.
This commit is contained in:
parent
c12c9eed38
commit
ed8930fff5
11 changed files with 155 additions and 137 deletions
|
@ -28,7 +28,7 @@ void TableFormattingContext::run(Box const& box, LayoutMode)
|
|||
auto& box_state = m_state.get_mutable(box);
|
||||
|
||||
compute_width(box);
|
||||
auto table_width = CSS::Length::make_px(box_state.content_width);
|
||||
auto table_width = CSS::Length::make_px(box_state.content_width());
|
||||
auto table_width_is_auto = box.computed_values().width().is_auto();
|
||||
|
||||
float total_content_width = 0;
|
||||
|
@ -47,8 +47,8 @@ void TableFormattingContext::run(Box const& box, LayoutMode)
|
|||
box.for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) {
|
||||
auto& row_group_box_state = m_state.get_mutable(row_group_box);
|
||||
|
||||
float remaining_for_max = box_state.content_width;
|
||||
float remaining_for_min = box_state.content_width;
|
||||
float remaining_for_max = box_state.content_width();
|
||||
float remaining_for_min = box_state.content_width();
|
||||
for (auto& column_width : column_widths) {
|
||||
remaining_for_max -= column_width.max;
|
||||
remaining_for_min -= column_width.min;
|
||||
|
@ -90,24 +90,24 @@ void TableFormattingContext::run(Box const& box, LayoutMode)
|
|||
auto& row_state = m_state.get_mutable(row);
|
||||
row_state.offset = { 0, content_height };
|
||||
layout_row(row, column_widths);
|
||||
content_width = max(content_width, row_state.content_width);
|
||||
content_height += row_state.content_height;
|
||||
content_width = max(content_width, row_state.content_width());
|
||||
content_height += row_state.content_height();
|
||||
});
|
||||
|
||||
if (row_group_box.computed_values().width().is_auto())
|
||||
row_group_box_state.content_width = content_width;
|
||||
row_group_box_state.content_height = content_height;
|
||||
row_group_box_state.set_content_width(content_width);
|
||||
row_group_box_state.set_content_height(content_height);
|
||||
|
||||
row_group_box_state.offset = { 0, total_content_height };
|
||||
total_content_height += content_height;
|
||||
total_content_width = max(total_content_width, row_group_box_state.content_width);
|
||||
total_content_width = max(total_content_width, row_group_box_state.content_width());
|
||||
});
|
||||
|
||||
if (table_width_is_auto)
|
||||
box_state.content_width = total_content_width;
|
||||
box_state.set_content_width(total_content_width);
|
||||
|
||||
// FIXME: This is a total hack, we should respect the 'height' property.
|
||||
box_state.content_height = total_content_height;
|
||||
box_state.set_content_height(total_content_height);
|
||||
}
|
||||
|
||||
void TableFormattingContext::calculate_column_widths(Box const& row, CSS::Length const& table_width, Vector<ColumnWidth>& column_widths)
|
||||
|
@ -121,7 +121,7 @@ void TableFormattingContext::calculate_column_widths(Box const& row, CSS::Length
|
|||
|
||||
if (specified_width.is_auto()) {
|
||||
auto width = calculate_max_content_width(cell);
|
||||
cell_state.content_width = width;
|
||||
cell_state.set_content_width(width);
|
||||
} else {
|
||||
compute_width(cell, LayoutMode::Normal);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ void TableFormattingContext::layout_row(Box const& row, Vector<ColumnWidth>& col
|
|||
float span_width = 0;
|
||||
for (size_t i = 0; i < cell.colspan(); ++i)
|
||||
span_width += column_widths[column_index++].used;
|
||||
cell_state.content_width = span_width - cell_state.border_box_left() - cell_state.border_box_right();
|
||||
cell_state.set_content_width(span_width - cell_state.border_box_left() - cell_state.border_box_right());
|
||||
|
||||
BlockFormattingContext::compute_height(cell, m_state);
|
||||
cell_state.offset = row_state.offset.translated(cell_state.border_box_left() + content_width, cell_state.border_box_top());
|
||||
|
@ -194,18 +194,18 @@ void TableFormattingContext::layout_row(Box const& row, Vector<ColumnWidth>& col
|
|||
tallest_cell_height = max(tallest_cell_height, cell_state.border_box_height());
|
||||
});
|
||||
|
||||
row_state.content_height = tallest_cell_height;
|
||||
row_state.set_content_height(tallest_cell_height);
|
||||
|
||||
row.for_each_child_of_type<TableCellBox>([&](auto& cell) {
|
||||
auto& cell_state = m_state.get_mutable(cell);
|
||||
cell_state.content_height = tallest_cell_height - cell_state.border_box_top() - cell_state.border_box_bottom();
|
||||
cell_state.set_content_height(tallest_cell_height - cell_state.border_box_top() - cell_state.border_box_bottom());
|
||||
});
|
||||
|
||||
if (use_auto_layout) {
|
||||
row_state.content_width = content_width;
|
||||
row_state.set_content_width(content_width);
|
||||
} else {
|
||||
auto& table_state = m_state.get_mutable(*table);
|
||||
row_state.content_width = table_state.content_width;
|
||||
row_state.set_content_width(table_state.content_width());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue