summaryrefslogtreecommitdiff
path: root/src/html/html_document.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2012-03-25 13:56:41 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2012-03-25 13:56:41 +0000
commita806c79feb31ff08ec7ff8b9c34eac77327e7758 (patch)
tree8f11fc3a6b70278bb9a0d0a1b099322615e50455 /src/html/html_document.c
parent5a2abb5987f4eab9d1ca06bb558b17494fa7974f (diff)
downloadlibdom-a806c79feb31ff08ec7ff8b9c34eac77327e7758.tar.gz
libdom-a806c79feb31ff08ec7ff8b9c34eac77327e7758.tar.bz2
Implement html_document_get_forms
svn path=/trunk/libdom/; revision=13687
Diffstat (limited to 'src/html/html_document.c')
-rw-r--r--src/html/html_document.c42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 52c6eca..607bbaf 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -10,6 +10,7 @@
#include "html/html_document.h"
#include "html/html_element.h"
+#include "html/html_collection.h"
#include "core/string.h"
#include "utils/namespace.h"
@@ -309,13 +310,48 @@ dom_exception _dom_html_document_get_links(dom_html_document *doc,
return DOM_NOT_SUPPORTED_ERR;
}
+static bool __dom_html_document_node_is_form(dom_node_internal *node)
+{
+ dom_string *form;
+ dom_exception err;
+
+ err = dom_string_create_interned((const uint8_t *) "form",
+ SLEN("form"), &form);
+ if (err == DOM_NO_ERR) {
+ if (dom_string_caseless_isequal(node->name, form)) {
+ dom_string_unref(form);
+ return true;
+ }
+
+ dom_string_unref(form);
+ }
+
+ return false;
+}
+
dom_exception _dom_html_document_get_forms(dom_html_document *doc,
struct dom_html_collection **col)
{
- UNUSED(doc);
- UNUSED(col);
+ dom_html_collection *result;
+ dom_element *root;
+ dom_exception err;
- return DOM_NOT_SUPPORTED_ERR;
+ err = dom_document_get_document_element(doc, &root);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_html_collection_create(doc, (dom_node_internal *) root,
+ __dom_html_document_node_is_form, &result);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref(root);
+ return err;
+ }
+
+ dom_node_unref(root);
+
+ *col = result;
+
+ return DOM_NO_ERR;
}
dom_exception _dom_html_document_get_anchors(dom_html_document *doc,