mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Use dom_stack_code enum for dom_stack_callback_T
This commit is contained in:
parent
4a2cde1c00
commit
eecc22751d
@ -500,7 +500,7 @@ render_dom_node_enhanced_text(struct dom_renderer *renderer, struct dom_node *no
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -513,15 +513,15 @@ render_dom_node_source(struct dom_stack *stack, struct dom_node *node, void *dat
|
||||
|| node->type == DOM_NODE_CDATA_SECTION
|
||||
|| node->type == DOM_NODE_COMMENT)) {
|
||||
render_dom_node_enhanced_text(renderer, node);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
|
||||
render_dom_node_text(renderer, &renderer->styles[node->type], node);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
/* This callback is also used for rendering processing instruction nodes. */
|
||||
static void
|
||||
static enum dom_stack_code
|
||||
render_dom_element_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -529,9 +529,11 @@ render_dom_element_source(struct dom_stack *stack, struct dom_node *node, void *
|
||||
assert(node && renderer && renderer->document);
|
||||
|
||||
render_dom_node_text(renderer, &renderer->styles[node->type], node);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
render_dom_element_end_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -544,7 +546,7 @@ render_dom_element_end_source(struct dom_stack *stack, struct dom_node *node, vo
|
||||
assert(node && renderer && renderer->document);
|
||||
|
||||
if (!string || !length)
|
||||
return;
|
||||
return DOM_STACK_CODE_OK;
|
||||
|
||||
if (check_dom_node_source(renderer, string, length)) {
|
||||
render_dom_flush(renderer, string);
|
||||
@ -553,9 +555,11 @@ render_dom_element_end_source(struct dom_stack *stack, struct dom_node *node, vo
|
||||
}
|
||||
|
||||
render_dom_text(renderer, &renderer->styles[node->type], string, length);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -620,9 +624,11 @@ render_dom_attribute_source(struct dom_stack *stack, struct dom_node *node, void
|
||||
render_dom_text(renderer, template, value, valuelen);
|
||||
}
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
render_dom_cdata_source(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -639,9 +645,11 @@ render_dom_cdata_source(struct dom_stack *stack, struct dom_node *node, void *da
|
||||
}
|
||||
|
||||
render_dom_node_text(renderer, &renderer->styles[node->type], node);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
render_dom_document_end(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -652,6 +660,8 @@ render_dom_document_end(struct dom_stack *stack, struct dom_node *node, void *da
|
||||
if (check_dom_node_source(renderer, renderer->position, 0)) {
|
||||
render_dom_flush(renderer, renderer->end);
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static struct dom_stack_context_info dom_source_renderer_context_info = {
|
||||
@ -693,7 +703,7 @@ static struct dom_stack_context_info dom_source_renderer_context_info = {
|
||||
|
||||
/* DOM RSS Renderer */
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_rss_push_element(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -735,9 +745,11 @@ dom_rss_push_element(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
|
||||
renderer->node = node;
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_rss_pop_element(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -776,9 +788,11 @@ dom_rss_pop_element(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_rss_push_content(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
@ -788,7 +802,7 @@ dom_rss_push_content(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
assert(node && renderer && renderer->document);
|
||||
|
||||
if (!renderer->node)
|
||||
return;
|
||||
return DOM_STACK_CODE_OK;
|
||||
|
||||
if (node->type == DOM_NODE_ENTITY_REFERENCE) {
|
||||
string -= 1;
|
||||
@ -800,6 +814,8 @@ dom_rss_push_content(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
} else {
|
||||
add_to_dom_string(&renderer->text, string, length);
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static struct dom_string *
|
||||
@ -901,13 +917,13 @@ render_rss_item(struct dom_renderer *renderer, struct dom_node *item)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_rss_pop_document(struct dom_stack *stack, struct dom_node *root, void *data)
|
||||
{
|
||||
struct dom_renderer *renderer = stack->current->data;
|
||||
|
||||
if (!renderer->channel)
|
||||
return;
|
||||
return DOM_STACK_CODE_OK;
|
||||
|
||||
render_rss_item(renderer, renderer->channel);
|
||||
|
||||
@ -927,6 +943,8 @@ dom_rss_pop_document(struct dom_stack *stack, struct dom_node *root, void *data)
|
||||
mem_free_if(renderer->items);
|
||||
|
||||
done_dom_node(root);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -897,7 +897,7 @@ match_element_selector(struct dom_select_node *selector, struct dom_node *node,
|
||||
#define get_dom_select_data(stack) ((stack)->current->data)
|
||||
|
||||
/* Matches an element node being visited against the current selector stack. */
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_select_push_element(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_select_data *select_data = get_dom_select_data(stack);
|
||||
@ -921,11 +921,13 @@ dom_select_push_element(struct dom_stack *stack, struct dom_node *node, void *da
|
||||
if (selector)
|
||||
push_dom_node(&select_data->stack, &selector->node);
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
/* Ensures that nodes, no longer 'reachable' on the stack do not have any
|
||||
* states associated with them on the select data stack. */
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_select_pop_element(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_select_data *select_data = get_dom_select_data(stack);
|
||||
@ -944,12 +946,14 @@ dom_select_pop_element(struct dom_stack *stack, struct dom_node *node, void *dat
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
/* For now this is only for matching the ':contains(<string>)' pseudo-class.
|
||||
* Any node which can contain text and thus characters from the given <string>
|
||||
* are handled in this common callback. */
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_select_push_text(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_select_data *select_data = get_dom_select_data(stack);
|
||||
@ -961,7 +965,7 @@ dom_select_push_text(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
WDBG("Text node: %d chars", node->string.length);
|
||||
|
||||
if (!text_sel)
|
||||
return;
|
||||
return DOM_STACK_CODE_OK;
|
||||
|
||||
text = &text_sel->node.string;
|
||||
|
||||
@ -973,6 +977,8 @@ dom_select_push_text(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
default:
|
||||
ERROR("Unhandled type");
|
||||
}
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
/* Context info for interacting with the DOM tree or stream stack. */
|
||||
|
@ -432,7 +432,7 @@ struct sgml_parsing_state {
|
||||
size_t depth;
|
||||
};
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
sgml_parsing_push(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct sgml_parser *parser = get_sgml_parser(stack);
|
||||
@ -448,9 +448,11 @@ sgml_parsing_push(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
SGML_STATE_TEXT, count_lines, complete, incremental,
|
||||
detect_errors);
|
||||
parser->code = parse_sgml_plain(&parser->stack, &parsing->scanner);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
sgml_parsing_pop(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct sgml_parser *parser = get_sgml_parser(stack);
|
||||
@ -464,6 +466,8 @@ sgml_parsing_pop(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
}
|
||||
|
||||
assert(parsing->depth == parser->stack.depth);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static struct dom_stack_context_info sgml_parsing_context_info = {
|
||||
|
@ -489,7 +489,7 @@ static unsigned char indent_string[] =
|
||||
#define get_indent_offset(stack) \
|
||||
((stack)->depth < sizeof(indent_string)/2 ? (stack)->depth * 2 : sizeof(indent_string))
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_stack_trace_tree(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_string *value = &node->string;
|
||||
@ -500,9 +500,11 @@ dom_stack_trace_tree(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
get_indent_offset(stack), indent_string,
|
||||
name->length, name->string,
|
||||
value->length, value->string);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_stack_trace_id_leaf(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_string value;
|
||||
@ -523,9 +525,11 @@ dom_stack_trace_id_leaf(struct dom_stack *stack, struct dom_node *node, void *da
|
||||
|
||||
if (is_dom_string_set(&value))
|
||||
done_dom_string(&value);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_stack_trace_leaf(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_string *name;
|
||||
@ -544,9 +548,11 @@ dom_stack_trace_leaf(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
|
||||
if (is_dom_string_set(&value))
|
||||
done_dom_string(&value);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
static void
|
||||
enum dom_stack_code
|
||||
dom_stack_trace_branch(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct dom_string *name;
|
||||
@ -561,6 +567,8 @@ dom_stack_trace_branch(struct dom_stack *stack, struct dom_node *node, void *dat
|
||||
empty_string_or_(stack->current->data),
|
||||
get_indent_offset(stack), indent_string,
|
||||
id->length, id->string, name->length, name->string);
|
||||
|
||||
return DOM_STACK_CODE_OK;
|
||||
}
|
||||
|
||||
struct dom_stack_context_info dom_stack_trace_context_info = {
|
||||
|
@ -22,7 +22,8 @@ enum dom_stack_code {
|
||||
/** DOM stack callback
|
||||
*
|
||||
* Used by contexts, for 'hooking' into the node traversing. */
|
||||
typedef void (*dom_stack_callback_T)(struct dom_stack *, struct dom_node *, void *);
|
||||
typedef enum dom_stack_code
|
||||
(*dom_stack_callback_T)(struct dom_stack *, struct dom_node *, void *);
|
||||
|
||||
#define DOM_STACK_MAX_DEPTH 4096
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user