@@ -25,6 +25,16 @@ int litehtml::render_item_table::_render(int x, int y, int max_width, const cont
2525
2626 containing_block_context cb_size = calculate_containing_block_context (containing_block_size);
2727
28+ if (cb_size.width_type == containing_block_context::cbc_value_type_auto)
29+ {
30+ max_width -= content_offset_left () + content_offset_right ();
31+ } else
32+ {
33+ max_width -= m_padding.width () + m_borders.width ();
34+ }
35+ if (max_width < 0 ) max_width = 0 ;
36+ max_width = std::min (max_width, cb_size.width );
37+
2838 // Calculate table spacing
2939 int table_width_spacing = 0 ;
3040 if (src_el ()->css ().get_border_collapse () == border_collapse_separate)
@@ -87,7 +97,7 @@ int litehtml::render_item_table::_render(int x, int y, int max_width, const cont
8797 else
8898 {
8999 // calculate minimum content width
90- cell->min_width = cell->el ->render (0 , 0 , 1 , cb_size);
100+ cell->min_width = cell->el ->render (0 , 0 , cell-> el -> content_offset_width () , cb_size);
91101 // calculate maximum content width
92102 cell->max_width = cell->el ->render (0 , 0 , max_width - table_width_spacing, cb_size);
93103 }
@@ -327,8 +337,6 @@ int litehtml::render_item_table::_render(int x, int y, int max_width, const cont
327337 table_height += m_border_spacing_y;
328338 }
329339
330- m_pos.width = table_width;
331-
332340 // Render table captions
333341 // Table border doesn't round the caption, so we have to start caption in the border position
334342 int captions_height = -border_top ();
@@ -370,7 +378,7 @@ int litehtml::render_item_table::_render(int x, int y, int max_width, const cont
370378 m_pos.width = table_width;
371379 m_pos.height = table_height + captions_height;
372380
373- return std::min (table_width, max_table_width) + content_offset_left () + content_offset_right ();
381+ return std::min (table_width, max_table_width) + content_offset_width ();
374382}
375383
376384std::shared_ptr<litehtml::render_item> litehtml::render_item_table::init ()
0 commit comments