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

DOM: Factor get_doctype out of render_dom_document.

This commit is contained in:
Miciah Dashiel Butler Masters 2006-05-06 05:03:39 +00:00 committed by Miciah Dashiel Butler Masters
parent f925adbfc9
commit 36e7044948

View File

@ -975,6 +975,31 @@ static struct dom_stack_context_info dom_rss_renderer_context_info = {
};
static void
get_doctype(struct dom_renderer *renderer, struct cache_entry *cached)
{
if (!strcasecmp("application/rss+xml", cached->content_type)) {
renderer->doctype = SGML_DOCTYPE_RSS;
} else if (!strcasecmp("application/docbook+xml",
cached->content_type)) {
renderer->doctype = SGML_DOCTYPE_DOCBOOK;
} else if (!strcasecmp("application/xbel+xml", cached->content_type)
|| !strcasecmp("application/x-xbel", cached->content_type)
|| !strcasecmp("application/xbel", cached->content_type)) {
renderer->doctype = SGML_DOCTYPE_XBEL;
} else {
assertm(!strcasecmp("text/html", cached->content_type)
|| !strcasecmp("application/xhtml+xml",
cached->content_type),
"Couldn't resolve doctype '%s'", cached->content_type);
renderer->doctype = SGML_DOCTYPE_HTML;
}
}
/* Shared multiplexor between renderers */
void
render_dom_document(struct cache_entry *cached, struct document *document,
@ -1005,25 +1030,7 @@ render_dom_document(struct cache_entry *cached, struct document *document,
else
parser_type = SGML_PARSER_TREE;
/* FIXME: Refactor the doctype lookup. */
if (!strcasecmp("application/rss+xml", cached->content_type)) {
renderer.doctype = SGML_DOCTYPE_RSS;
} else if (!strcasecmp("application/docbook+xml", cached->content_type)) {
renderer.doctype = SGML_DOCTYPE_DOCBOOK;
} else if (!strcasecmp("application/xbel+xml", cached->content_type)
|| !strcasecmp("application/x-xbel", cached->content_type)
|| !strcasecmp("application/xbel", cached->content_type)) {
renderer.doctype = SGML_DOCTYPE_XBEL;
} else {
assertm(!strcasecmp("text/html", cached->content_type)
|| !strcasecmp("application/xhtml+xml", cached->content_type),
"Couldn't resolve doctype '%s'", cached->content_type);
renderer.doctype = SGML_DOCTYPE_HTML;
}
get_doctype(&renderer, cached);
parser = init_sgml_parser(parser_type, renderer.doctype, &uri, 0);
if (!parser) return;