From f7be887580a9dc7645df1e04f676a0dd4af48938 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 5 Mar 2008 08:09:06 +0000 Subject: Centered tables are a special case. svn path=/trunk/netsurf/; revision=3880 --- render/box_construct.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'render/box_construct.c') diff --git a/render/box_construct.c b/render/box_construct.c index 2cb264afd..5a3f90599 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -1199,6 +1199,21 @@ struct css_style * box_get_style(struct content *c, markup_track->align = ALIGN_NONE; } } + /* Centered tables are a special case. The align attribute only + * affects the current element (table) and overrides any existing + * HTML alignment rule. Tables aligned to left or right are floated + * by the default CSS file. */ + if (!author->margin[LEFT] && !author->margin[RIGHT] && + strcmp((const char *) n->name, "table") == 0) { + if ((s = (char *) xmlGetProp(n, + (const xmlChar *) "align"))) { + if (strcasecmp(s, "center") == 0) { + style->margin[LEFT].margin = CSS_MARGIN_AUTO; + style->margin[RIGHT].margin = CSS_MARGIN_AUTO; + } + xmlFree(s); + } + } box_solve_display(style, !n->parent); @@ -1215,7 +1230,6 @@ struct css_style * box_get_style(struct content *c, else if (strcmp((const char *) n->name, "div") == 0 || strcmp((const char *) n->name, "col") == 0 || strcmp((const char *) n->name, "colgroup") == 0 || - strcmp((const char *) n->name, "table") == 0 || strcmp((const char *) n->name, "tbody") == 0 || strcmp((const char *) n->name, "td") == 0 || strcmp((const char *) n->name, "tfoot") == 0 || -- cgit v1.2.3