1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Use is_*_element() to determine whether element is block or inline

Use that in the stack killing code, where we do some pretty funny checks
and stuff. The decision is based on the linebreak struct attribute,
non-zero for block elements.
This commit is contained in:
Petr Baudis 2005-09-22 21:44:28 +02:00 committed by Petr Baudis
parent a3f177e088
commit 7a91098135
2 changed files with 5 additions and 3 deletions

View File

@ -140,6 +140,8 @@ struct html_element {
ELEMENT_VISITED = 2, ELEMENT_VISITED = 2,
} pseudo_class; } pseudo_class;
}; };
#define is_inline_element(e) (e->linebreak == 0)
#define is_block_element(e) (e->linebreak > 0)
enum html_special_type { enum html_special_type {
SP_TAG, SP_TAG,

View File

@ -812,10 +812,10 @@ start_element(struct element_info *ei,
if (ei->type == ELEMENT_TYPE_NON_NESTABLE) { if (ei->type == ELEMENT_TYPE_NON_NESTABLE) {
foreach (e, html_context->stack) { foreach (e, html_context->stack) {
if (e->type < ELEMENT_KILLABLE) break; if (e->type < ELEMENT_KILLABLE) break;
if (e->linebreak || !ei->linebreak) break; if (is_block_element(e) || is_inline_element(ei)) break;
} }
} else foreach (e, html_context->stack) { } else foreach (e, html_context->stack) {
if (e->linebreak && !ei->linebreak) break; if (is_block_element(e) && is_inline_element(ei)) break;
if (e->type < ELEMENT_KILLABLE) break; if (e->type < ELEMENT_KILLABLE) break;
if (!strlcasecmp(e->name, e->namelen, name, namelen)) break; if (!strlcasecmp(e->name, e->namelen, name, namelen)) break;
} }
@ -930,7 +930,7 @@ end_element(struct element_info *ei,
/* dump_html_stack(html_context); */ /* dump_html_stack(html_context); */
foreach (e, html_context->stack) { foreach (e, html_context->stack) {
if (e->linebreak && !ei->linebreak) kill = 1; if (is_block_element(e) && is_inline_element(ei)) kill = 1;
if (strlcasecmp(e->name, e->namelen, name, namelen)) { if (strlcasecmp(e->name, e->namelen, name, namelen)) {
if (e->type < ELEMENT_KILLABLE) if (e->type < ELEMENT_KILLABLE)
break; break;