Merge pull request #197 from stasoid/master

Fix table issues
This commit is contained in:
Yuri Kobets 2022-03-13 22:59:52 +03:00 committed by GitHub
commit 9898cc633b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 2 deletions

View File

@ -292,7 +292,7 @@ blockquote {
margin-top: 1em;
margin-bottom: 1em;
margin-left: 40px;
margin-left: 40px;
margin-right: 40px;
}
/*********** FORM ELEMENTS ************/

View File

@ -161,7 +161,7 @@ void litehtml::element::get_redraw_box(litehtml::position& pos, int x /*= 0*/, i
int litehtml::element::calc_width(int defVal) const
{
css_length w = get_css_width();
if(w.is_predefined())
if(w.is_predefined() || get_display() == display_table_cell)
{
return defVal;
}

View File

@ -375,6 +375,34 @@ int litehtml::table_grid::calc_table_width(int block_width, bool is_auto, int& m
}
cur_width += m_columns[col].width;
}
// If the table is still too wide shrink columns with % widths
if(cur_width > block_width)
{
while(true)
{
bool shrunk = false;
for(int col = 0; col < m_cols_count; col++)
{
if(!m_columns[col].css_width.is_predefined() && m_columns[col].css_width.units() == css_units_percentage)
{
if(m_columns[col].width > m_columns[col].min_width)
{
m_columns[col].width--;
cur_width--;
shrunk = true;
if(cur_width == block_width)
{
break;
}
}
}
}
if(cur_width == block_width || !shrunk)
{
break;
}
}
}
}
return cur_width;
}