1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -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 */ /* Shared multiplexor between renderers */
void void
render_dom_document(struct cache_entry *cached, struct document *document, render_dom_document(struct cache_entry *cached, struct document *document,
@ -1005,28 +1030,10 @@ render_dom_document(struct cache_entry *cached, struct document *document,
else else
parser_type = SGML_PARSER_TREE; parser_type = SGML_PARSER_TREE;
/* FIXME: Refactor the doctype lookup. */ get_doctype(&renderer, 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;
}
parser = init_sgml_parser(parser_type, renderer.doctype, &uri, 0); parser = init_sgml_parser(parser_type, renderer.doctype, &uri, 0);
if (!parser) return; if (!parser) return;
if (document->options.plain) { if (document->options.plain) {
add_dom_stack_context(&parser->stack, &renderer, add_dom_stack_context(&parser->stack, &renderer,