mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
LibWeb: Use table_box()
to get root box in TFC
Introduce `table_box()` function that returns table formatting context root box casted to `TableBox` similar to how it's done in other formatting contexts like `root()` in BFC and `flex_container` in FFC. And replace `context_box()` calls in TFC with calls to `table_box()`.
This commit is contained in:
parent
f26eed9633
commit
77a2b151ea
2 changed files with 11 additions and 11 deletions
|
@ -206,12 +206,11 @@ void TableFormattingContext::compute_table_measures()
|
||||||
|
|
||||||
void TableFormattingContext::compute_table_width()
|
void TableFormattingContext::compute_table_width()
|
||||||
{
|
{
|
||||||
auto const& table_box = context_box();
|
auto& table_box_state = m_state.get_mutable(table_box());
|
||||||
auto& table_box_state = m_state.get_mutable(table_box);
|
|
||||||
|
|
||||||
auto& computed_values = table_box.computed_values();
|
auto& computed_values = table_box().computed_values();
|
||||||
|
|
||||||
CSSPixels width_of_table_containing_block = m_state.get(*table_box.containing_block()).content_width();
|
CSSPixels width_of_table_containing_block = m_state.get(*table_box().containing_block()).content_width();
|
||||||
|
|
||||||
// The row/column-grid width minimum (GRIDMIN) width is the sum of the min-content width
|
// The row/column-grid width minimum (GRIDMIN) width is the sum of the min-content width
|
||||||
// of all the columns plus cell spacing or borders.
|
// of all the columns plus cell spacing or borders.
|
||||||
|
@ -230,7 +229,7 @@ void TableFormattingContext::compute_table_width()
|
||||||
// The used min-width of a table is the greater of the resolved min-width, CAPMIN, and GRIDMIN.
|
// The used min-width of a table is the greater of the resolved min-width, CAPMIN, and GRIDMIN.
|
||||||
auto used_min_width = grid_min;
|
auto used_min_width = grid_min;
|
||||||
if (!computed_values.min_width().is_auto()) {
|
if (!computed_values.min_width().is_auto()) {
|
||||||
used_min_width = max(used_min_width, computed_values.min_width().resolved(table_box, CSS::Length::make_px(width_of_table_containing_block)).to_px(table_box));
|
used_min_width = max(used_min_width, computed_values.min_width().resolved(table_box(), CSS::Length::make_px(width_of_table_containing_block)).to_px(table_box()));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixels used_width;
|
CSSPixels used_width;
|
||||||
|
@ -243,7 +242,7 @@ void TableFormattingContext::compute_table_width()
|
||||||
// If the table-root’s width property has a computed value (resolving to
|
// If the table-root’s width property has a computed value (resolving to
|
||||||
// resolved-table-width) other than auto, the used width is the greater
|
// resolved-table-width) other than auto, the used width is the greater
|
||||||
// of resolved-table-width, and the used min-width of the table.
|
// of resolved-table-width, and the used min-width of the table.
|
||||||
CSSPixels resolved_table_width = computed_values.width().resolved(table_box, CSS::Length::make_px(width_of_table_containing_block)).to_px(table_box);
|
CSSPixels resolved_table_width = computed_values.width().resolved(table_box(), CSS::Length::make_px(width_of_table_containing_block)).to_px(table_box());
|
||||||
used_width = max(resolved_table_width, used_min_width);
|
used_width = max(resolved_table_width, used_min_width);
|
||||||
table_box_state.set_content_width(used_width);
|
table_box_state.set_content_width(used_width);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +252,7 @@ void TableFormattingContext::distribute_width_to_columns()
|
||||||
{
|
{
|
||||||
// Implements https://www.w3.org/TR/css-tables-3/#width-distribution-algorithm
|
// Implements https://www.w3.org/TR/css-tables-3/#width-distribution-algorithm
|
||||||
|
|
||||||
CSSPixels available_width = m_state.get(context_box()).content_width();
|
CSSPixels available_width = m_state.get(table_box()).content_width();
|
||||||
|
|
||||||
auto columns_total_used_width = [&]() {
|
auto columns_total_used_width = [&]() {
|
||||||
CSSPixels total_used_width = 0;
|
CSSPixels total_used_width = 0;
|
||||||
|
@ -346,8 +345,7 @@ void TableFormattingContext::distribute_width_to_columns()
|
||||||
|
|
||||||
void TableFormattingContext::determine_intrisic_size_of_table_container(AvailableSpace const& available_space)
|
void TableFormattingContext::determine_intrisic_size_of_table_container(AvailableSpace const& available_space)
|
||||||
{
|
{
|
||||||
auto const& table_box = context_box();
|
auto& table_box_state = m_state.get_mutable(table_box());
|
||||||
auto& table_box_state = m_state.get_mutable(table_box);
|
|
||||||
|
|
||||||
if (available_space.width.is_min_content()) {
|
if (available_space.width.is_min_content()) {
|
||||||
// The min-content width of a table is the width required to fit all of its columns min-content widths and its undistributable spaces.
|
// The min-content width of a table is the width required to fit all of its columns min-content widths and its undistributable spaces.
|
||||||
|
@ -426,7 +424,7 @@ void TableFormattingContext::position_row_boxes()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPixels row_group_top_offset = 0.0f;
|
CSSPixels row_group_top_offset = 0.0f;
|
||||||
context_box().for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) {
|
table_box().for_each_child_of_type<TableRowGroupBox>([&](auto& row_group_box) {
|
||||||
CSSPixels row_group_height = 0.0f;
|
CSSPixels row_group_height = 0.0f;
|
||||||
CSSPixels row_group_width = 0.0f;
|
CSSPixels row_group_width = 0.0f;
|
||||||
|
|
||||||
|
@ -511,7 +509,7 @@ void TableFormattingContext::run(Box const& box, LayoutMode, AvailableSpace cons
|
||||||
position_row_boxes();
|
position_row_boxes();
|
||||||
position_cell_boxes();
|
position_cell_boxes();
|
||||||
|
|
||||||
m_state.get_mutable(context_box()).set_content_height(total_content_height);
|
m_state.get_mutable(table_box()).set_content_height(total_content_height);
|
||||||
|
|
||||||
// FIXME: This is a total hack, we should respect the 'height' property.
|
// FIXME: This is a total hack, we should respect the 'height' property.
|
||||||
m_automatic_content_height = total_content_height;
|
m_automatic_content_height = total_content_height;
|
||||||
|
|
|
@ -19,6 +19,8 @@ public:
|
||||||
virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
|
virtual void run(Box const&, LayoutMode, AvailableSpace const&) override;
|
||||||
virtual CSSPixels automatic_content_height() const override;
|
virtual CSSPixels automatic_content_height() const override;
|
||||||
|
|
||||||
|
TableBox const& table_box() const { return static_cast<TableBox const&>(context_box()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void calculate_row_column_grid(Box const&);
|
void calculate_row_column_grid(Box const&);
|
||||||
void compute_table_measures();
|
void compute_table_measures();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue