diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-02-20 11:39:25 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-02-20 11:39:25 +0000 |
commit | cc1094f0ac62db0d736b6e41e219fe628d22a69e (patch) | |
tree | aaa69ff9929767133acc02c299c1a25c9540cddb /render/html.c | |
parent | 0619131f20ad86fe640ea9a1a45d3ae7bf73c1d8 (diff) | |
download | netsurf-cc1094f0ac62db0d736b6e41e219fe628d22a69e.tar.gz netsurf-cc1094f0ac62db0d736b6e41e219fe628d22a69e.tar.bz2 |
Utilise hubbub's form association callback.
Please can we dispense with the libxml binding? It's causing much #ifdef mess.
Fix encoding of <input type=image> names -- previously were output as raw utf-8, rather than in the submission charset.
Actually bother to destroy forms in a document, and the controls associated with them. We still leak non form-associated controls, but that's too much effort to fix right now.
svn path=/trunk/netsurf/; revision=6573
Diffstat (limited to 'render/html.c')
-rw-r--r-- | render/html.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/render/html.c b/render/html.c index 4063f67ad..91f55b145 100644 --- a/render/html.c +++ b/render/html.c @@ -38,6 +38,7 @@ #include "image/bitmap.h" #include "render/box.h" #include "render/font.h" +#include "render/form.h" #include "render/html.h" #include "render/imagemap.h" #include "render/layout.h" @@ -281,6 +282,9 @@ bool html_convert(struct content *c, int width, int height) xmlNode *html, *head; union content_msg_data msg_data; unsigned int time_before, time_taken; +#ifdef WITH_HUBBUB + struct form *f; +#endif /* finish parsing */ if (c->source_size == 0) { @@ -321,8 +325,6 @@ bool html_convert(struct content *c, int width, int height) c->data.html.document = binding_get_document(c->data.html.parser_binding); /*xmlDebugDumpDocument(stderr, c->data.html.document);*/ - binding_destroy_tree(c->data.html.parser_binding); - c->data.html.parser_binding = NULL; if (!c->data.html.document) { LOG(("Parsing failed")); @@ -364,6 +366,26 @@ bool html_convert(struct content *c, int width, int height) if (!html_find_stylesheets(c, html)) return false; +#ifdef WITH_HUBBUB + /* Retrieve forms from parser */ + c->data.html.forms = binding_get_forms(c->data.html.parser_binding); + /* Make all actions absolute */ + for (f = c->data.html.forms; f != NULL; f = f->prev) { + char *action; + url_func_result res; + + res = url_join(f->action, c->data.html.base_url, &action); + if (res != URL_FUNC_OK) { + msg_data.error = messages_get("NoMemory"); + content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + return false; + } + + free(f->action); + f->action = action; + } +#endif + /* convert xml tree to box tree */ LOG(("XML to box")); content_set_status(c, messages_get("Processing")); @@ -405,6 +427,10 @@ bool html_convert(struct content *c, int width, int height) c->reformat_time - wallclock())); /*box_dump(c->data.html.layout->children, 0);*/ + /* Destroy the parser binding */ + binding_destroy_tree(c->data.html.parser_binding); + c->data.html.parser_binding = NULL; + if (c->active == 0) c->status = CONTENT_STATUS_DONE; else @@ -1654,8 +1680,17 @@ void html_reformat(struct content *c, int width, int height) void html_destroy(struct content *c) { unsigned int i; + struct form *f, *g; + LOG(("content %p", c)); + /* Destroy forms */ + for (f = c->data.html.forms; f != NULL; f = g) { + g = f->prev; + + form_free(f); + } + imagemap_destroy(c); if (c->bitmap) { |