From 80013c7a7194c47b11f6f8dddc416367df3f134d Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 8 Jul 2003 20:54:19 +0000 Subject: [project @ 2003-07-08 20:54:19 by bursa] Table column width improvements. svn path=/import/netsurf/; revision=212 --- render/layout.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/render/layout.c b/render/layout.c index db26dadbf..14e9258f2 100644 --- a/render/layout.c +++ b/render/layout.c @@ -646,9 +646,19 @@ void layout_table(struct box * table, unsigned long width, struct box * cont, table_width = max_width; } else { /* for fixed-width tables, distribute the extra space too */ - unsigned long extra = (table_width - max_width) / table->columns; - for (i = 0; i < table->columns; i++) { - table->col[i].width = table->col[i].max + extra; + unsigned int flexible_columns = 0; + for (i = 0; i != table->columns; i++) + if (table->col[i].type != COLUMN_WIDTH_FIXED) + flexible_columns++; + if (flexible_columns == 0) { + unsigned long extra = (table_width - max_width) / table->columns; + for (i = 0; i != table->columns; i++) + table->col[i].width = table->col[i].max + extra; + } else { + unsigned long extra = (table_width - max_width) / flexible_columns; + for (i = 0; i != table->columns; i++) + if (table->col[i].type != COLUMN_WIDTH_FIXED) + table->col[i].width = table->col[i].max + extra; } } } else { @@ -914,7 +924,7 @@ void calculate_table_widths(struct box *table) min += col[i + j].min; max += col[i + j].max; } - + /* use specified width if colspan == 1 */ if (col[i].type != COLUMN_WIDTH_FIXED && cell->style->width.width == CSS_WIDTH_LENGTH && @@ -928,6 +938,7 @@ void calculate_table_widths(struct box *table) else /* specified width not big enough => use min */ col[i].width = col[i].max = max = min; + continue; } else if (col[i].type == COLUMN_WIDTH_UNKNOWN) { -- cgit v1.2.3