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

Simplify DOM node popping

.. by turning do_pop_dom_node() into pop_dom_node() and let pop_dom_state()
handle it's own logic for reaching the wanted state.
This commit is contained in:
Jonas Fonseca 2005-12-27 04:42:28 +01:00 committed by Jonas Fonseca
parent f371de1638
commit af19f811e3

View File

@ -164,17 +164,20 @@ push_dom_node(struct dom_stack *stack, struct dom_node *node)
return node; return node;
} }
static int void
do_pop_dom_node(struct dom_stack *stack, struct dom_stack_state *parent) pop_dom_node(struct dom_stack *stack)
{ {
struct dom_stack_state *state; struct dom_stack_state *state;
int i; int i;
assert(stack && !dom_stack_is_empty(stack)); assert(stack);
if (dom_stack_is_empty(stack))
return;
state = get_dom_stack_top(stack); state = get_dom_stack_top(stack);
if (state->immutable) if (state->immutable)
return 1; return;
call_dom_stack_callbacks(stack, state, DOM_STACK_POP); call_dom_stack_callbacks(stack, state, DOM_STACK_POP);
@ -195,18 +198,6 @@ do_pop_dom_node(struct dom_stack *stack, struct dom_stack_state *parent)
} }
memset(state, 0, sizeof(*state)); memset(state, 0, sizeof(*state));
return state == parent;
}
void
pop_dom_node(struct dom_stack *stack)
{
assert(stack);
if (dom_stack_is_empty(stack)) return;
do_pop_dom_node(stack, get_dom_stack_parent(stack));
} }
void void
@ -237,8 +228,14 @@ pop_dom_state(struct dom_stack *stack, struct dom_stack_state *target)
if (dom_stack_is_empty(stack)) return; if (dom_stack_is_empty(stack)) return;
foreachback_dom_stack_state (stack, state, pos) { foreachback_dom_stack_state (stack, state, pos) {
if (do_pop_dom_node(stack, target)) /* Don't pop past states marked immutable. */
break;; if (state->immutable)
break;
/* Pop until the target state is reached. */
pop_dom_node(stack);
if (state == target)
break;
} }
} }