From 22640f85e0d245df817df96afa18d382e3a1b49a Mon Sep 17 00:00:00 2001 From: James Bursa Date: Sun, 22 May 2005 21:50:14 +0000 Subject: [project @ 2005-05-22 21:50:14 by bursa] Add BOX_TEXT type to distinguish boxes which came from an inline element to boxes which came from a text node. Add inline_parent pointer to box structure. Rewrite text-decoration support to take advantage of the new data (line colours are now correct). Note: there is a clipping issue in redraw. svn path=/import/netsurf/; revision=1732 --- render/box_construct.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'render/box_construct.c') diff --git a/render/box_construct.c b/render/box_construct.c index 57046120f..d6841bf7b 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -72,14 +72,17 @@ static const content_type image_types[] = { static bool convert_xml_to_box(xmlNode *n, struct content *content, struct css_style *parent_style, struct box *parent, struct box **inline_container, + struct box *inline_parent, char *href, char *title); bool box_construct_element(xmlNode *n, struct content *content, struct css_style *parent_style, struct box *parent, struct box **inline_container, + struct box *inline_parent, char *href, char *title); bool box_construct_text(xmlNode *n, struct content *content, struct css_style *parent_style, struct box *parent, struct box **inline_container, + struct box *inline_parent, char *href, char *title); static struct css_style * box_get_style(struct content *c, struct css_style *parent_style, @@ -174,7 +177,7 @@ bool xml_to_box(xmlNode *n, struct content *c) c->data.html.object = 0; if (!convert_xml_to_box(n, c, c->data.html.style, &root, - &inline_container, 0, 0)) + &inline_container, 0, 0, 0)) return false; if (!box_normalise_block(&root, c)) return false; @@ -224,15 +227,16 @@ static const box_type box_map[] = { bool convert_xml_to_box(xmlNode *n, struct content *content, struct css_style *parent_style, struct box *parent, struct box **inline_container, + struct box *inline_parent, char *href, char *title) { switch (n->type) { case XML_ELEMENT_NODE: return box_construct_element(n, content, parent_style, parent, - inline_container, href, title); + inline_container, inline_parent, href, title); case XML_TEXT_NODE: return box_construct_text(n, content, parent_style, parent, - inline_container, href, title); + inline_container, inline_parent, href, title); default: /* not an element or text node: ignore it (eg. comment) */ return true; @@ -256,6 +260,7 @@ bool convert_xml_to_box(xmlNode *n, struct content *content, bool box_construct_element(xmlNode *n, struct content *content, struct css_style *parent_style, struct box *parent, struct box **inline_container, + struct box *inline_parent, char *href, char *title) { bool convert_children = true; @@ -335,10 +340,11 @@ bool box_construct_element(xmlNode *n, struct content *content, if (box->type == BOX_INLINE || box->type == BOX_BR) { /* inline box: add to tree and recurse */ + box->inline_parent = inline_parent; box_add_child(*inline_container, box); for (c = n->children; convert_children && c; c = c->next) if (!convert_xml_to_box(c, content, style, parent, - inline_container, href, title)) + inline_container, box, href, title)) return false; } else if (box->type == BOX_INLINE_BLOCK) { /* inline block box: add to tree and recurse */ @@ -346,7 +352,7 @@ bool box_construct_element(xmlNode *n, struct content *content, inline_container_c = 0; for (c = n->children; convert_children && c; c = c->next) if (!convert_xml_to_box(c, content, style, box, - &inline_container_c, href, title)) + &inline_container_c, 0, href, title)) return false; } else { if (style->float_ == CSS_FLOAT_LEFT || @@ -373,7 +379,7 @@ bool box_construct_element(xmlNode *n, struct content *content, inline_container_c = 0; for (c = n->children; convert_children && c; c = c->next) if (!convert_xml_to_box(c, content, style, box, - &inline_container_c, href, title)) + &inline_container_c, 0, href, title)) return false; if (style->float_ == CSS_FLOAT_NONE) /* new inline container unless this is a float */ @@ -486,6 +492,7 @@ bool box_construct_element(xmlNode *n, struct content *content, bool box_construct_text(xmlNode *n, struct content *content, struct css_style *parent_style, struct box *parent, struct box **inline_container, + struct box *inline_parent, char *href, char *title) { struct box *box = 0; @@ -529,6 +536,8 @@ bool box_construct_text(xmlNode *n, struct content *content, free(text); return false; } + box->type = BOX_TEXT; + box->inline_parent = inline_parent; box->text = talloc_strdup(content, text); free(text); if (!box->text) @@ -604,7 +613,8 @@ bool box_construct_text(xmlNode *n, struct content *content, free(text); return false; } - box->type = BOX_INLINE; + box->type = BOX_TEXT; + box->inline_parent = inline_parent; box->text = talloc_strdup(content, current); if (!box->text) { free(text); @@ -648,9 +658,6 @@ struct css_style * box_get_style(struct content *c, xmlNode *n) { char *s; - unsigned int i; - unsigned int stylesheet_count = c->data.html.stylesheet_count; - struct content **stylesheet = c->data.html.stylesheet_content; struct css_style *style; struct css_style *style_new; char *url; @@ -1284,7 +1291,7 @@ bool box_object(BOX_SPECIAL_PARAMS) /* convert children and place into fallback */ for (c = n->children; c; c = c->next) { if (!convert_xml_to_box(c, content, box->style, box, - &inline_container, 0, 0)) + &inline_container, 0, 0, 0)) return false; } box->fallback = box->children; -- cgit v1.2.3