From 330c0174e5c94332801725a3a9be5bac377d75eb Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 19 Dec 2005 02:51:32 +0100 Subject: [PATCH] Rename DOM stack iterators and make them include all states when iterating They are now called: foreach{back,}_dom_stack_state (...) and the immutable flag together with node type restricted stack searches should ensure that the document root node never is popped. --- src/document/dom/stack.c | 2 +- src/document/dom/stack.h | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/document/dom/stack.c b/src/document/dom/stack.c index 8ee990581..510ee3742 100644 --- a/src/document/dom/stack.c +++ b/src/document/dom/stack.c @@ -204,7 +204,7 @@ pop_dom_state(struct dom_stack *stack, struct dom_stack_state *target) if (dom_stack_is_empty(stack)) return; - foreachback_dom_state (stack, state, pos) { + foreachback_dom_stack_state (stack, state, pos) { if (do_pop_dom_node(stack, target)) break;; } diff --git a/src/document/dom/stack.h b/src/document/dom/stack.h index 5501ea0f8..373cfe963 100644 --- a/src/document/dom/stack.h +++ b/src/document/dom/stack.h @@ -77,13 +77,13 @@ get_dom_stack_state(struct dom_stack *stack, int top_offset) /* The state iterators do not include the bottom state */ -#define foreach_dom_state(stack, item, pos) \ - for ((pos) = 1; (pos) < (stack)->depth; (pos)++) \ - if (((item) = &(stack)->states[(pos)])) +#define foreach_dom_stack_state(stack, state, pos) \ + for ((pos) = 0; (pos) < (stack)->depth; (pos)++) \ + if (((state) = &(stack)->states[(pos)])) -#define foreachback_dom_state(stack, item, pos) \ - for ((pos) = (stack)->depth - 1; (pos) > 0; (pos)--) \ - if (((item) = &(stack)->states[(pos)])) +#define foreachback_dom_stack_state(stack, state, pos) \ + for ((pos) = (stack)->depth - 1; (pos) >= 0; (pos)--) \ + if (((state) = &(stack)->states[(pos)])) /* Dive through the stack states in search for the specified match. */ static inline struct dom_stack_state * @@ -94,7 +94,7 @@ search_dom_stack(struct dom_stack *stack, enum dom_node_type type, int pos; /* FIXME: Take node subtype and compare if non-zero or something. */ - foreachback_dom_state (stack, state, pos) { + foreachback_dom_stack_state (stack, state, pos) { struct dom_node *parent = state->node; if (parent->type == type