1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-10-27 08:00:32 -04:00

DOM: Added callbacks when adding an element or an attribute.

This commit is contained in:
Witold Filipczyk 2007-05-13 19:46:39 +02:00 committed by Witold Filipczyk
parent d6c844288a
commit 9edc009c10
2 changed files with 11 additions and 1 deletions

View File

@ -66,6 +66,9 @@ add_sgml_element(struct dom_stack *stack, struct dom_scanner_token *token)
if (push_dom_node(stack, node) != DOM_CODE_OK)
return NULL;
if (parser->add_element_callback)
parser->add_element_callback(parent, node);
state = get_dom_stack_top(stack);
assert(node == state->node);
@ -97,9 +100,12 @@ add_sgml_attribute(struct dom_stack *stack,
if (valtoken && valtoken->type == SGML_TOKEN_STRING)
node->data.attribute.quoted = valtoken->string.string[-1];
if (!node || push_dom_node(stack, node) != DOM_CODE_OK)
if (push_dom_node(stack, node) != DOM_CODE_OK)
return NULL;
if (parser->add_attribute_callback)
parser->add_attribute_callback(parent, node);
pop_dom_node(stack);
return node;

View File

@ -69,6 +69,8 @@ struct sgml_parser_state {
typedef enum dom_code
(*sgml_error_T)(struct sgml_parser *, struct dom_string *, unsigned int);
typedef void
(*sgml_callback_T)(struct dom_node *parent, struct dom_node *current);
/** The SGML parser
*
@ -88,6 +90,8 @@ struct sgml_parser {
enum dom_code code; /**< The latest (error) code */
sgml_error_T error_func; /**< Called for detected errors */
sgml_callback_T add_element_callback; /**< Called for added elements */
sgml_callback_T add_attribute_callback; /**< Called for added attributes */
struct dom_stack stack; /**< A stack for tracking parsed nodes */
struct dom_stack parsing; /**< Used for tracking parsing states */