1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:37:43 +00:00

LibWeb: Use intrinsic_percentage instead of percentage_{width, height}

Follow the terminology from specification.
This commit is contained in:
Andi Gallo 2023-07-17 00:23:07 +00:00 committed by Andreas Kling
parent 2f7527b0a4
commit 1f3fca996c
2 changed files with 17 additions and 17 deletions

View file

@ -230,13 +230,13 @@ void TableFormattingContext::compute_cell_measures(AvailableSpace const& availab
auto const& computed_values = cell.box->computed_values(); auto const& computed_values = cell.box->computed_values();
if (computed_values.width().is_percentage()) { if (computed_values.width().is_percentage()) {
m_columns[cell.column_index].has_percentage_width = true; m_columns[cell.column_index].has_intrinsic_percentage = true;
m_columns[cell.column_index].percentage_width = max(m_columns[cell.column_index].percentage_width, computed_values.width().percentage().value()); m_columns[cell.column_index].intrinsic_percentage = max(m_columns[cell.column_index].intrinsic_percentage, computed_values.width().percentage().value());
} }
if (computed_values.height().is_percentage()) { if (computed_values.height().is_percentage()) {
m_rows[cell.row_index].has_percentage_height = true; m_rows[cell.row_index].has_intrinsic_percentage = true;
m_rows[cell.row_index].percentage_height = max(m_rows[cell.row_index].percentage_height, computed_values.height().percentage().value()); m_rows[cell.row_index].intrinsic_percentage = max(m_rows[cell.row_index].intrinsic_percentage, computed_values.height().percentage().value());
} }
} }
@ -633,7 +633,7 @@ bool TableFormattingContext::distribute_excess_width_by_intrinsic_percentage(CSS
for (auto const& column : m_columns) { for (auto const& column : m_columns) {
if (column_filter(column)) { if (column_filter(column)) {
found_matching_columns = true; found_matching_columns = true;
total_percentage_width += column.percentage_width; total_percentage_width += column.intrinsic_percentage;
} }
} }
if (!found_matching_columns) { if (!found_matching_columns) {
@ -641,7 +641,7 @@ bool TableFormattingContext::distribute_excess_width_by_intrinsic_percentage(CSS
} }
for (auto& column : m_columns) { for (auto& column : m_columns) {
if (column_filter(column)) { if (column_filter(column)) {
column.used_width += excess_width * column.percentage_width / total_percentage_width; column.used_width += excess_width * column.intrinsic_percentage / total_percentage_width;
} }
} }
return true; return true;
@ -677,8 +677,8 @@ void TableFormattingContext::distribute_width_to_columns()
// - all other columns are assigned their min-content width. // - all other columns are assigned their min-content width.
for (size_t i = 0; i < m_columns.size(); ++i) { for (size_t i = 0; i < m_columns.size(); ++i) {
auto& column = m_columns[i]; auto& column = m_columns[i];
if (column.has_percentage_width) { if (column.has_intrinsic_percentage) {
candidate_widths[i] = max(column.min_size, column.percentage_width / 100 * available_width); candidate_widths[i] = max(column.min_size, column.intrinsic_percentage / 100 * available_width);
} }
} }
@ -718,7 +718,7 @@ void TableFormattingContext::distribute_width_to_columns()
// - all other columns are assigned their max-content width. // - all other columns are assigned their max-content width.
for (size_t i = 0; i < m_columns.size(); ++i) { for (size_t i = 0; i < m_columns.size(); ++i) {
auto& column = m_columns[i]; auto& column = m_columns[i];
if (!column.has_percentage_width) { if (!column.has_intrinsic_percentage) {
candidate_widths[i] = column.max_size; candidate_widths[i] = column.max_size;
} }
} }
@ -753,7 +753,7 @@ void TableFormattingContext::distribute_excess_width_to_columns(CSSPixels availa
if (distribute_excess_width_proportionally_to_max_width( if (distribute_excess_width_proportionally_to_max_width(
excess_width, excess_width,
[](auto const& column) { [](auto const& column) {
return !column.is_constrained && column.has_originating_cells && column.percentage_width == 0 && column.max_size > 0; return !column.is_constrained && column.has_originating_cells && column.intrinsic_percentage == 0 && column.max_size > 0;
})) { })) {
excess_width = available_width - compute_columns_total_used_width(); excess_width = available_width - compute_columns_total_used_width();
} }
@ -765,7 +765,7 @@ void TableFormattingContext::distribute_excess_width_to_columns(CSSPixels availa
// columns allowed to grow by this rule are increased by equal amounts so the total increase adds to the excess width. // columns allowed to grow by this rule are increased by equal amounts so the total increase adds to the excess width.
if (distribute_excess_width_equally(excess_width, if (distribute_excess_width_equally(excess_width,
[](auto const& column) { [](auto const& column) {
return !column.is_constrained && column.has_originating_cells && column.percentage_width == 0; return !column.is_constrained && column.has_originating_cells && column.intrinsic_percentage == 0;
})) { })) {
excess_width = available_width - compute_columns_total_used_width(); excess_width = available_width - compute_columns_total_used_width();
} }
@ -778,7 +778,7 @@ void TableFormattingContext::distribute_excess_width_to_columns(CSSPixels availa
if (distribute_excess_width_proportionally_to_max_width( if (distribute_excess_width_proportionally_to_max_width(
excess_width, excess_width,
[](auto const& column) { [](auto const& column) {
return column.is_constrained && column.percentage_width == 0 && column.max_size > 0; return column.is_constrained && column.intrinsic_percentage == 0 && column.max_size > 0;
})) { })) {
excess_width = available_width - compute_columns_total_used_width(); excess_width = available_width - compute_columns_total_used_width();
} }
@ -789,7 +789,7 @@ void TableFormattingContext::distribute_excess_width_to_columns(CSSPixels availa
// which, due to other rules, must have originating cells), the distributed widths of the columns allowed to grow by this rule are // which, due to other rules, must have originating cells), the distributed widths of the columns allowed to grow by this rule are
// increased in proportion to intrinsic percentage width so the total increase adds to the excess width. // increased in proportion to intrinsic percentage width so the total increase adds to the excess width.
if (distribute_excess_width_by_intrinsic_percentage(excess_width, [](auto const& column) { if (distribute_excess_width_by_intrinsic_percentage(excess_width, [](auto const& column) {
return column.percentage_width > 0; return column.intrinsic_percentage > 0;
})) { })) {
excess_width = available_width - compute_columns_total_used_width(); excess_width = available_width - compute_columns_total_used_width();
} }

View file

@ -77,8 +77,8 @@ private:
CSSPixels min_size { 0 }; CSSPixels min_size { 0 };
CSSPixels max_size { 0 }; CSSPixels max_size { 0 };
CSSPixels used_width { 0 }; CSSPixels used_width { 0 };
bool has_percentage_width { false }; bool has_intrinsic_percentage { false };
double percentage_width { 0 }; double intrinsic_percentage { 0 };
// Store whether the column is constrained: https://www.w3.org/TR/css-tables-3/#constrainedness // Store whether the column is constrained: https://www.w3.org/TR/css-tables-3/#constrainedness
bool is_constrained { false }; bool is_constrained { false };
// Store whether the column has originating cells, defined in https://www.w3.org/TR/css-tables-3/#terminology. // Store whether the column has originating cells, defined in https://www.w3.org/TR/css-tables-3/#terminology.
@ -93,8 +93,8 @@ private:
CSSPixels baseline { 0 }; CSSPixels baseline { 0 };
CSSPixels min_size { 0 }; CSSPixels min_size { 0 };
CSSPixels max_size { 0 }; CSSPixels max_size { 0 };
bool has_percentage_height { false }; bool has_intrinsic_percentage { false };
double percentage_height { 0 }; double intrinsic_percentage { 0 };
// Store whether the row is constrained: https://www.w3.org/TR/css-tables-3/#constrainedness // Store whether the row is constrained: https://www.w3.org/TR/css-tables-3/#constrainedness
bool is_constrained { false }; bool is_constrained { false };
}; };