diff options
author | James Bursa <james@netsurf-browser.org> | 2003-09-14 20:32:05 +0000 |
---|---|---|
committer | James Bursa <james@netsurf-browser.org> | 2003-09-14 20:32:05 +0000 |
commit | eeb805497da31fa26be6147d468ac1f1a729b636 (patch) | |
tree | 251cf38471ae3556d1caccc289dc2102ed3c7c8e /render | |
parent | 22cea706c5c2b9c2673f0dd3516c76d1fe5a513e (diff) | |
download | netsurf-eeb805497da31fa26be6147d468ac1f1a729b636.tar.gz netsurf-eeb805497da31fa26be6147d468ac1f1a729b636.tar.bz2 |
[project @ 2003-09-14 20:32:05 by bursa]
Percentage column changes; fix calculate_inline_container_widths.
svn path=/import/netsurf/; revision=291
Diffstat (limited to 'render')
-rw-r--r-- | render/layout.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/render/layout.c b/render/layout.c index 1f7901e8d..3dbc5e464 100644 --- a/render/layout.c +++ b/render/layout.c @@ -585,7 +585,7 @@ void layout_table(struct box * table, unsigned long width, struct box * cont, unsigned int i; unsigned int *row_span, *excess_y; unsigned long table_width, min_width = 0, max_width = 0; - unsigned long fixed_width = 0, total_percent = 0, auto_min_width = 0; + unsigned long required_width = 0; unsigned long x, x0, x1; unsigned long table_height = 0; unsigned long *xs; /* array of column x positions */ @@ -627,14 +627,15 @@ void layout_table(struct box * table, unsigned long width, struct box * cont, for (i = 0; i != columns; i++) { if (col[i].type == COLUMN_WIDTH_FIXED) - fixed_width += col[i].width; - else if (col[i].type == COLUMN_WIDTH_PERCENT) - total_percent += col[i].width; - else - auto_min_width += col[i].min; + required_width += col[i].width; + else if (col[i].type == COLUMN_WIDTH_PERCENT) { + unsigned long width = col[i].width * table_width / 100; + required_width += col[i].min < width ? width : col[i].min; + } else + required_width += col[i].min; } - if (table_width < fixed_width + total_percent * table_width / 100 + auto_min_width) { + if (table_width < required_width) { /* table narrower than required width for columns: * treat percentage widths as maximums */ for (i = 0; i != columns; i++) { @@ -879,6 +880,7 @@ void calculate_inline_container_widths(struct box *box) struct box *child; unsigned long min = 0, max = 0, width; char *word, *space; + int i, j; for (child = box->children; child != 0; child = child->next) { switch (child->type) { @@ -900,17 +902,14 @@ void calculate_inline_container_widths(struct box *box) /* TODO: add spaces */ /* min = widest word */ - for (word = child->text, - space = strchr(child->text, ' '); - space != 0; - word = space + 1, - space = strchr(word, ' ')) { - width = font_width(child->font, word, - (unsigned int) (space - word - 1)); + i = 0; + do { + for (j = i; j != child->length && child->text[j] != ' '; j++) + ; + width = font_width(child->font, child->text + i, j - i); if (min < width) min = width; - } - width = font_width(child->font, word, strlen(word)); - if (min < width) min = width; + i = j + 1; + } while (j != child->length); } else if (child->gadget) { child->width = gadget_width(child->gadget); @@ -940,6 +939,7 @@ void calculate_inline_container_widths(struct box *box) } } + assert(min <= max); box->min_width = min; box->max_width = max; } |