summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAliaksandr Kalenik <kalenik.aliaksandr@gmail.com>2023-01-20 00:59:43 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-20 18:04:17 +0100
commit87f0e835eb7fee2af95a365f29113f315571a755 (patch)
treefc42ff7111902395e2c9fc77b707da1ef4885703 /Userland
parentaddfa4ed586a4ba033b43cb0d7f57a8dd9600751 (diff)
downloadserenity-87f0e835eb7fee2af95a365f29113f315571a755.zip
LibWeb: Improve auto height calculation for tables
Change `compute_auto_height_for_block_level_element` to use max height (`m_automatic_content_height` produced from TFC) for tables with auto height which is more correct behaviour than treating them like block containers.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp3
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Layout/TableFormattingContext.h2
3 files changed, 8 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index 59d11806cb..dd0c2efde5 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -404,6 +404,9 @@ CSSPixels BlockFormattingContext::compute_auto_height_for_block_level_element(Bo
// max-content size.
return calculate_max_content_height(box, available_space.width);
}
+ if (display.is_table_inside()) {
+ return calculate_max_content_height(box, available_space.height);
+ }
// https://www.w3.org/TR/CSS22/visudet.html#normal-block
// 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
index d0d7ae51e9..aa488751de 100644
--- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp
@@ -414,7 +414,7 @@ void TableFormattingContext::calculate_row_heights(LayoutMode layout_mode)
}
}
-void TableFormattingContext::position_row_boxes()
+void TableFormattingContext::position_row_boxes(CSSPixels& total_content_height)
{
auto const& table_state = m_state.get(table_box());
@@ -456,6 +456,8 @@ void TableFormattingContext::position_row_boxes()
row_group_top_offset += row_group_height;
});
+
+ total_content_height = max(row_top_offset, row_group_top_offset) - table_state.border_top - table_state.padding_top;
}
void TableFormattingContext::position_cell_boxes()
@@ -520,7 +522,7 @@ void TableFormattingContext::run(Box const& box, LayoutMode layout_mode, Availab
distribute_width_to_columns();
calculate_row_heights(layout_mode);
- position_row_boxes();
+ position_row_boxes(total_content_height);
position_cell_boxes();
m_state.get_mutable(table_box()).set_content_height(total_content_height);
diff --git a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h
index 3776ed82c0..96122e7abd 100644
--- a/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h
+++ b/Userland/Libraries/LibWeb/Layout/TableFormattingContext.h
@@ -33,7 +33,7 @@ private:
void distribute_width_to_columns();
void determine_intrisic_size_of_table_container(AvailableSpace const& available_space);
void calculate_row_heights(LayoutMode layout_mode);
- void position_row_boxes();
+ void position_row_boxes(CSSPixels&);
void position_cell_boxes();
CSSPixels m_automatic_content_height { 0 };