mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
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.
This commit is contained in:
parent
051db70dd4
commit
330c0174e5
@ -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;;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user