Skip to content

Commit f2b5e9d

Browse files
committed
Fixed incorrect table height.
1 parent b187154 commit f2b5e9d

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed

litehtml.sln

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/html_tag.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4421,6 +4421,28 @@ int litehtml::html_tag::render_table(int x, int y, int max_width, bool second_pa
44214421
}
44224422
}
44234423

4424+
// Calculate vertical table spacing
4425+
int table_height_spacing = 0;
4426+
if (m_border_collapse == border_collapse_separate)
4427+
{
4428+
table_height_spacing = m_border_spacing_y * (m_grid->rows_count() + 1);
4429+
}
4430+
else
4431+
{
4432+
table_height_spacing = 0;
4433+
4434+
if (m_grid->rows_count())
4435+
{
4436+
table_height_spacing -= std::min(border_top(), m_grid->row(0).border_top);
4437+
table_height_spacing -= std::min(border_bottom(), m_grid->row(m_grid->rows_count() - 1).border_bottom);
4438+
}
4439+
4440+
for (int row = 1; row < m_grid->rows_count(); row++)
4441+
{
4442+
table_height_spacing -= std::min(m_grid->row(row).border_top, m_grid->row(row - 1).border_bottom);
4443+
}
4444+
}
4445+
44244446

44254447
// calculate block height
44264448
int block_height = 0;
@@ -4451,7 +4473,7 @@ int litehtml::html_tag::render_table(int x, int y, int max_width, bool second_pa
44514473
int extra_row_height = 0;
44524474
int minimum_table_height = std::max(block_height, min_height);
44534475

4454-
m_grid->calc_rows_height(minimum_table_height, m_border_spacing_y);
4476+
m_grid->calc_rows_height(minimum_table_height - table_height_spacing, m_border_spacing_y);
44554477
m_grid->calc_vertical_positions(m_borders, m_border_collapse, m_border_spacing_y);
44564478

44574479
int table_height = 0;

src/table.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ void litehtml::table_grid::finish()
117117

118118
if(cell(col, row)->el && cell(col, row)->colspan <= 1)
119119
{
120-
if(!cell(col, row)->el->get_css_width().is_predefined())
120+
if (!cell(col, row)->el->get_css_width().is_predefined() && m_columns[col].css_width.is_predefined())
121121
{
122122
m_columns[col].css_width = cell(col, row)->el->get_css_width();
123-
break;
124123
}
125124
}
126125
}
@@ -474,7 +473,7 @@ void litehtml::table_grid::calc_rows_height(int blockHeight, int borderSpacingY)
474473
min_table_height += row.height;
475474
}
476475

477-
min_table_height += borderSpacingY * ((int) m_rows.size() + 1);
476+
//min_table_height += borderSpacingY * ((int) m_rows.size() + 1);
478477

479478
if (blockHeight > min_table_height)
480479
{

0 commit comments

Comments
 (0)