summaryrefslogtreecommitdiff
path: root/src/html/html_form_element.c
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/html_form_element.c
parentaa8a5b2dc324a9c25f3cde9316060d0c411ca4c2 (diff)
downloadlibdom-3ef2a1413de900aa096887bfbf7e6447c41c668a.tar.gz
libdom-3ef2a1413de900aa096887bfbf7e6447c41c668a.tar.bz2
HTMLFormElement: Initial support, 2 tests now pass
Diffstat (limited to 'src/html/html_form_element.c')
-rw-r--r--src/html/html_form_element.c34
1 files changed, 23 insertions, 11 deletions
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;
}