summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-10 23:13:08 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-03-10 23:13:08 +0000
commitb9e22451c25286da77b2da843fbb7d62eea3cb89 (patch)
treecb2864f10489e2aa2c044ff68371d2d02187873a /render
parent72f99e36bb9d26e3de3112f740d58350e47f62d3 (diff)
downloadnetsurf-b9e22451c25286da77b2da843fbb7d62eea3cb89.tar.gz
netsurf-b9e22451c25286da77b2da843fbb7d62eea3cb89.tar.bz2
Sync hubbub binding with spec.
svn path=/trunk/netsurf/; revision=6769
Diffstat (limited to 'render')
-rw-r--r--render/hubbub_binding.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/render/hubbub_binding.c b/render/hubbub_binding.c
index b674d011c..7d06dd02a 100644
--- a/render/hubbub_binding.c
+++ b/render/hubbub_binding.c
@@ -502,6 +502,13 @@ int append_child(void *ctx, void *parent, void *child, void **result)
xmlNode *chld = (xmlNode *) child;
xmlNode *p = (xmlNode *) parent;
+ /** \todo Text node merging logic as per
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/ \
+ * tree-construction.html#insert-a-character
+ *
+ * Doesn't actually matter for us until we have scripting. Thus,
+ * this is something which can wait until libdom.
+ */
if (chld->type == XML_TEXT_NODE && p->last != NULL &&
p->last->type == XML_TEXT_NODE) {
/* Need to clone the child, as libxml will free it if it
@@ -632,17 +639,42 @@ int form_associate(void *ctx, void *form, void *node)
xmlNode *n = (xmlNode *) node;
struct form *f;
struct form_control *control = NULL;
-
- /* Find form object to associate with */
+ xmlChar *id = NULL;
+
+ /* Find form object to associate with:
+ *
+ * 1) If node possesses an @form, use the form with a matching @id
+ * 2) Otherwise, use the form provided
+ */
+ id = xmlGetProp(n, (const xmlChar *) "form");
for (f = c->forms; f != NULL; f = f->prev) {
- if (f->node == form)
+ if (id == NULL && f->node == form) {
break;
+ } else if (id != NULL) {
+ xmlNode *fn = (xmlNode *) f->node;
+ xmlChar *fid = xmlGetProp(fn, (const xmlChar *) "id");
+
+ if (fid != NULL && strcmp((char *) id,
+ (char *) fid) == 0) {
+ xmlFree(fid);
+ break;
+ } else if (fid != NULL) {
+ xmlFree(fid);
+ }
+ }
}
+ if (id != NULL)
+ xmlFree(id);
/* None found -- give up */
if (f == NULL)
return 0;
+ /* Will be one of: button, fieldset, input, label,
+ * output, select, textarea.
+ *
+ * We ignore fieldset, label and output.
+ */
if (strcasecmp((const char *) n->name, "input") == 0) {
control = parse_input_element(n);
} else if (strcasecmp((const char *) n->name, "button") == 0) {