diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-05-03 14:40:39 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-03 15:03:56 +0200 |
commit | 4d971b5bc59f56e7492a15b0aa08f73537293e6a (patch) | |
tree | 39795c54abce0f5cab10ea9580f947c6ca455fe7 /Userland | |
parent | da768e7c460934b78a753067391509dfa5f31863 (diff) | |
download | serenity-4d971b5bc59f56e7492a15b0aa08f73537293e6a.zip |
LibWeb: Use appropriate containing block width to get width of table
This solves the issue that previously width table-wrapper containing
block were used in the places were containing block of table-root
should be used.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp index b8df1aff87..8990f578d6 100644 --- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp @@ -212,9 +212,11 @@ void TableFormattingContext::compute_table_width() auto& computed_values = table_box().computed_values(); + CSSPixels width_of_table_containing_block = m_state.get(*table_box().containing_block()).content_width(); + // Percentages on 'width' and 'height' on the table are relative to the table wrapper box's containing block, // not the table wrapper box itself. - CSSPixels width_of_table_containing_block = m_state.get(*table_wrapper().containing_block()).content_width(); + CSSPixels width_of_table_wrapper_containing_block = m_state.get(*table_wrapper().containing_block()).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. @@ -233,7 +235,7 @@ void TableFormattingContext::compute_table_width() // The used min-width of a table is the greater of the resolved min-width, CAPMIN, and GRIDMIN. auto used_min_width = grid_min; 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_wrapper_containing_block)).to_px(table_box())); } CSSPixels used_width; @@ -245,10 +247,10 @@ void TableFormattingContext::compute_table_width() // 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 // 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_wrapper_containing_block)).to_px(table_box()); used_width = max(resolved_table_width, used_min_width); if (!computed_values.max_width().is_none()) - used_width = min(used_width, computed_values.max_width().resolved(table_box(), CSS::Length::make_px(width_of_table_containing_block)).to_px(table_box())); + used_width = min(used_width, computed_values.max_width().resolved(table_box(), CSS::Length::make_px(width_of_table_wrapper_containing_block)).to_px(table_box())); } // The assignable table width is the used width of the table minus the total horizontal border spacing (if any). |