diff options
author | Richard Wilson <rjw@netsurf-browser.org> | 2005-03-22 00:10:42 +0000 |
---|---|---|
committer | Richard Wilson <rjw@netsurf-browser.org> | 2005-03-22 00:10:42 +0000 |
commit | b832e05f034ccca6d2bcaa058ca0d9d6214bd22b (patch) | |
tree | 472ef7907956bd00501387a6588a51548a0d4793 /render | |
parent | 28d9260ca463abe3992fd674cc127b6b2baa04aa (diff) | |
download | netsurf-b832e05f034ccca6d2bcaa058ca0d9d6214bd22b.tar.gz netsurf-b832e05f034ccca6d2bcaa058ca0d9d6214bd22b.tar.bz2 |
[project @ 2005-03-22 00:10:42 by rjw]
Experimental cellpadding support
svn path=/import/netsurf/; revision=1569
Diffstat (limited to 'render')
-rw-r--r-- | render/box.c | 15 | ||||
-rw-r--r-- | render/layout.c | 13 |
2 files changed, 26 insertions, 2 deletions
diff --git a/render/box.c b/render/box.c index 2eb928d46..3cc8d805f 100644 --- a/render/box.c +++ b/render/box.c @@ -936,6 +936,21 @@ struct css_style * box_get_style(struct content *c, } } } + style->html_style.cellpadding.type = CSS_CELLPADDING_VALUE; + if ((s = (char *) xmlGetProp(n, + (const xmlChar *) "cellpadding"))) { + if (!strrchr(s, '%')) { /* % not implemented */ + int value = atoi(s); + if (0 <= value) { + style->html_style.cellpadding.value = value; + /* todo: match <td> and <th> rules and don't set if they are */ + for (i = 0; i < 4; i++) + style->padding[i].override_cellpadding = false; + } + } + } else { + style->html_style.cellpadding.value = 1; + } } if ((s = (char *) xmlGetProp(n, (const xmlChar *) "style")) != NULL) { diff --git a/render/layout.c b/render/layout.c index 48ea15ba8..96a61e31d 100644 --- a/render/layout.c +++ b/render/layout.c @@ -1216,7 +1216,7 @@ bool layout_table(struct box *table, int available_width, int *excess_y; int table_width, min_width = 0, max_width = 0; int required_width = 0; - int x; + int x, cp; int table_height = 0; int *xs; /* array of column x positions */ int auto_width; @@ -1264,6 +1264,11 @@ bool layout_table(struct box *table, int available_width, layout_find_dimensions(available_width, c->style, 0, c->padding, c->border); + if (c->style->html_style.cellpadding.type == CSS_CELLPADDING_VALUE) + for (cp = 0; cp < 4; cp++) + if (!c->style->padding[cp].override_cellpadding) + c->padding[cp] = + c->style->html_style.cellpadding.value; if (c->style->overflow == CSS_OVERFLOW_SCROLL || c->style->overflow == @@ -1663,7 +1668,11 @@ bool calculate_widths(struct box *box) /* add margins, border, padding to min, max widths */ if (style) { for (side = 1; side != 5; side += 2) { /* RIGHT, LEFT */ - if (style->padding[side].padding == CSS_PADDING_LENGTH) + if ((box->type == BOX_TABLE_CELL) && + (style->html_style.cellpadding.type == CSS_CELLPADDING_VALUE) && + (!style->padding[side].override_cellpadding)) + extra_fixed += style->html_style.cellpadding.value; + else if (style->padding[side].padding == CSS_PADDING_LENGTH) extra_fixed += (int)css_len2px(&style->padding[side].value.length, style); else if (style->padding[side].padding == CSS_PADDING_PERCENT) |