summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2004-03-24 20:10:03 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2004-03-24 20:10:03 +0000
commitb2242ae0f01b9fa4d791c3c74ce2a6383c6d27b1 (patch)
tree963c92e582a9c8e91e4dddbb965cbb2ee6054a9e
parente944d395e0e12cc727a5ccb54e18afd4ffe4cf7c (diff)
downloadnetsurf-b2242ae0f01b9fa4d791c3c74ce2a6383c6d27b1.tar.gz
netsurf-b2242ae0f01b9fa4d791c3c74ce2a6383c6d27b1.tar.bz2
[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
-rw-r--r--render/html.c8
-rw-r--r--render/html.h1
-rw-r--r--riscos/save_complete.c18
3 files changed, 12 insertions, 15 deletions
diff --git a/render/html.c b/render/html.c
index 7e3fb834c..e028e523d 100644
--- a/render/html.c
+++ b/render/html.c
@@ -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)
diff --git a/render/html.h b/render/html.h
index 673e57317..d029a7554 100644
--- a/render/html.h
+++ b/render/html.h
@@ -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. */
diff --git a/riscos/save_complete.c b/riscos/save_complete.c
index 0738f2240..d63ceedf0 100644
--- a/riscos/save_complete.c
+++ b/riscos/save_complete.c
@@ -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);
}