[project @ 2004-03-24 20:10:03 by jmb]

Remove need for XML parse tree to be kept in memory.
The source document is now reparsed when saving complete.

svn path=/import/netsurf/; revision=662
This commit is contained in:
John Mark Bell 2004-03-24 20:10:03 +00:00
parent e944d395e0
commit b2242ae0f0
3 changed files with 12 additions and 15 deletions

View File

@ -69,7 +69,6 @@ void html_create(struct content *c, const char *params[])
}
html->parser = htmlCreatePushParserCtxt(0, 0, "", 0, 0, html->encoding);
html->document = 0;
html->base_url = xstrdup(c->url);
html->layout = 0;
html->background_colour = TRANSPARENT;
@ -140,7 +139,7 @@ int html_convert(struct content *c, unsigned int width, unsigned int height)
/* finish parsing */
htmlParseChunk(c->data.html.parser, "", 0, 1);
document = c->data.html.document = c->data.html.parser->myDoc;
document = c->data.html.parser->myDoc;
/*xmlDebugDumpDocument(stderr, c->data.html.parser->myDoc);*/
htmlFreeParserCtxt(c->data.html.parser);
c->data.html.parser = 0;
@ -182,7 +181,7 @@ int html_convert(struct content *c, unsigned int width, unsigned int height)
/*box_dump(c->data.html.layout->children, 0);*/
/* XML tree not required past this point */
//xmlFreeDoc(document);
xmlFreeDoc(document);
/* layout the box tree */
sprintf(c->status_message, messages_get("Formatting"));
@ -756,9 +755,6 @@ void html_destroy(struct content *c)
if (c->data.html.parser)
htmlFreeParserCtxt(c->data.html.parser);
if (c->data.html.document)
xmlFreeDoc(c->data.html.document);
free(c->data.html.base_url);
if (c->data.html.layout)

View File

@ -36,7 +36,6 @@ struct box_position {
/** Data specific to CONTENT_HTML. */
struct content_html_data {
htmlParserCtxt *parser; /**< HTML parser context. */
xmlDoc *document; /**< the XML document tree */
xmlCharEncoding encoding; /**< Encoding of source. */
bool getenc; /**< Need to get the encoding from the document, as server is broken. */

View File

@ -58,7 +58,7 @@ void save_complete(struct content *c) {
unsigned int i;
struct url_entry urls = {0, 0, 0, 0}; /* sentinel at head */
struct url_entry *object;
xmlDoc *toSave;
htmlParserCtxtPtr toSave;
if (c->type != CONTENT_HTML)
return;
@ -136,26 +136,28 @@ void save_complete(struct content *c) {
}
/* make a copy of the document tree */
toSave = xmlCopyDoc(c->data.html.document, 1);
if (!toSave) {
toSave = htmlCreateMemoryParserCtxt(c->source_data, c->source_size);
if (htmlParseDocument(toSave) == -1) {
htmlFreeParserCtxt(toSave);
xfree(spath);
return;
}
/* rewrite all urls we know about */
if (rewrite_document_urls(toSave, &urls, fname) == 0) {
if (rewrite_document_urls(toSave->myDoc, &urls, fname) == 0) {
xfree(spath);
xmlFreeDoc(toSave);
xmlFreeDoc(toSave->myDoc);
htmlFreeParserCtxt(toSave);
return;
}
/* save the html file out last of all */
sprintf(spath, "%s%s", SAVE_PATH, fname);
htmlSaveFile(spath, toSave);
htmlSaveFile(spath, toSave->myDoc);
xosfile_set_type(spath, 0xfaf);
xmlFreeDoc(toSave);
xmlFreeDoc(toSave->myDoc);
htmlFreeParserCtxt(toSave);
xfree(spath);
//xfree(fname);
}