summaryrefslogtreecommitdiff
path: root/render/layout.c
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2003-09-12 14:37:26 +0000
committerJames Bursa <james@netsurf-browser.org>2003-09-12 14:37:26 +0000
commit226f937199955c45c3e3f261b294d3701c29f5e6 (patch)
tree9b650f5c475547715014d3ff390473669b95bbf5 /render/layout.c
parent4866b512b8f74f4e304732aadfdb49dc82143b31 (diff)
downloadnetsurf-226f937199955c45c3e3f261b294d3701c29f5e6.tar.gz
netsurf-226f937199955c45c3e3f261b294d3701c29f5e6.tar.bz2
[project @ 2003-09-12 14:37:26 by bursa]
Fix percentage width columns. svn path=/import/netsurf/; revision=287
Diffstat (limited to 'render/layout.c')
-rw-r--r--render/layout.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/render/layout.c b/render/layout.c
index e6974c047..00197185f 100644
--- a/render/layout.c
+++ b/render/layout.c
@@ -582,7 +582,7 @@ void layout_table(struct box * table, unsigned long width, struct box * cont,
unsigned long cx, unsigned long cy)
{
unsigned int columns = table->columns; /* total columns */
- unsigned long table_width, max_width = 0;
+ unsigned long table_width, min_width = 0, max_width = 0;
unsigned long x;
unsigned long table_height = 0;
unsigned long *xs; /* array of column x positions */
@@ -625,22 +625,24 @@ void layout_table(struct box * table, unsigned long width, struct box * cont,
LOG(("width %lu, min %lu, max %lu", table_width, table->min_width, table->max_width));
- /* percentage width columns give an upper bound if possible */
for (i = 0; i < table->columns; i++) {
if (col[i].type == COLUMN_WIDTH_PERCENT) {
- col[i].max = width * col[i].width / 100;
- if (col[i].max < col[i].min)
- col[i].max = col[i].min;
+ unsigned long width = table_width * col[i].width / 100;
+ if (width < col[i].min)
+ width = col[i].min;
+ col[i].min = col[i].width = col[i].max = width;
+ col[i].type = COLUMN_WIDTH_FIXED;
}
+ min_width += col[i].min;
max_width += col[i].max;
}
- if (table_width <= table->min_width) {
+ if (table_width <= min_width) {
/* not enough space: minimise column widths */
for (i = 0; i < table->columns; i++) {
col[i].width = col[i].min;
}
- table_width = table->min_width;
+ table_width = min_width;
} else if (max_width <= table_width) {
/* more space than maximum width */
if (table->style->width.width == CSS_WIDTH_AUTO) {
@@ -668,8 +670,8 @@ void layout_table(struct box * table, unsigned long width, struct box * cont,
}
} else {
/* space between min and max: fill it exactly */
- float scale = (float) (table_width - table->min_width) /
- (float) (max_width - table->min_width);
+ float scale = (float) (table_width - min_width) /
+ (float) (max_width - min_width);
/* fprintf(stderr, "filling, scale %f\n", scale); */
for (i = 0; i < table->columns; i++) {
col[i].width = col[i].min +