summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2008-02-28 20:36:09 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2008-02-28 20:36:09 +0000
commitf752aca0d4c0c47b849ad12ec18f85aa9898a3fe (patch)
treeaf88da5d01d6ac202cd8cb201dbe59ac1b75b0e8 /render
parent85bb19c93dbcaa9b1410c2cc93ee82ec89433576 (diff)
downloadnetsurf-f752aca0d4c0c47b849ad12ec18f85aa9898a3fe.tar.gz
netsurf-f752aca0d4c0c47b849ad12ec18f85aa9898a3fe.tar.bz2
Fix align attributes on TABLE etc being overridden in the table's cells by the default alignment of cells with no align attribute.
svn path=/trunk/netsurf/; revision=3873
Diffstat (limited to 'render')
-rw-r--r--render/box_construct.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/render/box_construct.c b/render/box_construct.c
index 3790d70d3..2cb264afd 100644
--- a/render/box_construct.c
+++ b/render/box_construct.c
@@ -101,6 +101,8 @@ struct markup_track {
bool cell_padding;
long padding_width;
+
+ bool table;
};
static bool convert_xml_to_box(xmlNode *n, struct content *content,
@@ -822,7 +824,8 @@ struct css_style * box_get_style(struct content *c,
url_func_result res;
colour border_color = 0x888888; /* mid-grey default for tables */
- /* if not in a table, switch off cellpadding and cell borders */
+ /* if not in a table, switch off cellpadding and cell borders
+ * and record that we're not in a table */
if (strcmp((const char *) n->name, "thead") != 0 &&
strcmp((const char *) n->name, "tbody") != 0 &&
strcmp((const char *) n->name, "tfoot") != 0 &&
@@ -833,6 +836,7 @@ struct css_style * box_get_style(struct content *c,
strcmp((const char *) n->name, "colgroup") != 0) {
markup_track->cell_border = false;
markup_track->cell_padding = false;
+ markup_track->table = false;
}
style = talloc_memdup(c, parent_style, sizeof *style);
@@ -1211,6 +1215,7 @@ 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 ||
@@ -1227,16 +1232,22 @@ struct css_style * box_get_style(struct content *c,
markup_track->align = ALIGN_LEFT;
xmlFree(s);
}
+ /* Need to remember if we're in a table, so that any alignment
+ * rules set on the table's elements won't get overridden by the
+ * default alignment of a cell with no align attribute.
+ * At this point, we're in a table if the element isn't a div */
+ if (strcmp((const char *) n->name, "div") != 0)
+ markup_track->table = true;
}
/* Table cells without an align value have a default implied
- * alignment */
- if (strcmp((const char *) n->name, "td") == 0) {
+ * alignment. */
+ if (strcmp((const char *) n->name, "td") == 0 && !markup_track->table) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_LEFT;
else
xmlFree(s);
}
- if (strcmp((const char *) n->name, "th") == 0) {
+ if (strcmp((const char *) n->name, "th") == 0 && !markup_track->table) {
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "align")))
markup_track->align = ALIGN_CENTER;
else