From 7a9109813591bd30bbfcaf933276b102be83f80b Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 22 Sep 2005 21:44:28 +0200 Subject: [PATCH] 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. --- src/document/html/parser.h | 2 ++ src/document/html/parser/parse.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/document/html/parser.h b/src/document/html/parser.h index 05f8dd556..88db5b574 100644 --- a/src/document/html/parser.h +++ b/src/document/html/parser.h @@ -140,6 +140,8 @@ struct html_element { ELEMENT_VISITED = 2, } pseudo_class; }; +#define is_inline_element(e) (e->linebreak == 0) +#define is_block_element(e) (e->linebreak > 0) enum html_special_type { SP_TAG, diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 0eb75c8f5..b4859701c 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -812,10 +812,10 @@ start_element(struct element_info *ei, if (ei->type == ELEMENT_TYPE_NON_NESTABLE) { foreach (e, html_context->stack) { 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) { - if (e->linebreak && !ei->linebreak) break; + if (is_block_element(e) && is_inline_element(ei)) break; if (e->type < ELEMENT_KILLABLE) 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); */ 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 (e->type < ELEMENT_KILLABLE) break;