mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Remove all traces of the element end-tag hilighting hack
End-tags will stay uncolored for the next few commits.
This commit is contained in:
parent
4c8d871404
commit
65b504f093
@ -137,12 +137,6 @@ do_pop_dom_node(struct dom_stack *stack, struct dom_stack_state *parent)
|
||||
if (!dom_stack_has_parents(stack)) return 0;
|
||||
|
||||
state = get_dom_stack_top(stack);
|
||||
if (state->callback) {
|
||||
void *state_data = get_dom_stack_state_data(stack, state);
|
||||
|
||||
/* Pass the node we are popping to and _not_ the state->node */
|
||||
state->callback(stack, parent->node, state_data);
|
||||
}
|
||||
|
||||
stack->depth--;
|
||||
assert(stack->depth >= 0);
|
||||
|
@ -24,10 +24,6 @@ struct dom_stack_state {
|
||||
/* The index (in the list above) which are currently being handled. */
|
||||
size_t index;
|
||||
|
||||
/* A callback registered to be called when the node is popped. Used for
|
||||
* correctly highlighting ending elements (e.g. </a>). */
|
||||
dom_stack_callback_T callback;
|
||||
|
||||
/* The depth of the state in the stack. This is amongst other things
|
||||
* used to get the state object data. */
|
||||
unsigned int depth;
|
||||
|
@ -37,66 +37,7 @@ static struct sgml_node_info html_elements[HTML_ELEMENTS] = {
|
||||
};
|
||||
|
||||
|
||||
static struct dom_node *
|
||||
add_html_element_end_node(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct sgml_parser *parser = stack->parser;
|
||||
struct dom_node *parent;
|
||||
struct scanner_token *token;
|
||||
|
||||
assert(stack && parser && node);
|
||||
assert(dom_stack_has_parents(stack));
|
||||
|
||||
/* Are we the actual node being popped? */
|
||||
if (node != get_dom_stack_top(stack)->node)
|
||||
return NULL;
|
||||
|
||||
parent = get_dom_stack_parent(stack)->node;
|
||||
token = get_scanner_token(&parser->scanner);
|
||||
|
||||
assertm(token, "No token found in callback");
|
||||
assertm(token->type == SGML_TOKEN_ELEMENT_END, "Bad token found in callback");
|
||||
|
||||
if (!token->length) return NULL;
|
||||
|
||||
return add_dom_element(parent, token->string, token->length);
|
||||
}
|
||||
|
||||
/* TODO: We need to handle ascending of <br> and "<p>text1<p>text2" using data
|
||||
* from sgml_node_info. */
|
||||
static struct dom_node *
|
||||
add_html_element_node(struct dom_stack *stack, struct dom_node *node, void *data)
|
||||
{
|
||||
struct sgml_parser *parser = stack->parser;
|
||||
|
||||
assert(stack && node);
|
||||
assert(dom_stack_has_parents(stack));
|
||||
|
||||
/* TODO: Move to SGML parser main loop and disguise these element ends
|
||||
* in some internal processing instruction. */
|
||||
if (parser->flags & SGML_PARSER_ADD_ELEMENT_ENDS)
|
||||
get_dom_stack_top(stack)->callback = add_html_element_end_node;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
struct sgml_info sgml_html_info = {
|
||||
html_attributes,
|
||||
html_elements,
|
||||
{
|
||||
/* */ NULL,
|
||||
/* DOM_NODE_ELEMENT */ add_html_element_node,
|
||||
/* DOM_NODE_ATTRIBUTE */ NULL,
|
||||
/* DOM_NODE_TEXT */ NULL,
|
||||
/* DOM_NODE_CDATA_SECTION */ NULL,
|
||||
/* DOM_NODE_ENTITY_REFERENCE */ NULL,
|
||||
/* DOM_NODE_ENTITY */ NULL,
|
||||
/* DOM_NODE_PROC_INSTRUCTION */ NULL,
|
||||
/* DOM_NODE_COMMENT */ NULL,
|
||||
/* DOM_NODE_DOCUMENT */ NULL,
|
||||
/* DOM_NODE_DOCUMENT_TYPE */ NULL,
|
||||
/* DOM_NODE_DOCUMENT_FRAGMENT */ NULL,
|
||||
/* DOM_NODE_NOTATION */ NULL,
|
||||
}
|
||||
};
|
||||
|
@ -311,10 +311,7 @@ init_sgml_parser(enum sgml_parser_type type, struct cache_entry *cached,
|
||||
parser->cache_entry = cached;
|
||||
parser->info = &sgml_html_info;
|
||||
|
||||
init_dom_stack(&parser->stack, parser, NULL, parser->info->callbacks, obj_size);
|
||||
|
||||
if (document->options.plain)
|
||||
parser->flags |= SGML_PARSER_ADD_ELEMENT_ENDS;
|
||||
init_dom_stack(&parser->stack, parser, NULL, NULL, obj_size);
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
@ -23,14 +23,9 @@ enum sgml_parser_type {
|
||||
SGML_PARSER_STREAM,
|
||||
};
|
||||
|
||||
enum sgml_parser_flags {
|
||||
SGML_PARSER_ADD_ELEMENT_ENDS = 1,
|
||||
};
|
||||
|
||||
struct sgml_parser {
|
||||
enum sgml_parser_type type;
|
||||
/* The parser flags controls what gets added to the DOM tree */
|
||||
enum sgml_parser_flags flags;
|
||||
|
||||
struct sgml_info *info;
|
||||
|
||||
struct document *document;
|
||||
|
@ -76,7 +76,6 @@ get_sgml_node_info(struct sgml_node_info list[], struct dom_node *node)
|
||||
struct sgml_info {
|
||||
struct sgml_node_info *attributes;
|
||||
struct sgml_node_info *elements;
|
||||
dom_stack_callback_T callbacks[DOM_NODES];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user