diff --git a/src/document/dom/renderer.c b/src/document/dom/renderer.c index f5061b90..3341024c 100644 --- a/src/document/dom/renderer.c +++ b/src/document/dom/renderer.c @@ -803,7 +803,8 @@ render_dom_document(struct cache_entry *cached, struct document *document, &renderer, cached->uri); if (!parser) return; - add_dom_stack_context(&parser->stack, &dom_source_renderer_context_info); + add_dom_stack_context(&parser->stack, &renderer, + &dom_source_renderer_context_info); root = parse_sgml(parser, buffer); done_sgml_parser(parser); diff --git a/src/document/dom/select.c b/src/document/dom/select.c index 041f058e..a4f86e76 100644 --- a/src/document/dom/select.c +++ b/src/document/dom/select.c @@ -831,7 +831,8 @@ select_dom_nodes(struct dom_select *select, struct dom_node *root) select_data.select = select;; init_dom_stack(&stack, &select_data, 0, 1); - add_dom_stack_context(&stack, &dom_select_context_info); + add_dom_stack_context(&stack, &select_data, + &dom_select_context_info); init_dom_stack(&select_data.stack, &select_data, obj_size, 1); diff --git a/src/document/dom/stack.c b/src/document/dom/stack.c index 682f94f5..47ce75a7 100644 --- a/src/document/dom/stack.c +++ b/src/document/dom/stack.c @@ -78,13 +78,17 @@ done_dom_stack(struct dom_stack *stack) } void -add_dom_stack_context(struct dom_stack *stack, +add_dom_stack_context(struct dom_stack *stack, void *data, struct dom_stack_context_info *context_info) { + struct dom_stack_context *context; + if (!realloc_dom_stack_context(&stack->contexts, stack->contexts_size)) return; - stack->contexts[stack->contexts_size++].info = context_info; + context = &stack->contexts[stack->contexts_size++]; + context->info = context_info; + context->data = data; } enum dom_stack_action { diff --git a/src/document/dom/stack.h b/src/document/dom/stack.h index aa9ba5c3..dc032d80 100644 --- a/src/document/dom/stack.h +++ b/src/document/dom/stack.h @@ -16,6 +16,10 @@ struct dom_stack_context_info { }; struct dom_stack_context { + /* Data specific to the parser and renderer. */ + void *data; + + /* Info about node callbacks and such. */ struct dom_stack_context_info *info; }; @@ -124,7 +128,7 @@ void init_dom_stack(struct dom_stack *stack, void *data, void done_dom_stack(struct dom_stack *stack); /* Add a callback collection to the stack. */ -void add_dom_stack_context(struct dom_stack *stack, +void add_dom_stack_context(struct dom_stack *stack, void *data, struct dom_stack_context_info *context_info); /* Decends down to the given node making it the current parent */