1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibWeb: Convert width/height and min-/max- versions to LengthPercentage

A lot of this is quite ugly, but it should only be so until I remove
Length::Type::Percentage entirely. (Which should happen later in this
PR, otherwise, yell at me!) For now, a lot of things have to be
resolved twice, first from a LengthPercentage to a Length, and then
from a Length to a pixel one.
This commit is contained in:
Sam Atkins 2022-01-19 16:19:43 +00:00 committed by Andreas Kling
parent cb0cce5cdc
commit dc681913e8
12 changed files with 276 additions and 194 deletions

View file

@ -52,7 +52,7 @@ void TableFormattingContext::run(Box& box, LayoutMode)
content_height += row.height();
});
if (row_group_box.computed_values().width().is_auto())
if (row_group_box.computed_values().width().is_length() && row_group_box.computed_values().width().length().is_auto())
row_group_box.set_width(content_width);
row_group_box.set_height(content_height);
@ -61,7 +61,7 @@ void TableFormattingContext::run(Box& box, LayoutMode)
total_content_width = max(total_content_width, row_group_box.width());
});
if (box.computed_values().width().is_auto())
if (box.computed_values().width().is_length() && box.computed_values().width().length().is_auto())
box.set_width(total_content_width);
// FIXME: This is a total hack, we should respect the 'height' property.
@ -72,7 +72,7 @@ void TableFormattingContext::calculate_column_widths(Box& row, Vector<float>& co
{
size_t column_index = 0;
auto* table = row.first_ancestor_of_type<TableBox>();
bool use_auto_layout = !table || table->computed_values().width().is_undefined_or_auto();
bool use_auto_layout = !table || (table->computed_values().width().is_length() && table->computed_values().width().length().is_undefined_or_auto());
row.for_each_child_of_type<TableCellBox>([&](auto& cell) {
compute_width(cell);
if (use_auto_layout) {
@ -91,7 +91,7 @@ void TableFormattingContext::layout_row(Box& row, Vector<float>& column_widths)
float tallest_cell_height = 0;
float content_width = 0;
auto* table = row.first_ancestor_of_type<TableBox>();
bool use_auto_layout = !table || table->computed_values().width().is_undefined_or_auto();
bool use_auto_layout = !table || (table->computed_values().width().is_length() && table->computed_values().width().length().is_undefined_or_auto());
row.for_each_child_of_type<TableCellBox>([&](auto& cell) {
cell.set_offset(row.effective_offset().translated(content_width, 0));