1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Use separate data variables for storing DOM stack data

They will eventually have to share the stack.
This commit is contained in:
Jonas Fonseca 2005-12-05 11:16:05 +01:00 committed by Jonas Fonseca
parent f85b498375
commit 8f25d73013
5 changed files with 21 additions and 18 deletions

View File

@ -387,7 +387,7 @@ add_dom_link(struct dom_renderer *renderer, unsigned char *string, int length)
static struct dom_node * static struct dom_node *
render_dom_tree(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_tree(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
struct screen_char *template = &renderer->styles[node->type]; struct screen_char *template = &renderer->styles[node->type];
unsigned char *name, *value; unsigned char *name, *value;
@ -407,7 +407,7 @@ render_dom_tree(struct dom_stack *stack, struct dom_node *node, void *data)
static struct dom_node * static struct dom_node *
render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
struct document *document = renderer->document; struct document *document = renderer->document;
struct screen_char *template = &renderer->styles[node->type]; struct screen_char *template = &renderer->styles[node->type];
unsigned char *name, *value, *id; unsigned char *name, *value, *id;
@ -430,7 +430,7 @@ render_dom_tree_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da
static struct dom_node * static struct dom_node *
render_dom_tree_leaf(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_tree_leaf(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
struct document *document = renderer->document; struct document *document = renderer->document;
struct screen_char *template = &renderer->styles[node->type]; struct screen_char *template = &renderer->styles[node->type];
unsigned char *name, *value; unsigned char *name, *value;
@ -452,7 +452,7 @@ render_dom_tree_leaf(struct dom_stack *stack, struct dom_node *node, void *data)
static struct dom_node * static struct dom_node *
render_dom_tree_branch(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_tree_branch(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
struct document *document = renderer->document; struct document *document = renderer->document;
struct screen_char *template = &renderer->styles[node->type]; struct screen_char *template = &renderer->styles[node->type];
unsigned char *name, *id; unsigned char *name, *id;
@ -536,7 +536,7 @@ render_dom_node_text(struct dom_renderer *renderer, struct screen_char *template
static struct dom_node * static struct dom_node *
render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
assert(node && renderer && renderer->document); assert(node && renderer && renderer->document);
@ -550,7 +550,7 @@ render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *dat
static struct dom_node * static struct dom_node *
render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
unsigned char *value; unsigned char *value;
int valuelen; int valuelen;
@ -577,7 +577,7 @@ render_dom_proc_instr_source(struct dom_stack *stack, struct dom_node *node, voi
static struct dom_node * static struct dom_node *
render_dom_element_source(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_element_source(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
assert(node && renderer && renderer->document); assert(node && renderer && renderer->document);
@ -590,7 +590,7 @@ static struct dom_node *
render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void *data) render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct dom_stack_state *state = get_dom_stack_parent(stack); struct dom_stack_state *state = get_dom_stack_parent(stack);
struct dom_renderer *renderer = stack->data; struct dom_renderer *renderer = stack->renderer;
struct screen_char *template = &renderer->styles[node->type]; struct screen_char *template = &renderer->styles[node->type];
struct dom_node *attribute = NULL; struct dom_node *attribute = NULL;
int i; int i;
@ -714,7 +714,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
document->options.hard_assume); document->options.hard_assume);
init_dom_renderer(&renderer, document, buffer, convert_table); init_dom_renderer(&renderer, document, buffer, convert_table);
init_dom_stack(&stack, &renderer, callbacks, 0); init_dom_stack(&stack, NULL, &renderer, callbacks, 0);
document->bgcolor = document->options.default_bg; document->bgcolor = document->options.default_bg;

View File

@ -45,7 +45,7 @@ realloc_dom_stack_state_objects(struct dom_stack *stack)
} }
void void
init_dom_stack(struct dom_stack *stack, void *data, init_dom_stack(struct dom_stack *stack, void *parser, void *renderer,
dom_stack_callback_T callbacks[DOM_NODES], dom_stack_callback_T callbacks[DOM_NODES],
size_t object_size) size_t object_size)
{ {
@ -53,7 +53,8 @@ init_dom_stack(struct dom_stack *stack, void *data,
memset(stack, 0, sizeof(*stack)); memset(stack, 0, sizeof(*stack));
stack->data = data; stack->parser = parser;
stack->renderer = renderer;
stack->object_size = object_size; stack->object_size = object_size;
if (callbacks) if (callbacks)

View File

@ -50,7 +50,9 @@ struct dom_stack {
/* Parser and document specific stuff */ /* Parser and document specific stuff */
dom_stack_callback_T callbacks[DOM_NODES]; dom_stack_callback_T callbacks[DOM_NODES];
void *data; void *renderer;
void *parser;
}; };
#define dom_stack_has_parents(nav) \ #define dom_stack_has_parents(nav) \
@ -107,7 +109,7 @@ search_dom_stack(struct dom_stack *stack, enum dom_node_type type,
/* The @object_size arg tells whether the stack should allocate objects for each /* The @object_size arg tells whether the stack should allocate objects for each
* state to be assigned to the state's @data member. Zero means no state data should * state to be assigned to the state's @data member. Zero means no state data should
* be allocated. */ * be allocated. */
void init_dom_stack(struct dom_stack *stack, void *data, void init_dom_stack(struct dom_stack *stack, void *parser, void *renderer,
dom_stack_callback_T callbacks[DOM_NODES], dom_stack_callback_T callbacks[DOM_NODES],
size_t object_size); size_t object_size);
void done_dom_stack(struct dom_stack *stack); void done_dom_stack(struct dom_stack *stack);

View File

@ -40,7 +40,7 @@ static struct sgml_node_info html_elements[HTML_ELEMENTS] = {
static struct dom_node * static struct dom_node *
add_html_element_end_node(struct dom_stack *stack, struct dom_node *node, void *data) add_html_element_end_node(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct sgml_parser *parser = stack->data; struct sgml_parser *parser = stack->parser;
struct dom_node *parent; struct dom_node *parent;
struct scanner_token *token; struct scanner_token *token;
@ -67,7 +67,7 @@ add_html_element_end_node(struct dom_stack *stack, struct dom_node *node, void *
static struct dom_node * static struct dom_node *
add_html_element_node(struct dom_stack *stack, struct dom_node *node, void *data) add_html_element_node(struct dom_stack *stack, struct dom_node *node, void *data)
{ {
struct sgml_parser *parser = stack->data; struct sgml_parser *parser = stack->parser;
assert(stack && node); assert(stack && node);
assert(dom_stack_has_parents(stack)); assert(dom_stack_has_parents(stack));

View File

@ -41,7 +41,7 @@ add_sgml_document(struct dom_stack *stack, struct uri *uri)
static inline struct dom_node * static inline struct dom_node *
add_sgml_element(struct dom_stack *stack, struct scanner_token *token) add_sgml_element(struct dom_stack *stack, struct scanner_token *token)
{ {
struct sgml_parser *parser = stack->data; struct sgml_parser *parser = stack->parser;
struct dom_node *parent = get_dom_stack_top(stack)->node; struct dom_node *parent = get_dom_stack_top(stack)->node;
struct dom_stack_state *state; struct dom_stack_state *state;
struct sgml_parser_state *pstate; struct sgml_parser_state *pstate;
@ -71,7 +71,7 @@ static inline void
add_sgml_attribute(struct dom_stack *stack, add_sgml_attribute(struct dom_stack *stack,
struct scanner_token *token, struct scanner_token *valtoken) struct scanner_token *token, struct scanner_token *valtoken)
{ {
struct sgml_parser *parser = stack->data; struct sgml_parser *parser = stack->parser;
struct dom_node *parent = get_dom_stack_top(stack)->node; struct dom_node *parent = get_dom_stack_top(stack)->node;
unsigned char *value = valtoken ? valtoken->string : NULL; unsigned char *value = valtoken ? valtoken->string : NULL;
uint16_t valuelen = valtoken ? valtoken->length : 0; uint16_t valuelen = valtoken ? valtoken->length : 0;
@ -309,7 +309,7 @@ init_sgml_parser(struct cache_entry *cached, struct document *document)
parser->cache_entry = cached; parser->cache_entry = cached;
parser->info = &sgml_html_info; parser->info = &sgml_html_info;
init_dom_stack(&parser->stack, parser, parser->info->callbacks, obj_size); init_dom_stack(&parser->stack, parser, NULL, parser->info->callbacks, obj_size);
if (document->options.plain) if (document->options.plain)
parser->flags |= SGML_PARSER_ADD_ELEMENT_ENDS; parser->flags |= SGML_PARSER_ADD_ELEMENT_ENDS;