mirror of
https://github.com/rkd77/elinks.git
synced 2025-02-02 15:09:23 -05:00
Add boolean immutable flag to the DOM stack state
Can be used to ensure the document root node never leaves the stack while parsing.
This commit is contained in:
parent
50223a91ae
commit
051db70dd4
@ -140,6 +140,9 @@ do_pop_dom_node(struct dom_stack *stack, struct dom_stack_state *parent)
|
||||
assert(stack && !dom_stack_is_empty(stack));
|
||||
|
||||
state = get_dom_stack_top(stack);
|
||||
if (state->immutable)
|
||||
return 1;
|
||||
|
||||
callback = stack->pop_callbacks[state->node->type];
|
||||
if (callback) {
|
||||
void *state_data = get_dom_stack_state_data(stack, state);
|
||||
|
@ -27,6 +27,9 @@ struct dom_stack_state {
|
||||
/* The depth of the state in the stack. This is amongst other things
|
||||
* used to get the state object data. */
|
||||
unsigned int depth;
|
||||
|
||||
/* Wether this stack state can be popped with pop_dom_*() family. */
|
||||
unsigned int immutable:1;
|
||||
};
|
||||
|
||||
/* The DOM stack is a convenient way to traverse DOM trees. Also it
|
||||
|
@ -330,6 +330,8 @@ init_sgml_parser(enum sgml_parser_type type, void *data, struct uri *uri,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
get_dom_stack_top(&parser->stack)->immutable = 1;
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user