1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-07-07 13:34:34 -04:00

Replace special handling in end_element with callbacks

Add close callbacks html_html_close, html_style_close, and
html_xmp_close. end_element now calls the element close callback instead
of performing special handling for certain tags.
This commit is contained in:
Miciah Dashiel Butler Masters 2006-05-27 03:29:49 +00:00 committed by Miciah Dashiel Butler Masters
parent 0f2982aa5d
commit 6947902b57
3 changed files with 30 additions and 11 deletions

View File

@ -357,6 +357,13 @@ html_style(struct html_context *html_context, unsigned char *a,
html_skip(html_context, a);
}
void
html_style_close(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
html_context->was_style = 0;
}
void
html_html(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
@ -371,6 +378,15 @@ html_html(struct html_context *html_context, unsigned char *a,
e->parattr.bgcolor = e->attr.style.bg = par_format.bgcolor = format.style.bg;
}
void
html_html_close(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
{
if (html_top->type >= ELEMENT_KILLABLE
&& !html_context->was_body_background)
html_apply_canvas_bgcolor(html_context);
}
void
html_head(struct html_context *html_context, unsigned char *a,
unsigned char *xxx3, unsigned char *xxx4, unsigned char **xxx5)
@ -561,6 +577,13 @@ html_xmp(struct html_context *html_context, unsigned char *a,
html_pre(html_context, a, html, eof, end);
}
void
html_xmp_close(struct html_context *html_context, unsigned char *a,
unsigned char *html, unsigned char *eof, unsigned char **end)
{
html_context->was_xmp = 0;
}
void
html_hr(struct html_context *html_context, unsigned char *a,
unsigned char *html, unsigned char *eof, unsigned char **end)

View File

@ -26,6 +26,7 @@ element_handler_T html_h5;
element_handler_T html_h6;
element_handler_T html_head;
element_handler_T html_html;
element_handler_T html_html_close;
element_handler_T html_hr;
element_handler_T html_italic;
element_handler_T html_li;
@ -39,6 +40,7 @@ element_handler_T html_pre;
element_handler_T html_script;
element_handler_T html_span;
element_handler_T html_style;
element_handler_T html_style_close;
element_handler_T html_subscript;
element_handler_T html_superscript;
element_handler_T html_table;
@ -50,6 +52,7 @@ element_handler_T html_tt;
element_handler_T html_ul;
element_handler_T html_underline;
element_handler_T html_xmp;
element_handler_T html_xmp_close;
void html_apply_canvas_bgcolor(struct html_context *);
void html_handle_body_meta(struct html_context *, unsigned char *, unsigned char *);

View File

@ -455,7 +455,7 @@ static struct element_info elements[] = {
{"H6", html_h6, NULL, 2, ET_NON_NESTABLE},
{"HEAD", html_head, NULL, 0, ET_NESTABLE },
{"HR", html_hr, NULL, 2, ET_NON_PAIRABLE},
{"HTML", html_html, NULL, 0, ET_NESTABLE },
{"HTML", html_html, html_html_close, 0, ET_NESTABLE },
{"I", html_italic, NULL, 0, ET_NESTABLE },
{"IFRAME", html_iframe, NULL, 1, ET_NON_PAIRABLE},
{"IMG", html_img, NULL, 0, ET_NON_PAIRABLE},
@ -479,7 +479,7 @@ static struct element_info elements[] = {
{"SPAN", html_span, NULL, 0, ET_NESTABLE },
{"STRIKE", html_underline, NULL, 0, ET_NESTABLE },
{"STRONG", html_bold, NULL, 0, ET_NESTABLE },
{"STYLE", html_style, NULL, 0, ET_NESTABLE },
{"STYLE", html_style, html_style_close, 0, ET_NESTABLE },
{"SUB", html_subscript, NULL, 0, ET_NESTABLE },
{"SUP", html_superscript, NULL, 0, ET_NESTABLE },
{"TABLE", html_table, NULL, 2, ET_NESTABLE },
@ -491,7 +491,7 @@ static struct element_info elements[] = {
{"TT", html_tt, NULL, 0, ET_NON_NESTABLE},
{"U", html_underline, NULL, 0, ET_NESTABLE },
{"UL", html_ul, NULL, 2, ET_NESTABLE },
{"XMP", html_xmp, NULL, 2, ET_NESTABLE },
{"XMP", html_xmp, html_xmp_close, 2, ET_NESTABLE },
{NULL, NULL, NULL, 0, ET_NESTABLE },
};
@ -908,14 +908,7 @@ end_element(struct element_info *ei,
if (ei->type == ET_NON_PAIRABLE || ei->type == ET_LI)
return html;
if (ei->open == html_xmp) html_context->was_xmp = 0;
if (ei->open == html_style) html_context->was_style = 0;
/* Apply background color from the <HTML> element. (bug 696) */
if (ei->open == html_html
&& html_top->type >= ELEMENT_KILLABLE
&& !html_context->was_body_background)
html_apply_canvas_bgcolor(html_context);
if (ei->close) ei->close(html_context, attr, html, eof, &html);
/* dump_html_stack(html_context); */
foreach (e, html_context->stack) {