mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-24 04:56:50 +03:00
[project @ 2003-12-10 23:12:39 by bursa]
Remove obsolete css_selector code. svn path=/import/netsurf/; revision=424
This commit is contained in:
parent
87cb037c31
commit
c5f1560a70
48
render/box.c
48
render/box.c
@ -47,12 +47,11 @@ struct result {
|
|||||||
|
|
||||||
static struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
static struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
||||||
struct css_style * parent_style,
|
struct css_style * parent_style,
|
||||||
struct css_selector ** selector, unsigned int depth,
|
|
||||||
struct box * parent, struct box *inline_container,
|
struct box * parent, struct box *inline_container,
|
||||||
struct status status);
|
struct status status);
|
||||||
static struct css_style * box_get_style(struct content ** stylesheet,
|
static struct css_style * box_get_style(struct content ** stylesheet,
|
||||||
unsigned int stylesheet_count, struct css_style * parent_style,
|
unsigned int stylesheet_count, struct css_style * parent_style,
|
||||||
xmlNode * n, struct css_selector * selector, unsigned int depth);
|
xmlNode * n);
|
||||||
static struct result box_a(xmlNode *n, struct status *status,
|
static struct result box_a(xmlNode *n, struct status *status,
|
||||||
struct css_style *style);
|
struct css_style *style);
|
||||||
static struct result box_body(xmlNode *n, struct status *status,
|
static struct result box_body(xmlNode *n, struct status *status,
|
||||||
@ -201,7 +200,6 @@ void box_insert_sibling(struct box *box, struct box *new_box)
|
|||||||
|
|
||||||
void xml_to_box(xmlNode *n, struct content *c)
|
void xml_to_box(xmlNode *n, struct content *c)
|
||||||
{
|
{
|
||||||
struct css_selector* selector = xcalloc(1, sizeof(struct css_selector));
|
|
||||||
struct status status = {c, 0, 0, 0, &c->data.html.elements};
|
struct status status = {c, 0, 0, 0, &c->data.html.elements};
|
||||||
|
|
||||||
LOG(("node %p", n));
|
LOG(("node %p", n));
|
||||||
@ -218,7 +216,7 @@ void xml_to_box(xmlNode *n, struct content *c)
|
|||||||
c->data.html.object = xcalloc(0, sizeof(*c->data.html.object));
|
c->data.html.object = xcalloc(0, sizeof(*c->data.html.object));
|
||||||
|
|
||||||
convert_xml_to_box(n, c, c->data.html.style,
|
convert_xml_to_box(n, c, c->data.html.style,
|
||||||
&selector, 0, c->data.html.layout, 0, status);
|
c->data.html.layout, 0, status);
|
||||||
LOG(("normalising"));
|
LOG(("normalising"));
|
||||||
box_normalise_block(c->data.html.layout->children);
|
box_normalise_block(c->data.html.layout->children);
|
||||||
}
|
}
|
||||||
@ -231,8 +229,6 @@ void xml_to_box(xmlNode *n, struct content *c)
|
|||||||
* n xml tree
|
* n xml tree
|
||||||
* content content structure
|
* content content structure
|
||||||
* parent_style style at this point in xml tree
|
* parent_style style at this point in xml tree
|
||||||
* selector element selector hierachy to this point
|
|
||||||
* depth depth in xml tree
|
|
||||||
* parent parent in box tree
|
* parent parent in box tree
|
||||||
* inline_container current inline container box, or 0
|
* inline_container current inline container box, or 0
|
||||||
* status status for forms etc.
|
* status status for forms etc.
|
||||||
@ -264,7 +260,6 @@ static box_type box_map[] = {
|
|||||||
|
|
||||||
struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
||||||
struct css_style * parent_style,
|
struct css_style * parent_style,
|
||||||
struct css_selector ** selector, unsigned int depth,
|
|
||||||
struct box * parent, struct box *inline_container,
|
struct box * parent, struct box *inline_container,
|
||||||
struct status status)
|
struct status status)
|
||||||
{
|
{
|
||||||
@ -278,28 +273,19 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
|||||||
int convert_children = 1;
|
int convert_children = 1;
|
||||||
char *href_in = status.href;
|
char *href_in = status.href;
|
||||||
|
|
||||||
assert(n != 0 && parent_style != 0 && selector != 0 && parent != 0);
|
assert(n != 0 && parent_style != 0 && parent != 0);
|
||||||
LOG(("depth %i, node %p, node type %i", depth, n, n->type));
|
LOG(("node %p, node type %i", n, n->type));
|
||||||
gui_multitask();
|
gui_multitask();
|
||||||
|
|
||||||
if (n->type == XML_ELEMENT_NODE) {
|
if (n->type == XML_ELEMENT_NODE) {
|
||||||
struct element_entry *element;
|
struct element_entry *element;
|
||||||
|
|
||||||
/* work out the style for this element */
|
|
||||||
*selector = xrealloc(*selector, (depth + 1) * sizeof(struct css_selector));
|
|
||||||
(*selector)[depth].element = (const char *) n->name;
|
|
||||||
(*selector)[depth].class = (*selector)[depth].id = 0;
|
|
||||||
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "class")))
|
|
||||||
(*selector)[depth].class = s;
|
|
||||||
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "id")))
|
|
||||||
(*selector)[depth].id = s;
|
|
||||||
style = box_get_style(content->data.html.stylesheet_content,
|
style = box_get_style(content->data.html.stylesheet_content,
|
||||||
content->data.html.stylesheet_count, parent_style, n,
|
content->data.html.stylesheet_count, parent_style, n);
|
||||||
*selector, depth + 1);
|
|
||||||
LOG(("display: %s", css_display_name[style->display]));
|
LOG(("display: %s", css_display_name[style->display]));
|
||||||
if (style->display == CSS_DISPLAY_NONE) {
|
if (style->display == CSS_DISPLAY_NONE) {
|
||||||
free(style);
|
free(style);
|
||||||
LOG(("depth %i, node %p, node type %i END", depth, n, n->type));
|
LOG(("node %p, node type %i END", n, n->type));
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
/* floats are treated as blocks */
|
/* floats are treated as blocks */
|
||||||
@ -326,7 +312,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
|||||||
/* no box for this element */
|
/* no box for this element */
|
||||||
assert(convert_children == 0);
|
assert(convert_children == 0);
|
||||||
free(style);
|
free(style);
|
||||||
LOG(("depth %i, node %p, node type %i END", depth, n, n->type));
|
LOG(("node %p, node type %i END", n, n->type));
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -340,7 +326,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* not an element or text node: ignore it (eg. comment) */
|
/* not an element or text node: ignore it (eg. comment) */
|
||||||
LOG(("depth %i, node %p, node type %i END", depth, n, n->type));
|
LOG(("node %p, node type %i END", n, n->type));
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,10 +436,10 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
|||||||
if (convert_children) {
|
if (convert_children) {
|
||||||
for (c = n->children; c != 0; c = c->next)
|
for (c = n->children; c != 0; c = c->next)
|
||||||
inline_container = convert_xml_to_box(c, content, style,
|
inline_container = convert_xml_to_box(c, content, style,
|
||||||
selector, depth + 1, parent, inline_container,
|
parent, inline_container,
|
||||||
status);
|
status);
|
||||||
}
|
}
|
||||||
LOG(("depth %i, node %p, node type %i END", depth, n, n->type));
|
LOG(("node %p, node type %i END", n, n->type));
|
||||||
goto end;
|
goto end;
|
||||||
} else if (box->type == BOX_INLINE_BLOCK) {
|
} else if (box->type == BOX_INLINE_BLOCK) {
|
||||||
/* inline block box: add to tree and recurse */
|
/* inline block box: add to tree and recurse */
|
||||||
@ -462,10 +448,10 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
|||||||
inline_container_c = 0;
|
inline_container_c = 0;
|
||||||
for (c = n->children; c != 0; c = c->next)
|
for (c = n->children; c != 0; c = c->next)
|
||||||
inline_container_c = convert_xml_to_box(c, content, style,
|
inline_container_c = convert_xml_to_box(c, content, style,
|
||||||
selector, depth + 1, box, inline_container_c,
|
box, inline_container_c,
|
||||||
status);
|
status);
|
||||||
}
|
}
|
||||||
LOG(("depth %i, node %p, node type %i END", depth, n, n->type));
|
LOG(("node %p, node type %i END", n, n->type));
|
||||||
goto end;
|
goto end;
|
||||||
} else {
|
} else {
|
||||||
/* float: insert a float box between the parent and current node */
|
/* float: insert a float box between the parent and current node */
|
||||||
@ -492,7 +478,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct content *content,
|
|||||||
inline_container_c = 0;
|
inline_container_c = 0;
|
||||||
for (c = n->children; c != 0; c = c->next)
|
for (c = n->children; c != 0; c = c->next)
|
||||||
inline_container_c = convert_xml_to_box(c, content, style,
|
inline_container_c = convert_xml_to_box(c, content, style,
|
||||||
selector, depth + 1, box, inline_container_c,
|
box, inline_container_c,
|
||||||
status);
|
status);
|
||||||
}
|
}
|
||||||
if (style->float_ == CSS_FLOAT_NONE)
|
if (style->float_ == CSS_FLOAT_NONE)
|
||||||
@ -514,12 +500,8 @@ end:
|
|||||||
free(title);
|
free(title);
|
||||||
if (!href_in)
|
if (!href_in)
|
||||||
xmlFree(status.href);
|
xmlFree(status.href);
|
||||||
if (n->type == XML_ELEMENT_NODE) {
|
|
||||||
free((*selector)[depth].class);
|
|
||||||
free((*selector)[depth].id);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG(("depth %i, node %p, node type %i END", depth, n, n->type));
|
LOG(("node %p, node type %i END", n, n->type));
|
||||||
return inline_container;
|
return inline_container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,7 +517,7 @@ end:
|
|||||||
|
|
||||||
struct css_style * box_get_style(struct content ** stylesheet,
|
struct css_style * box_get_style(struct content ** stylesheet,
|
||||||
unsigned int stylesheet_count, struct css_style * parent_style,
|
unsigned int stylesheet_count, struct css_style * parent_style,
|
||||||
xmlNode * n, struct css_selector * selector, unsigned int depth)
|
xmlNode * n)
|
||||||
{
|
{
|
||||||
struct css_style * style = xcalloc(1, sizeof(struct css_style));
|
struct css_style * style = xcalloc(1, sizeof(struct css_style));
|
||||||
struct css_style * style_new = xcalloc(1, sizeof(struct css_style));
|
struct css_style * style_new = xcalloc(1, sizeof(struct css_style));
|
||||||
|
Loading…
Reference in New Issue
Block a user