summaryrefslogtreecommitdiff
path: root/src/html
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-07 16:28:04 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-07-07 16:29:28 +0100
commit3ef2a1413de900aa096887bfbf7e6447c41c668a (patch)
tree611bc7db26cecf9570cc71aa41f6a56fbd19c873 /src/html
parentaa8a5b2dc324a9c25f3cde9316060d0c411ca4c2 (diff)
downloadlibdom-3ef2a1413de900aa096887bfbf7e6447c41c668a.tar.gz
libdom-3ef2a1413de900aa096887bfbf7e6447c41c668a.tar.bz2
HTMLFormElement: Initial support, 2 tests now pass
Diffstat (limited to 'src/html')
-rw-r--r--src/html/html_document.c6
-rw-r--r--src/html/html_form_element.c34
-rw-r--r--src/html/html_form_element.h2
3 files changed, 31 insertions, 11 deletions
diff --git a/src/html/html_document.c b/src/html/html_document.c
index 11ee899..288de82 100644
--- a/src/html/html_document.c
+++ b/src/html/html_document.c
@@ -14,6 +14,7 @@
#include "html/html_html_element.h"
#include "html/html_head_element.h"
#include "html/html_title_element.h"
+#include "html/html_form_element.h"
#include "core/string.h"
#include "utils/namespace.h"
@@ -176,6 +177,11 @@ _dom_html_document_create_element_internal(dom_html_document *html,
(dom_html_title_element **) result);
}
+ if (dom_string_caseless_isequal(tag_name, html->memoised[hds_FORM])) {
+ return _dom_html_form_element_create(html, namespace, prefix,
+ (dom_html_form_element **) result);
+ }
+
return _dom_html_element_create(html, tag_name, namespace, prefix,
result);
}
diff --git a/src/html/html_form_element.c b/src/html/html_form_element.c
index b24a08e..83af37a 100644
--- a/src/html/html_form_element.c
+++ b/src/html/html_form_element.c
@@ -33,6 +33,7 @@ static bool _dom_is_form_control(struct dom_node_internal *node);
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_form_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_form_element **ele)
{
struct dom_node_internal *node;
@@ -43,10 +44,10 @@ dom_exception _dom_html_form_element_create(struct dom_html_document *doc,
/* Set up vtables */
node = (struct dom_node_internal *) *ele;
- node->base.vtable = &_dom_element_vtable;
+ node->base.vtable = &_dom_html_element_vtable;
node->vtable = &_protect_vtable;
- return _dom_html_form_element_initialise(doc, *ele);
+ return _dom_html_form_element_initialise(doc, namespace, prefix, *ele);
}
/**
@@ -57,18 +58,15 @@ dom_exception _dom_html_form_element_create(struct dom_html_document *doc,
* \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
dom_exception _dom_html_form_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_form_element *ele)
{
- dom_string *name = NULL;
dom_exception err;
- err = dom_string_create((const uint8_t *) "FORM", SLEN("FORM"), &name);
- if (err != DOM_NO_ERR)
- return err;
+ err = _dom_html_element_initialise(doc, &ele->base,
+ doc->memoised[hds_FORM],
+ namespace, prefix);
- err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL);
- dom_string_unref(name);
-
ele->col = NULL;
return err;
@@ -231,11 +229,25 @@ dom_exception dom_html_form_element_reset(dom_html_form_element *ele)
* src/html/html_collection.h for detail. */
static bool _dom_is_form_control(struct dom_node_internal *node)
{
- UNUSED(node);
+ struct dom_html_document *doc =
+ (struct dom_html_document *)(node->owner);
assert(node->type == DOM_ELEMENT_NODE);
- /** \todo: implement */
+ /* Form controls are INPUT TEXTAREA SELECT and BUTTON */
+ if (dom_string_caseless_isequal(node->name,
+ doc->memoised[hds_INPUT]))
+ return true;
+ if (dom_string_caseless_isequal(node->name,
+ doc->memoised[hds_TEXTAREA]))
+ return true;
+ if (dom_string_caseless_isequal(node->name,
+ doc->memoised[hds_SELECT]))
+ return true;
+ if (dom_string_caseless_isequal(node->name,
+ doc->memoised[hds_BUTTON]))
+ return true;
+
return false;
}
diff --git a/src/html/html_form_element.h b/src/html/html_form_element.h
index dbf6267..1ee9878 100644
--- a/src/html/html_form_element.h
+++ b/src/html/html_form_element.h
@@ -23,10 +23,12 @@ struct dom_html_form_element {
/* Create a dom_html_form_element object */
dom_exception _dom_html_form_element_create(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_form_element **ele);
/* Initialise a dom_html_form_element object */
dom_exception _dom_html_form_element_initialise(struct dom_html_document *doc,
+ dom_string *namespace, dom_string *prefix,
struct dom_html_form_element *ele);
/* Finalise a dom_html_form_element object */