From 12a34ebfb1791c1ca7f09f24a0e56be4530fdfc6 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Wed, 8 Aug 2012 10:56:53 +0100 Subject: Mostly implement HTMLOptionElement, HTMLSelectElement. Enable HTMLOptionElement tests that pass. --- bindings/hubbub/parser.c | 12 +- include/dom/dom.h | 2 + include/dom/html/html_option_element.h | 52 ++- include/dom/html/html_select_element.h | 34 +- src/html/Makefile | 4 +- src/html/html_collection.c | 4 +- src/html/html_document.c | 8 + src/html/html_document_strings.h | 7 + src/html/html_option_element.c | 359 +++++++++++++++++- src/html/html_option_element.h | 49 ++- src/html/html_options_collection.c | 68 +++- src/html/html_select_element.c | 406 ++++++++++++++++++--- src/html/html_select_element.h | 11 +- .../tests/level1/html/HTMLOptionElement01.xml | 45 +++ .../level1/html/HTMLOptionElement01.xml.kfail | 45 --- .../tests/level1/html/HTMLOptionElement02.xml | 44 +++ .../level1/html/HTMLOptionElement02.xml.kfail | 44 --- .../tests/level1/html/HTMLOptionElement03.xml | 44 +++ .../level1/html/HTMLOptionElement03.xml.kfail | 44 --- .../tests/level1/html/HTMLOptionElement04.xml | 43 +++ .../level1/html/HTMLOptionElement04.xml.kfail | 43 --- .../tests/level1/html/HTMLOptionElement06.xml | 44 +++ .../level1/html/HTMLOptionElement06.xml.kfail | 44 --- .../tests/level1/html/HTMLOptionElement07.xml | 44 +++ .../level1/html/HTMLOptionElement07.xml.kfail | 44 --- .../tests/level1/html/HTMLOptionElement08.xml | 44 +++ .../level1/html/HTMLOptionElement08.xml.kfail | 44 --- .../tests/level1/html/HTMLOptionElement09.xml | 43 +++ .../level1/html/HTMLOptionElement09.xml.kfail | 43 --- 29 files changed, 1292 insertions(+), 426 deletions(-) create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement01.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement01.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement02.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement02.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement03.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement03.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement04.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement04.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement06.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement06.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement07.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement07.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement08.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement08.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLOptionElement09.xml delete mode 100644 test/testcases/tests/level1/html/HTMLOptionElement09.xml.kfail diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c index 6174823..8296fe8 100644 --- a/bindings/hubbub/parser.c +++ b/bindings/hubbub/parser.c @@ -26,6 +26,7 @@ #include "html/html_document.h" #include "html/html_button_element.h" #include "html/html_input_element.h" +#include "html/html_select_element.h" #include "html/html_text_area_element.h" #include @@ -495,6 +496,15 @@ static hubbub_error form_associate(void *parser, void *form, void *node) "Error in form_associate"); return HUBBUB_UNKNOWN; } + } else if (dom_string_caseless_isequal(ele->name, + doc->memoised[hds_SELECT])) { + err = _dom_html_select_element_set_form( + (dom_html_select_element *)node, form_ele); + if (err != DOM_NO_ERR) { + dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx, + "Error in form_associate"); + return HUBBUB_UNKNOWN; + } } else if (dom_string_caseless_isequal(ele->name, doc->memoised[hds_TEXTAREA])) { err = _dom_html_text_area_element_set_form( @@ -505,7 +515,7 @@ static hubbub_error form_associate(void *parser, void *form, void *node) return HUBBUB_UNKNOWN; } } - + return HUBBUB_OK; } diff --git a/include/dom/dom.h b/include/dom/dom.h index b68085a..f9d8817 100644 --- a/include/dom/dom.h +++ b/include/dom/dom.h @@ -52,6 +52,8 @@ #include #include #include +#include +#include /* DOM Events header */ #include diff --git a/include/dom/html/html_option_element.h b/include/dom/html/html_option_element.h index 2e182d5..53ba286 100644 --- a/include/dom/html/html_option_element.h +++ b/include/dom/html/html_option_element.h @@ -2,6 +2,56 @@ * This file is part of libdom. * Licensed under the MIT License, * http://www.opensource.org/licenses/mit-license.php - * Copyright 2009 Bo Yang + * Copyright 2012 John-Mark Bell */ +#ifndef dom_html_option_element_h_ +#define dom_html_option_element_h_ + +#include +#include +#include +#include + +typedef struct dom_html_option_element dom_html_option_element; + +dom_exception dom_html_option_element_get_form( + dom_html_option_element *option, dom_html_form_element **form); + +dom_exception dom_html_option_element_get_default_selected( + dom_html_option_element *option, bool *default_selected); + +dom_exception dom_html_option_element_set_default_selected( + dom_html_option_element *option, bool default_selected); + +dom_exception dom_html_option_element_get_text( + dom_html_option_element *option, dom_string **text); + +dom_exception dom_html_option_element_get_index( + dom_html_option_element *option, unsigned long *index); + +dom_exception dom_html_option_element_get_disabled( + dom_html_option_element *option, bool *disabled); + +dom_exception dom_html_option_element_set_disabled( + dom_html_option_element *option, bool disabled); + +dom_exception dom_html_option_element_get_label( + dom_html_option_element *option, dom_string **label); + +dom_exception dom_html_option_element_set_label( + dom_html_option_element *option, dom_string *label); + +dom_exception dom_html_option_element_get_selected( + dom_html_option_element *option, bool *selected); + +dom_exception dom_html_option_element_set_selected( + dom_html_option_element *option, bool selected); + +dom_exception dom_html_option_element_get_value( + dom_html_option_element *option, dom_string **value); + +dom_exception dom_html_option_element_set_value( + dom_html_option_element *option, dom_string *value); + +#endif diff --git a/include/dom/html/html_select_element.h b/include/dom/html/html_select_element.h index 10c002a..89b6844 100644 --- a/include/dom/html/html_select_element.h +++ b/include/dom/html/html_select_element.h @@ -12,44 +12,70 @@ #include +#include + typedef struct dom_html_select_element dom_html_select_element; struct dom_html_options_collection; struct dom_html_element; +dom_exception dom_html_select_element_get_type( + dom_html_select_element *ele, dom_string **type); + dom_exception dom_html_select_element_get_selected_index( dom_html_select_element *ele, unsigned long *index); dom_exception dom_html_select_element_set_selected_index( dom_html_select_element *ele, unsigned long index); + +dom_exception dom_html_select_element_get_value( + dom_html_select_element *ele, dom_string **value); +dom_exception dom_html_select_element_set_value( + dom_html_select_element *ele, dom_string *value); + dom_exception dom_html_select_element_get_length( dom_html_select_element *ele, unsigned long *len); dom_exception dom_html_select_element_set_length( dom_html_select_element *ele, unsigned long len); + +dom_exception dom_html_select_element_get_form( + dom_html_select_element *ele, dom_html_form_element **form); + dom_exception dom_html_select_element_get_options( dom_html_select_element *ele, struct dom_html_options_collection **col); + dom_exception dom_html_select_element_get_disabled( dom_html_select_element *ele, bool *disabled); dom_exception dom_html_select_element_set_disabled( dom_html_select_element *ele, bool disabled); + dom_exception dom_html_select_element_get_multiple( dom_html_select_element *ele, bool *multiple); dom_exception dom_html_select_element_set_multiple( dom_html_select_element *ele, bool multiple); + +dom_exception dom_html_select_element_get_name( + dom_html_select_element *ele, dom_string **name); +dom_exception dom_html_select_element_set_name( + dom_html_select_element *ele, dom_string *name); + dom_exception dom_html_select_element_get_size( dom_html_select_element *ele, unsigned long *size); dom_exception dom_html_select_element_set_size( dom_html_select_element *ele, unsigned long size); + dom_exception dom_html_select_element_get_tab_index( dom_html_select_element *ele, unsigned long *tab_index); dom_exception dom_html_select_element_set_tab_index( dom_html_select_element *ele, unsigned long tab_index); /* Functions */ -dom_exception dom_html_select_element_add(struct dom_html_element *ele, - struct dom_html_element *before); -dom_exception dom_html_element_blur(struct dom_html_select_element *ele); -dom_exception dom_html_element_focus(struct dom_html_select_element *ele); +dom_exception dom_html_select_element_add(dom_html_select_element *select, + struct dom_html_element *ele, struct dom_html_element *before); +dom_exception dom_html_select_element_remove(dom_html_select_element *ele, + long index); +dom_exception dom_html_select_element_blur(struct dom_html_select_element *ele); +dom_exception dom_html_select_element_focus(struct dom_html_select_element *ele); #endif diff --git a/src/html/Makefile b/src/html/Makefile index 3001c59..4e1b4c4 100644 --- a/src/html/Makefile +++ b/src/html/Makefile @@ -6,9 +6,9 @@ DIR_SOURCES := \ html_base_element.c html_isindex_element.c html_style_element.c \ html_body_element.c html_form_element.c html_select_element.c \ html_button_element.c html_input_element.c html_text_area_element.c \ - html_opt_group_element.c + html_opt_group_element.c html_option_element.c -UNINMPLEMENTED_SOURCES := html_option_element.c \ +UNINMPLEMENTED_SOURCES := \ html_label_element.c html_fieldset_element.c \ html_legend_element.c html_ulist_element.c html_olist_element.c \ html_dlist_element.c html_directory_element.c html_menu_element.c \ diff --git a/src/html/html_collection.c b/src/html/html_collection.c index 1e43940..f180286 100644 --- a/src/html/html_collection.c +++ b/src/html/html_collection.c @@ -214,9 +214,7 @@ dom_exception dom_html_collection_named_item(dom_html_collection *col, struct dom_node_internal *n = col->root; dom_exception err; - while (*node != NULL) { - assert(n != NULL); - + while (n != NULL) { if (n->type == DOM_ELEMENT_NODE && col->ic(n, col->ctx) == true) { dom_string *id = NULL; diff --git a/src/html/html_document.c b/src/html/html_document.c index ffc2e1c..7f29a5d 100644 --- a/src/html/html_document.c +++ b/src/html/html_document.c @@ -22,6 +22,8 @@ #include "html/html_input_element.h" #include "html/html_text_area_element.h" #include "html/html_opt_group_element.h" +#include "html/html_option_element.h" +#include "html/html_select_element.h" #include "core/string.h" #include "utils/namespace.h" @@ -210,6 +212,12 @@ _dom_html_document_create_element_internal(dom_html_document *html, } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_OPTGROUP])) { exc = _dom_html_opt_group_element_create(html, namespace, prefix, (dom_html_opt_group_element **) result); + } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_OPTION])) { + exc = _dom_html_option_element_create(html, namespace, prefix, + (dom_html_option_element **) result); + } else if (dom_string_caseless_isequal(tag_name, html->memoised[hds_SELECT])) { + exc = _dom_html_select_element_create(html, namespace, prefix, + (dom_html_select_element **) result); } else { exc = _dom_html_element_create(html, tag_name, namespace, prefix, result); diff --git a/src/html/html_document_strings.h b/src/html/html_document_strings.h index bd33866..fa9c4e4 100644 --- a/src/html/html_document_strings.h +++ b/src/html/html_document_strings.h @@ -88,6 +88,13 @@ HTML_DOCUMENT_STRINGS_ACTION(use_map,usemap) HTML_DOCUMENT_STRINGS_ACTION1(textarea) /* HTMLOptGroupElement attributes */ HTML_DOCUMENT_STRINGS_ACTION1(label) +/* HTMLOptionElement attributes */ +/* HTML_DOCUMENT_STRINGS_ACTION1(label) */ +HTML_DOCUMENT_STRINGS_ACTION1(selected) +/* HTML_DOCUMENT_STRINGS_ACTION1(value) */ +/* HTMLSelectElement strings */ +HTML_DOCUMENT_STRINGS_ACTION(select_multiple,select-multiple) +HTML_DOCUMENT_STRINGS_ACTION(select_one,select-one) /* Names for elements which get specialised. */ HTML_DOCUMENT_STRINGS_ACTION1(HTML) HTML_DOCUMENT_STRINGS_ACTION1(HEAD) diff --git a/src/html/html_option_element.c b/src/html/html_option_element.c index 2e182d5..1584bac 100644 --- a/src/html/html_option_element.c +++ b/src/html/html_option_element.c @@ -2,6 +2,363 @@ * This file is part of libdom. * Licensed under the MIT License, * http://www.opensource.org/licenses/mit-license.php - * Copyright 2009 Bo Yang + * Copyright 2012 John-Mark Bell */ +#include +#include + +#include +#include + +#include "html/html_document.h" +#include "html/html_option_element.h" + +#include "core/node.h" +#include "core/attr.h" +#include "utils/utils.h" + +static struct dom_element_protected_vtable _protect_vtable = { + { + DOM_NODE_PROTECT_VTABLE_HTML_OPTION_ELEMENT + }, + DOM_HTML_OPTION_ELEMENT_PROTECT_VTABLE +}; + +/** + * Create a dom_html_option_element object + * + * \param doc The document object + * \param ele The returned element object + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception _dom_html_option_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, + struct dom_html_option_element **ele) +{ + struct dom_node_internal *node; + + *ele = malloc(sizeof(dom_html_option_element)); + if (*ele == NULL) + return DOM_NO_MEM_ERR; + + /* Set up vtables */ + node = (struct dom_node_internal *) *ele; + node->base.vtable = &_dom_html_element_vtable; + node->vtable = &_protect_vtable; + + return _dom_html_option_element_initialise(doc, namespace, prefix, *ele); +} + +/** + * Initialise a dom_html_option_element object + * + * \param doc The document object + * \param ele The dom_html_option_element object + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception _dom_html_option_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, + struct dom_html_option_element *ele) +{ + ele->default_selected = false; + ele->default_selected_set = false; + + return _dom_html_element_initialise(doc, &ele->base, + doc->memoised[hds_OPTION], + namespace, prefix); +} + +/** + * Finalise a dom_html_option_element object + * + * \param ele The dom_html_option_element object + */ +void _dom_html_option_element_finalise(struct dom_html_option_element *ele) +{ + _dom_html_element_finalise(&ele->base); +} + +/** + * Destroy a dom_html_option_element object + * + * \param ele The dom_html_option_element object + */ +void _dom_html_option_element_destroy(struct dom_html_option_element *ele) +{ + _dom_html_option_element_finalise(ele); + free(ele); +} + +/*-----------------------------------------------------------------------*/ +/* Public APIs */ + +dom_exception dom_html_option_element_get_form( + dom_html_option_element *option, dom_html_form_element **form) +{ + dom_html_document *doc; + dom_node_internal *select = ((dom_node_internal *) option)->parent; + + doc = (dom_html_document *) ((dom_node_internal *) option)->owner; + + /* Search ancestor chain for SELECT element */ + while (select != NULL) { + if (select->type == DOM_ELEMENT_NODE && + dom_string_caseless_isequal(select->name, + doc->memoised[hds_SELECT])) + break; + + select = select->parent; + } + + if (select != NULL) { + return dom_html_select_element_get_form((dom_html_select_element *) select, + form); + } + + *form = NULL; + + return DOM_NO_ERR; +} + +/** + * Get the defaultSelected property + * + * \param option The dom_html_option_element object + * \param default_selected Pointer to location to receive value + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_get_default_selected( + dom_html_option_element *option, bool *default_selected) +{ + *default_selected = option->default_selected; + + return DOM_NO_ERR; +} + +/** + * Set the defaultSelected property + * + * \param option The dom_html_option_element object + * \param default_selected New value for property + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_set_default_selected( + dom_html_option_element *option, bool default_selected) +{ + option->default_selected = default_selected; + option->default_selected_set = true; + + return DOM_NO_ERR; +} + +/** + * Get the text contained in the option + * + * \param option The dom_html_option_element object + * \param text Pointer to location to receive text + * \return DOM_NO_ERR on success, appropriate error otherwise + */ +dom_exception dom_html_option_element_get_text( + dom_html_option_element *option, dom_string **text) +{ + return dom_node_get_text_content(option, text); +} + +/** + * Obtain the index of this option in its parent + * + * \param option The dom_html_option_element object + * \param index Pointer to receive zero-based index + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_get_index( + dom_html_option_element *option, unsigned long *index) +{ + UNUSED(option); + UNUSED(index); + + /** \todo Implement */ + return DOM_NOT_SUPPORTED_ERR; +} + +/** + * Get the disabled property + * + * \param ele The dom_html_option_element object + * \param disabled The returned status + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception dom_html_option_element_get_disabled(dom_html_option_element *ele, + bool *disabled) +{ + return dom_html_element_get_bool_property(&ele->base, "disabled", + SLEN("disabled"), disabled); +} + +/** + * Set the disabled property + * + * \param ele The dom_html_option_element object + * \param disabled The status + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception dom_html_option_element_set_disabled(dom_html_option_element *ele, + bool disabled) +{ + return dom_html_element_set_bool_property(&ele->base, "disabled", + SLEN("disabled"), disabled); +} + +/** + * Get the label property + * + * \param option The dom_html_option_element object + * \param label Pointer to location to receive label + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_get_label( + dom_html_option_element *option, dom_string **label) +{ + dom_html_document *doc; + + doc = (dom_html_document *) ((dom_node_internal *) option)->owner; + + return dom_element_get_attribute(option, + doc->memoised[hds_label], label); +} + +/** + * Set the label property + * + * \param option The dom_html_option_element object + * \param label Label value + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_set_label( + dom_html_option_element *option, dom_string *label) +{ + dom_html_document *doc; + + doc = (dom_html_document *) ((dom_node_internal *) option)->owner; + + return dom_element_set_attribute(option, + doc->memoised[hds_label], label); +} + +/** + * Get the selected property + * + * \param ele The dom_html_option_element object + * \param selected The returned status + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception dom_html_option_element_get_selected(dom_html_option_element *ele, + bool *selected) +{ + return dom_html_element_get_bool_property(&ele->base, "selected", + SLEN("selected"), selected); +} + +/** + * Set the selected property + * + * \param ele The dom_html_option_element object + * \param selected The status + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception dom_html_option_element_set_selected(dom_html_option_element *ele, + bool selected) +{ + return dom_html_element_set_bool_property(&ele->base, "selected", + SLEN("selected"), selected); +} + +/** + * Get the value property + * + * \param option The dom_html_option_element object + * \param value Pointer to location to receive property value + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_get_value( + dom_html_option_element *option, dom_string **value) +{ + dom_html_document *doc; + bool has_value = false; + dom_exception err; + + doc = (dom_html_document *) ((dom_node_internal *) option)->owner; + + err = dom_element_has_attribute(option, + doc->memoised[hds_value], &has_value); + if (err != DOM_NO_ERR) + return err; + + if (has_value) { + return dom_element_get_attribute(option, + doc->memoised[hds_value], value); + } + + return dom_html_option_element_get_text(option, value); +} + +/** + * Set the value property + * + * \param option The dom_html_option_element object + * \param value Property value + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_option_element_set_value( + dom_html_option_element *option, dom_string *value) +{ + dom_html_document *doc; + + doc = (dom_html_document *) ((dom_node_internal *) option)->owner; + + return dom_element_set_attribute(option, + doc->memoised[hds_value], value); +} + +/*------------------------------------------------------------------------*/ +/* The protected virtual functions */ + +/* The virtual function used to parse attribute value, see src/core/element.c + * for detail */ +dom_exception _dom_html_option_element_parse_attribute(dom_element *ele, + dom_string *name, dom_string *value, + dom_string **parsed) +{ + dom_html_option_element *option = (dom_html_option_element *)ele; + dom_html_document *html = (dom_html_document *)(ele->base.owner); + + /** \todo Find some way to do the equiv for default_selected to be + * false instead of true. Some end-tag hook in the binding perhaps? + */ + if (dom_string_caseless_isequal(name, html->memoised[hds_selected])) { + if (option->default_selected_set == false) { + option->default_selected = true; + option->default_selected_set = true; + } + } + + dom_string_ref(value); + *parsed = value; + + return DOM_NO_ERR; +} + +/* The virtual destroy function, see src/core/node.c for detail */ +void _dom_virtual_html_option_element_destroy(dom_node_internal *node) +{ + _dom_html_option_element_destroy((struct dom_html_option_element *) node); +} + +/* The virtual copy function, see src/core/node.c for detail */ +dom_exception _dom_html_option_element_copy(dom_node_internal *old, + dom_node_internal **copy) +{ + return _dom_html_element_copy(old, copy); +} + diff --git a/src/html/html_option_element.h b/src/html/html_option_element.h index 2e182d5..bc8ff6f 100644 --- a/src/html/html_option_element.h +++ b/src/html/html_option_element.h @@ -2,6 +2,53 @@ * This file is part of libdom. * Licensed under the MIT License, * http://www.opensource.org/licenses/mit-license.php - * Copyright 2009 Bo Yang + * Copyright 2012 John-Mark Bell */ +#ifndef dom_internal_html_option_element_h_ +#define dom_internal_html_option_element_h_ + +#include + +#include "html/html_element.h" + +struct dom_html_option_element { + struct dom_html_element base; + /**< The base class */ + bool default_selected; /**< Initial selected value */ + bool default_selected_set; /**< Whether default_selected has been set */ +}; + +/* Create a dom_html_option_element object */ +dom_exception _dom_html_option_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, + struct dom_html_option_element **ele); + +/* Initialise a dom_html_option_element object */ +dom_exception _dom_html_option_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, + struct dom_html_option_element *ele); + +/* Finalise a dom_html_option_element object */ +void _dom_html_option_element_finalise(struct dom_html_option_element *ele); + +/* Destroy a dom_html_option_element object */ +void _dom_html_option_element_destroy(struct dom_html_option_element *ele); + +/* The protected virtual functions */ +dom_exception _dom_html_option_element_parse_attribute(dom_element *ele, + dom_string *name, dom_string *value, + dom_string **parsed); +void _dom_virtual_html_option_element_destroy(dom_node_internal *node); +dom_exception _dom_html_option_element_copy(dom_node_internal *old, + dom_node_internal **copy); + +#define DOM_HTML_OPTION_ELEMENT_PROTECT_VTABLE \ + _dom_html_option_element_parse_attribute + +#define DOM_NODE_PROTECT_VTABLE_HTML_OPTION_ELEMENT \ + _dom_virtual_html_option_element_destroy, \ + _dom_html_option_element_copy + +#endif + diff --git a/src/html/html_options_collection.c b/src/html/html_options_collection.c index 26926bf..e5b5f34 100644 --- a/src/html/html_options_collection.c +++ b/src/html/html_options_collection.c @@ -142,7 +142,73 @@ dom_exception dom_html_options_collection_item(dom_html_options_collection *col, dom_exception dom_html_options_collection_named_item(dom_html_options_collection *col, dom_string *name, struct dom_node **node) { - return dom_html_collection_named_item(&col->base, name, node); + struct dom_node_internal *n = col->base.root; + dom_string *kname; + dom_exception err; + + /* Search for an element with an appropriate ID */ + err = dom_html_collection_named_item(&col->base, name, node); + if (err == DOM_NO_ERR && *node != NULL) + return err; + + /* Didn't find one, so consider name attribute */ + err = dom_string_create_interned((const uint8_t *) "name", SLEN("name"), + &kname); + if (err != DOM_NO_ERR) + return err; + + while (n != NULL) { + if (n->type == DOM_ELEMENT_NODE && + col->base.ic(n, col->base.ctx) == true) { + dom_string *nval = NULL; + + err = dom_element_get_attribute(n, kname, &nval); + if (err != DOM_NO_ERR) { + dom_string_unref(kname); + return err; + } + + if (nval != NULL && dom_string_isequal(name, nval)) { + *node = (struct dom_node *) n; + dom_node_ref(n); + dom_string_unref(nval); + dom_string_unref(kname); + + return DOM_NO_ERR; + } + + if (nval != NULL) + dom_string_unref(nval); + } + + /* Depth first iterating */ + if (n->first_child != NULL) { + n = n->first_child; + } else if (n->next != NULL) { + n = n->next; + } else { + /* No children and siblings */ + struct dom_node_internal *parent = n->parent; + + while (parent != col->base.root && + n == parent->last_child) { + n = parent; + parent = parent->parent; + } + + if (parent == col->base.root) + n = NULL; + else + n = n->next; + } + } + + dom_string_unref(kname); + + /* Not found the target node */ + *node = NULL; + + return DOM_NO_ERR; } /** diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c index 2d92c5f..9992376 100644 --- a/src/html/html_select_element.c +++ b/src/html/html_select_element.c @@ -8,6 +8,9 @@ #include #include +#include +#include + #include "html/html_document.h" #include "html/html_select_element.h" @@ -31,6 +34,7 @@ static bool is_option(struct dom_node_internal *node, void *ctx); * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_select_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_select_element **ele) { struct dom_node_internal *node; @@ -44,7 +48,7 @@ dom_exception _dom_html_select_element_create(struct dom_html_document *doc, node->base.vtable = &_dom_html_element_vtable; node->vtable = &_protect_vtable; - return _dom_html_select_element_initialise(doc, *ele); + return _dom_html_select_element_initialise(doc, namespace, prefix, *ele); } /** @@ -55,23 +59,15 @@ dom_exception _dom_html_select_element_create(struct dom_html_document *doc, * \return DOM_NO_ERR on success, appropriate dom_exception on failure. */ dom_exception _dom_html_select_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_select_element *ele) { - dom_string *name = NULL; - dom_exception err; - - err = dom_string_create((const uint8_t *) "SELECT", SLEN("SELECT"), - &name); - if (err != DOM_NO_ERR) - return err; - - err = _dom_html_element_initialise(doc, &ele->base, name, NULL, NULL); - dom_string_unref(name); - - ele->selected = -1; + ele->form = NULL; ele->options = NULL; - return err; + return _dom_html_element_initialise(doc, &ele->base, + doc->memoised[hds_SELECT], + namespace, prefix); } /** @@ -81,6 +77,9 @@ dom_exception _dom_html_select_element_initialise(struct dom_html_document *doc, */ void _dom_html_select_element_finalise(struct dom_html_select_element *ele) { + if (ele->options != NULL) + dom_html_options_collection_unref(ele->options); + _dom_html_element_finalise(&ele->base); } @@ -129,6 +128,51 @@ dom_exception _dom_html_select_element_copy(dom_node_internal *old, /*-----------------------------------------------------------------------*/ /* Public APIs */ +static dom_exception _dom_html_select_element_ensure_collection( + dom_html_select_element *ele) +{ + dom_exception err; + dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); + + assert(doc != NULL); + + if (ele->options == NULL) { + err = _dom_html_options_collection_create(doc, + (dom_node_internal *) ele, + is_option, ele, &ele->options); + if (err != DOM_NO_ERR) + return err; + } + + return DOM_NO_ERR; +} + +/** + * Get the type of selection control + * + * \param ele The Select element + * \param type Pointer to location to receive type + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_select_element_get_type( + dom_html_select_element *ele, dom_string **type) +{ + dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); + dom_exception err; + bool multiple; + + err = dom_html_select_element_get_multiple(ele, &multiple); + if (err != DOM_NO_ERR) + return err; + + if (multiple) + *type = dom_string_ref(doc->memoised[hds_select_multiple]); + else + *type = dom_string_ref(doc->memoised[hds_select_one]); + + return DOM_NO_ERR; +} + /** * Get the ordinal index of the selected option * @@ -139,7 +183,36 @@ dom_exception _dom_html_select_element_copy(dom_node_internal *old, dom_exception dom_html_select_element_get_selected_index( dom_html_select_element *ele, unsigned long *index) { - *index = ele->selected; + dom_exception err; + unsigned long idx, len; + dom_node *option; + bool selected; + + err = dom_html_select_element_get_length(ele, &len); + if (err != DOM_NO_ERR) + return err; + + for (idx = 0; idx < len; idx++) { + err = dom_html_options_collection_item(ele->options, + idx, &option); + if (err != DOM_NO_ERR) + return err; + + err = dom_html_option_element_get_selected( + (dom_html_option_element *) option, &selected); + + dom_node_unref(option); + + if (err != DOM_NO_ERR) + return err; + + if (selected) { + *index = idx; + return DOM_NO_ERR; + } + } + + *index = -1; return DOM_NO_ERR; } @@ -154,11 +227,78 @@ dom_exception dom_html_select_element_get_selected_index( dom_exception dom_html_select_element_set_selected_index( dom_html_select_element *ele, unsigned long index) { - ele->selected = index; + UNUSED(ele); + UNUSED(index); + + /** \todo Implement */ + return DOM_NOT_SUPPORTED_ERR; +} + +/** + * Get the value of this form control + * + * \param ele The select element + * \param value Pointer to location to receive value + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_select_element_get_value( + dom_html_select_element *ele, dom_string **value) +{ + dom_exception err; + unsigned long idx, len; + dom_node *option; + bool selected; + + err = dom_html_select_element_get_length(ele, &len); + if (err != DOM_NO_ERR) + return err; + + for (idx = 0; idx < len; idx++) { + err = dom_html_options_collection_item(ele->options, + idx, &option); + if (err != DOM_NO_ERR) + return err; + + err = dom_html_option_element_get_selected( + (dom_html_option_element *) option, &selected); + if (err != DOM_NO_ERR) { + dom_node_unref(option); + return err; + } + + if (selected) { + err = dom_html_option_element_get_value( + (dom_html_option_element *) option, + value); + + dom_node_unref(option); + + return err; + } + } + + *value = NULL; return DOM_NO_ERR; } +/** + * Set the value of this form control + * + * \param ele The select element + * \param value New value + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_select_element_set_value( + dom_html_select_element *ele, dom_string *value) +{ + UNUSED(ele); + UNUSED(value); + + /** \todo Implement */ + return DOM_NOT_SUPPORTED_ERR; +} + /** * Get the number of options in this select element * @@ -170,16 +310,10 @@ dom_exception dom_html_select_element_get_length( dom_html_select_element *ele, unsigned long *len) { dom_exception err; - dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); - assert(doc != NULL); - if (ele->options == NULL) { - err = _dom_html_options_collection_create(doc, - (dom_node_internal *) ele, - is_option, NULL, &ele->options); - if (err != DOM_NO_ERR) - return err; - } + err = _dom_html_select_element_ensure_collection(ele); + if (err != DOM_NO_ERR) + return err; return dom_html_options_collection_get_length(ele->options, len); } @@ -202,6 +336,24 @@ dom_exception dom_html_select_element_set_length( return DOM_NOT_SUPPORTED_ERR; } +/** + * Get the form associated with a select + * + * \param select The dom_html_select_element object + * \param form Pointer to location to receive form + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_select_element_get_form( + dom_html_select_element *select, dom_html_form_element **form) +{ + *form = select->form; + + if (*form != NULL) + dom_node_ref(*form); + + return DOM_NO_ERR; +} + /** * The collection of OPTION elements of this element * @@ -214,19 +366,10 @@ dom_exception dom_html_select_element_get_options( struct dom_html_options_collection **col) { dom_exception err; - dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); - assert(doc != NULL); - if (ele->options == NULL) { - err = _dom_html_options_collection_create(doc, - (dom_node_internal *) ele, - is_option, NULL, &ele->options); - if (err != DOM_NO_ERR) - return err; - - *col = ele->options; - return DOM_NO_ERR; - } + err = _dom_html_select_element_ensure_collection(ele); + if (err != DOM_NO_ERR) + return err; dom_html_options_collection_ref(ele->options); *col = ele->options; @@ -290,20 +433,166 @@ dom_exception dom_html_select_element_set_multiple( "multiple", SLEN("multiple"), multiple); } +/** + * Get the name property + * + * \param ele The select element + * \param name Pointer to location to receive name + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_select_element_get_name( + dom_html_select_element *ele, dom_string **name) +{ + dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); + + return dom_element_get_attribute(ele, + doc->memoised[hds_name], name); +} + +/** + * Set the name property + * + * \param ele The select element + * \param name New name + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ +dom_exception dom_html_select_element_set_name( + dom_html_select_element *ele, dom_string *name) +{ + dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); + + return dom_element_set_attribute(ele, + doc->memoised[hds_name], name); + +} + +/** + * Get the size property + * + * \param ele The select element + * \param size Pointer to location to receive size + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ dom_exception dom_html_select_element_get_size( - dom_html_select_element *ele, unsigned long *size); + dom_html_select_element *ele, unsigned long *size) +{ + return dom_html_element_get_long_property(&ele->base, "size", + SLEN("size"), size); +} + +/** + * Set the size property + * + * \param ele The select element + * \param size New size + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ dom_exception dom_html_select_element_set_size( - dom_html_select_element *ele, unsigned long size); + dom_html_select_element *ele, unsigned long size) +{ + return dom_html_element_set_long_property(&ele->base, "size", + SLEN("size"), size); +} + +/** + * Get the tabindex property + * + * \param ele The select element + * \param tab_index Pointer to location to receive tab index + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ dom_exception dom_html_select_element_get_tab_index( - dom_html_select_element *ele, unsigned long *tab_index); + dom_html_select_element *ele, unsigned long *tab_index) +{ + return dom_html_element_get_long_property(&ele->base, "tabindex", + SLEN("tabindex"), tab_index); +} + +/** + * Set the tabindex property + * + * \param ele The select element + * \param tab_index New tab index + * \return DOM_NO_ERR on success, appropriate error otherwise. + */ dom_exception dom_html_select_element_set_tab_index( - dom_html_select_element *ele, unsigned long tab_index); + dom_html_select_element *ele, unsigned long tab_index) +{ + return dom_html_element_set_long_property(&ele->base, "tabindex", + SLEN("tabindex"), tab_index); +} + /* Functions */ -dom_exception dom_html_select_element_add(struct dom_html_element *ele, - struct dom_html_element *before); -dom_exception dom_html_element_blur(struct dom_html_select_element *ele); -dom_exception dom_html_element_focus(struct dom_html_select_element *ele); +dom_exception dom_html_select_element_add(dom_html_select_element *select, + struct dom_html_element *ele, struct dom_html_element *before) +{ + UNUSED(select); + UNUSED(ele); + UNUSED(before); + + /** \todo Implement */ + return DOM_NOT_SUPPORTED_ERR; +} + +dom_exception dom_html_select_element_remove(dom_html_select_element *ele, + long index) +{ + dom_exception err; + unsigned long len; + dom_node *option; + + err = dom_html_select_element_get_length(ele, &len); + if (err != DOM_NO_ERR) + return err; + + /* Ensure index is in range */ + if ((unsigned long) index >= len) + return DOM_NO_ERR; + + err = dom_html_options_collection_item(ele->options, index, &option); + if (err != DOM_NO_ERR) + return err; + + /** \todo What does remove mean? Remove option from tree and destroy it? */ + return DOM_NOT_SUPPORTED_ERR; +} + +/** + * Blur this control + * + * \param ele Element to blur + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception dom_html_select_element_blur(struct dom_html_select_element *ele) +{ + struct dom_document *doc = dom_node_get_owner(ele); + bool success = false; + assert(doc != NULL); + + /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */ + return _dom_dispatch_generic_event(doc, (dom_event_target *) ele, + (const uint8_t *) "blur", SLEN("blur"), true, + true, &success); +} + +/** + * Focus this control + * + * \param ele Element to focus + * \return DOM_NO_ERR on success, appropriate dom_exception on failure. + */ +dom_exception dom_html_select_element_focus(struct dom_html_select_element *ele) +{ + struct dom_document *doc = dom_node_get_owner(ele); + bool success = false; + assert(doc != NULL); + + /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */ + return _dom_dispatch_generic_event(doc, (dom_event_target *) ele, + (const uint8_t *) "focus", SLEN("focus"), true, + true, &success); +} /*-----------------------------------------------------------------------*/ @@ -312,21 +601,20 @@ dom_exception dom_html_element_focus(struct dom_html_select_element *ele); /* Test whether certain node is an option node */ bool is_option(struct dom_node_internal *node, void *ctx) { - dom_string *name = NULL; - bool ret = false; - dom_exception err; - - UNUSED(ctx); + dom_html_select_element *ele = ctx; + dom_html_document *doc = (dom_html_document *) dom_node_get_owner(ele); - err = dom_string_create((const uint8_t *) "OPTION", SLEN("OPTION"), - &name); - if (err != DOM_NO_ERR) - return false; + if (dom_string_isequal(node->name, doc->memoised[hds_OPTION])) + return true; - if (dom_string_isequal(name, node->name)) - ret = true; - - dom_string_unref(name); + return false; +} + +dom_exception _dom_html_select_element_set_form( + dom_html_select_element *select, dom_html_form_element *form) +{ + select->form = form; - return ret; + return DOM_NO_ERR; } + diff --git a/src/html/html_select_element.h b/src/html/html_select_element.h index 68c51e3..6fb7bf1 100644 --- a/src/html/html_select_element.h +++ b/src/html/html_select_element.h @@ -16,18 +16,20 @@ struct dom_html_select_element { struct dom_html_element base; /**< The base class */ - long selected; - /**< The selected element's index */ + dom_html_form_element *form; + /**< The form associated with select */ dom_html_options_collection *options; /**< The options objects */ }; /* Create a dom_html_select_element object */ dom_exception _dom_html_select_element_create(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_select_element **ele); /* Initialise a dom_html_select_element object */ dom_exception _dom_html_select_element_initialise(struct dom_html_document *doc, + dom_string *namespace, dom_string *prefix, struct dom_html_select_element *ele); /* Finalise a dom_html_select_element object */ @@ -51,5 +53,10 @@ dom_exception _dom_html_select_element_copy(dom_node_internal *old, _dom_virtual_html_select_element_destroy, \ _dom_html_select_element_copy +/* Internal function for bindings */ + +dom_exception _dom_html_select_element_set_form( + dom_html_select_element *select, dom_html_form_element *form); + #endif diff --git a/test/testcases/tests/level1/html/HTMLOptionElement01.xml b/test/testcases/tests/level1/html/HTMLOptionElement01.xml new file mode 100644 index 0000000..d07454c --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement01.xml @@ -0,0 +1,45 @@ + + + + + + + +HTMLOptionElement01 +NIST + + The form attribute returns the FORM element containing this control. + + Retrieve the form attribute from the first SELECT element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + +
+ + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement01.xml.kfail deleted file mode 100644 index d07454c..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement01.xml.kfail +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - -HTMLOptionElement01 -NIST - - The form attribute returns the FORM element containing this control. - - Retrieve the form attribute from the first SELECT element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement02.xml b/test/testcases/tests/level1/html/HTMLOptionElement02.xml new file mode 100644 index 0000000..bbf3153 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement02.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLOptionElement02 +NIST + + The form attribute returns null if control in not within the context of + a form. + + Retrieve the first OPTION attribute from the second select element and + examine its form element. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement02.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement02.xml.kfail deleted file mode 100644 index bbf3153..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement02.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLOptionElement02 -NIST - - The form attribute returns null if control in not within the context of - a form. - - Retrieve the first OPTION attribute from the second select element and - examine its form element. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement03.xml b/test/testcases/tests/level1/html/HTMLOptionElement03.xml new file mode 100644 index 0000000..9cee3c4 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement03.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLOptionElement03 +NIST + + The defaultSelected attribute contains the value of the selected + attribute. + + Retrieve the defaultSelected attribute from the first OPTION element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement03.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement03.xml.kfail deleted file mode 100644 index 9cee3c4..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement03.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLOptionElement03 -NIST - - The defaultSelected attribute contains the value of the selected - attribute. - - Retrieve the defaultSelected attribute from the first OPTION element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement04.xml b/test/testcases/tests/level1/html/HTMLOptionElement04.xml new file mode 100644 index 0000000..1923dd3 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement04.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLOptionElement04 +NIST + + The text attribute contains the text contained within the option element. + + Retrieve the text attribute from the second OPTION element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement04.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement04.xml.kfail deleted file mode 100644 index 1923dd3..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement04.xml.kfail +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLOptionElement04 -NIST - - The text attribute contains the text contained within the option element. - - Retrieve the text attribute from the second OPTION element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement06.xml b/test/testcases/tests/level1/html/HTMLOptionElement06.xml new file mode 100644 index 0000000..2c00da4 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement06.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLOptionElement06 +NIST + + The disabled attribute indicates that this control is not available + within this context. + + Retrieve the disabled attribute from the last OPTION element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement06.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement06.xml.kfail deleted file mode 100644 index 2c00da4..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement06.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLOptionElement06 -NIST - - The disabled attribute indicates that this control is not available - within this context. - - Retrieve the disabled attribute from the last OPTION element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement07.xml b/test/testcases/tests/level1/html/HTMLOptionElement07.xml new file mode 100644 index 0000000..9218070 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement07.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLOptionElement07 +NIST + + The label attribute is used in hierarchical menus. It specifies + a shorter label for an option that the content of the OPTION element. + + Retrieve the label attribute from the second OPTION element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement07.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement07.xml.kfail deleted file mode 100644 index 9218070..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement07.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLOptionElement07 -NIST - - The label attribute is used in hierarchical menus. It specifies - a shorter label for an option that the content of the OPTION element. - - Retrieve the label attribute from the second OPTION element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement08.xml b/test/testcases/tests/level1/html/HTMLOptionElement08.xml new file mode 100644 index 0000000..c5c6640 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement08.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLOptionElement08 +NIST + + The selected attribute indicates the current state of the corresponding + form control in an interactive user-agent. + + Retrieve the selected attribute from the first OPTION element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement08.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement08.xml.kfail deleted file mode 100644 index c5c6640..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement08.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLOptionElement08 -NIST - - The selected attribute indicates the current state of the corresponding - form control in an interactive user-agent. - - Retrieve the selected attribute from the first OPTION element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLOptionElement09.xml b/test/testcases/tests/level1/html/HTMLOptionElement09.xml new file mode 100644 index 0000000..064ccbe --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLOptionElement09.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLOptionElement09 +NIST + + The value attribute contains the current form control value. + + Retrieve the value attribute from the first OPTION element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLOptionElement09.xml.kfail b/test/testcases/tests/level1/html/HTMLOptionElement09.xml.kfail deleted file mode 100644 index 064ccbe..0000000 --- a/test/testcases/tests/level1/html/HTMLOptionElement09.xml.kfail +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLOptionElement09 -NIST - - The value attribute contains the current form control value. - - Retrieve the value attribute from the first OPTION element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - -- cgit v1.2.3 From f6dfa1bd24a39ebf55993837431b10e437cade12 Mon Sep 17 00:00:00 2001 From: John-Mark Bell Date: Wed, 19 Sep 2012 00:03:05 +0100 Subject: Enable HTMLSelectElement tests --- include/dom/html/html_select_element.h | 11 +++- src/html/html_select_element.c | 4 +- test/DOMTSHandler.pm | 7 +++ .../tests/level1/html/HTMLSelectElement01.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement01.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement02.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement02.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement03.xml | 49 ++++++++++++++++++ .../level1/html/HTMLSelectElement03.xml.kfail | 49 ------------------ .../tests/level1/html/HTMLSelectElement04.xml | 43 ++++++++++++++++ .../level1/html/HTMLSelectElement04.xml.kfail | 43 ---------------- .../tests/level1/html/HTMLSelectElement05.xml | 43 ++++++++++++++++ .../level1/html/HTMLSelectElement05.xml.kfail | 43 ---------------- .../tests/level1/html/HTMLSelectElement06.xml | 45 +++++++++++++++++ .../level1/html/HTMLSelectElement06.xml.kfail | 45 ----------------- .../tests/level1/html/HTMLSelectElement07.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement07.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement08.xml | 59 ++++++++++++++++++++++ .../level1/html/HTMLSelectElement08.xml.kfail | 59 ---------------------- .../tests/level1/html/HTMLSelectElement09.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement09.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement10.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement10.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement11.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement11.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement12.xml | 43 ++++++++++++++++ .../level1/html/HTMLSelectElement12.xml.kfail | 43 ---------------- .../tests/level1/html/HTMLSelectElement13.xml | 44 ++++++++++++++++ .../level1/html/HTMLSelectElement13.xml.kfail | 44 ---------------- .../tests/level1/html/HTMLSelectElement14.xml | 37 ++++++++++++++ .../level1/html/HTMLSelectElement14.xml.kfail | 37 -------------- .../tests/level1/html/HTMLSelectElement15.xml | 37 ++++++++++++++ .../level1/html/HTMLSelectElement15.xml.kfail | 37 -------------- .../tests/level1/html/HTMLSelectElement17.xml | 43 ++++++++++++++++ .../level1/html/HTMLSelectElement17.xml.kfail | 43 ---------------- test/testutils/foreach.c | 26 ++++++++++ test/testutils/foreach.h | 4 ++ 37 files changed, 755 insertions(+), 711 deletions(-) create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement01.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement01.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement02.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement02.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement03.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement03.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement04.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement04.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement05.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement05.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement06.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement06.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement07.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement07.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement08.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement08.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement09.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement09.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement10.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement10.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement11.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement11.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement12.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement12.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement13.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement13.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement14.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement14.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement15.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement15.xml.kfail create mode 100644 test/testcases/tests/level1/html/HTMLSelectElement17.xml delete mode 100644 test/testcases/tests/level1/html/HTMLSelectElement17.xml.kfail diff --git a/include/dom/html/html_select_element.h b/include/dom/html/html_select_element.h index 89b6844..b92abd6 100644 --- a/include/dom/html/html_select_element.h +++ b/include/dom/html/html_select_element.h @@ -40,9 +40,12 @@ dom_exception dom_html_select_element_set_length( dom_exception dom_html_select_element_get_form( dom_html_select_element *ele, dom_html_form_element **form); -dom_exception dom_html_select_element_get_options( +dom_exception dom__html_select_element_get_options( dom_html_select_element *ele, struct dom_html_options_collection **col); +#define dom_html_select_element_get_options(e, c) \ + dom__html_select_element_get_options((dom_html_select_element *) (e), \ + (struct dom_html_options_collection **) (c)) dom_exception dom_html_select_element_get_disabled( dom_html_select_element *ele, bool *disabled); @@ -70,8 +73,12 @@ dom_exception dom_html_select_element_set_tab_index( dom_html_select_element *ele, unsigned long tab_index); /* Functions */ -dom_exception dom_html_select_element_add(dom_html_select_element *select, +dom_exception dom__html_select_element_add(dom_html_select_element *select, struct dom_html_element *ele, struct dom_html_element *before); +#define dom_html_select_element_add(s, e, b) \ + dom__html_select_element_add((dom_html_select_element *) (s), \ + (struct dom_html_element *) (e), \ + (struct dom_html_element *) (b)) dom_exception dom_html_select_element_remove(dom_html_select_element *ele, long index); dom_exception dom_html_select_element_blur(struct dom_html_select_element *ele); diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c index 9992376..89e46a9 100644 --- a/src/html/html_select_element.c +++ b/src/html/html_select_element.c @@ -361,7 +361,7 @@ dom_exception dom_html_select_element_get_form( * \param col THe returned collection object * \return DOM_NO_ERR on success. */ -dom_exception dom_html_select_element_get_options( +dom_exception dom__html_select_element_get_options( dom_html_select_element *ele, struct dom_html_options_collection **col) { @@ -524,7 +524,7 @@ dom_exception dom_html_select_element_set_tab_index( /* Functions */ -dom_exception dom_html_select_element_add(dom_html_select_element *select, +dom_exception dom__html_select_element_add(dom_html_select_element *select, struct dom_html_element *ele, struct dom_html_element *before) { UNUSED(select); diff --git a/test/DOMTSHandler.pm b/test/DOMTSHandler.pm index 890a8ff..93a97e9 100644 --- a/test/DOMTSHandler.pm +++ b/test/DOMTSHandler.pm @@ -1244,6 +1244,13 @@ sub generate_control_statement { print "foreach_initialise_domnamednodemap($coll, \&iterator$iterator_index);\n"; print "while(get_next_domnamednodemap($coll, \&iterator$iterator_index, \&$member)) {\n"; } + + if ($self->{"var"}->{$coll} eq "HTMLCollection") { + $iterator_index++; + print "unsigned int iterator$iterator_index = 0;"; + print "foreach_initialise_domhtmlcollection($coll, \&iterator$iterator_index);\n"; + print "while(get_next_domhtmlcollection($coll, \&iterator$iterator_index, \&$member)) {\n"; + } } } diff --git a/test/testcases/tests/level1/html/HTMLSelectElement01.xml b/test/testcases/tests/level1/html/HTMLSelectElement01.xml new file mode 100644 index 0000000..3b08881 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement01.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement01 +NIST + + The type attribute is the string "select-multiple" when multiple + attribute is true. + + Retrieve the type attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement01.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement01.xml.kfail deleted file mode 100644 index 3b08881..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement01.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement01 -NIST - - The type attribute is the string "select-multiple" when multiple - attribute is true. - - Retrieve the type attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement02.xml b/test/testcases/tests/level1/html/HTMLSelectElement02.xml new file mode 100644 index 0000000..f9e865d --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement02.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement02 +NIST + + The selectedIndex attribute specifies the ordinal index of the selected + option. + + Retrieve the selectedIndex attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement02.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement02.xml.kfail deleted file mode 100644 index f9e865d..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement02.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement02 -NIST - - The selectedIndex attribute specifies the ordinal index of the selected - option. - - Retrieve the selectedIndex attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement03.xml b/test/testcases/tests/level1/html/HTMLSelectElement03.xml new file mode 100644 index 0000000..97d217c --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement03.xml @@ -0,0 +1,49 @@ + + + + + + + +HTMLSelectElement03 +NIST + + The selectedIndex attribute specifies the ordinal index of the selected + option. If no element is selected -1 is returned. + + Retrieve the selectedIndex attribute from the second SELECT element and + examine its value. + + Per http://www.w3.org/TR/html401/interact/forms.html#h-17.6.1, + without an explicit selected attribute, user agent behavior is + undefined. There is no way to coerce no option to be selected. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement03.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement03.xml.kfail deleted file mode 100644 index 97d217c..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement03.xml.kfail +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - -HTMLSelectElement03 -NIST - - The selectedIndex attribute specifies the ordinal index of the selected - option. If no element is selected -1 is returned. - - Retrieve the selectedIndex attribute from the second SELECT element and - examine its value. - - Per http://www.w3.org/TR/html401/interact/forms.html#h-17.6.1, - without an explicit selected attribute, user agent behavior is - undefined. There is no way to coerce no option to be selected. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement04.xml b/test/testcases/tests/level1/html/HTMLSelectElement04.xml new file mode 100644 index 0000000..11ff6ee --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement04.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLSelectElement04 +NIST + + The value attribute specifies the current form control value. + + Retrieve the value attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement04.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement04.xml.kfail deleted file mode 100644 index 11ff6ee..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement04.xml.kfail +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLSelectElement04 -NIST - - The value attribute specifies the current form control value. - - Retrieve the value attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement05.xml b/test/testcases/tests/level1/html/HTMLSelectElement05.xml new file mode 100644 index 0000000..16c78e1 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement05.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLSelectElement05 +NIST + + The length attribute specifies the number of options in this select. + + Retrieve the length attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement05.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement05.xml.kfail deleted file mode 100644 index 16c78e1..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement05.xml.kfail +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLSelectElement05 -NIST - - The length attribute specifies the number of options in this select. - - Retrieve the length attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement06.xml b/test/testcases/tests/level1/html/HTMLSelectElement06.xml new file mode 100644 index 0000000..8ff66a0 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement06.xml @@ -0,0 +1,45 @@ + + + + + + + +HTMLSelectElement06 +NIST + + The form attribute returns the FORM element containing this control. + + Retrieve the form attribute from the first SELECT element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement06.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement06.xml.kfail deleted file mode 100644 index 8ff66a0..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement06.xml.kfail +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - -HTMLSelectElement06 -NIST - - The form attribute returns the FORM element containing this control. - - Retrieve the form attribute from the first SELECT element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement07.xml b/test/testcases/tests/level1/html/HTMLSelectElement07.xml new file mode 100644 index 0000000..218b9d6 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement07.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement07 +NIST + + The form attribute returns null if control in not within the context of + a form. + + Retrieve the second SELECT element and + examine its form element. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement07.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement07.xml.kfail deleted file mode 100644 index 218b9d6..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement07.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement07 -NIST - - The form attribute returns null if control in not within the context of - a form. - - Retrieve the second SELECT element and - examine its form element. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement08.xml b/test/testcases/tests/level1/html/HTMLSelectElement08.xml new file mode 100644 index 0000000..12593fe --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement08.xml @@ -0,0 +1,59 @@ + + + + + + + +HTMLSelectElement08 +NIST + + The options attribute returns a collection of OPTION elements contained + by this element. + + Retrieve the options attribute from the first SELECT element and + examine the items of the returned collection. + +Mary Brady +2002-02-22 + + + + + + + + + + + +"option" +"option" +"option" +"option" +"option" + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement08.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement08.xml.kfail deleted file mode 100644 index 12593fe..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement08.xml.kfail +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - -HTMLSelectElement08 -NIST - - The options attribute returns a collection of OPTION elements contained - by this element. - - Retrieve the options attribute from the first SELECT element and - examine the items of the returned collection. - -Mary Brady -2002-02-22 - - - - - - - - - - - -"option" -"option" -"option" -"option" -"option" - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement09.xml b/test/testcases/tests/level1/html/HTMLSelectElement09.xml new file mode 100644 index 0000000..382510d --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement09.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement09 +NIST + + The disabled attribute indicates that this control is not available + within this context. + + Retrieve the disabled attribute from the third SELECT element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement09.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement09.xml.kfail deleted file mode 100644 index 382510d..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement09.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement09 -NIST - - The disabled attribute indicates that this control is not available - within this context. - - Retrieve the disabled attribute from the third SELECT element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement10.xml b/test/testcases/tests/level1/html/HTMLSelectElement10.xml new file mode 100644 index 0000000..b9f5762 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement10.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement10 +NIST + + The multiple attribute(if true) indicates that multiple OPTION elements + may be selected + + Retrieve the multiple attribute from the first SELECT element + and examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement10.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement10.xml.kfail deleted file mode 100644 index b9f5762..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement10.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement10 -NIST - - The multiple attribute(if true) indicates that multiple OPTION elements - may be selected - - Retrieve the multiple attribute from the first SELECT element - and examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement11.xml b/test/testcases/tests/level1/html/HTMLSelectElement11.xml new file mode 100644 index 0000000..ebb4d1b --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement11.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement11 +NIST + + The name attribute specifies the form control or object name when + submitted with a form. + + Retrieve the name attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement11.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement11.xml.kfail deleted file mode 100644 index ebb4d1b..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement11.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement11 -NIST - - The name attribute specifies the form control or object name when - submitted with a form. - - Retrieve the name attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement12.xml b/test/testcases/tests/level1/html/HTMLSelectElement12.xml new file mode 100644 index 0000000..5559f5d --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement12.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLSelectElement12 +NIST + + The size attribute specifies the number of visible rows. + + Retrieve the size attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement12.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement12.xml.kfail deleted file mode 100644 index 5559f5d..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement12.xml.kfail +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLSelectElement12 -NIST - - The size attribute specifies the number of visible rows. - - Retrieve the size attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement13.xml b/test/testcases/tests/level1/html/HTMLSelectElement13.xml new file mode 100644 index 0000000..2c0aafb --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement13.xml @@ -0,0 +1,44 @@ + + + + + + + +HTMLSelectElement13 +NIST + + The tabIndex attribute specifies an index that represents the elements + position in the tabbing order. + + Retrieve the tabIndex attribute from the first SELECT element and + examine its value. + +Mary Brady +2002-02-22 + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement13.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement13.xml.kfail deleted file mode 100644 index 2c0aafb..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement13.xml.kfail +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - -HTMLSelectElement13 -NIST - - The tabIndex attribute specifies an index that represents the elements - position in the tabbing order. - - Retrieve the tabIndex attribute from the first SELECT element and - examine its value. - -Mary Brady -2002-02-22 - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement14.xml b/test/testcases/tests/level1/html/HTMLSelectElement14.xml new file mode 100644 index 0000000..df22987 --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement14.xml @@ -0,0 +1,37 @@ + + + + + + + +HTMLSelectElement14 +Curt Arnold + +focus should give the select element input focus. + +2004-03-18 + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement14.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement14.xml.kfail deleted file mode 100644 index df22987..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement14.xml.kfail +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - -HTMLSelectElement14 -Curt Arnold - -focus should give the select element input focus. - -2004-03-18 - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement15.xml b/test/testcases/tests/level1/html/HTMLSelectElement15.xml new file mode 100644 index 0000000..dcc2f6d --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement15.xml @@ -0,0 +1,37 @@ + + + + + + + +HTMLSelectElement15 +Curt Arnold + +blur should surrender input focus. + +2004-03-18 + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement15.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement15.xml.kfail deleted file mode 100644 index dcc2f6d..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement15.xml.kfail +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - -HTMLSelectElement15 -Curt Arnold - -blur should surrender input focus. - -2004-03-18 - - - - - - - - - - - diff --git a/test/testcases/tests/level1/html/HTMLSelectElement17.xml b/test/testcases/tests/level1/html/HTMLSelectElement17.xml new file mode 100644 index 0000000..03549ff --- /dev/null +++ b/test/testcases/tests/level1/html/HTMLSelectElement17.xml @@ -0,0 +1,43 @@ + + + + + + + +HTMLSelectElement17 +Curt Arnold + +Removes a non-existant option using HTMLSelectElement.remove. + +2004-03-18 + + + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/html/HTMLSelectElement17.xml.kfail b/test/testcases/tests/level1/html/HTMLSelectElement17.xml.kfail deleted file mode 100644 index 03549ff..0000000 --- a/test/testcases/tests/level1/html/HTMLSelectElement17.xml.kfail +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - -HTMLSelectElement17 -Curt Arnold - -Removes a non-existant option using HTMLSelectElement.remove. - -2004-03-18 - - - - - - - - - - - - - - - - - diff --git a/test/testutils/foreach.c b/test/testutils/foreach.c index 764920c..bbc8a47 100644 --- a/test/testutils/foreach.c +++ b/test/testutils/foreach.c @@ -34,6 +34,11 @@ void foreach_initialise_domnamednodemap(dom_namednodemap *map, unsigned int *ite *iterator = 0; } +void foreach_initialise_domhtmlcollection(dom_html_collection *coll, unsigned int *iterator) +{ + (void)coll; + *iterator = 0; +} bool _get_next_domnodelist(dom_nodelist *list, unsigned int *iterator, dom_node **ret) { @@ -97,3 +102,24 @@ bool _get_next_domnamednodemap(dom_namednodemap *map, unsigned int *iterator, do return true; } + +bool _get_next_domhtmlcollection(dom_html_collection *coll, unsigned int *iterator, dom_node **ret) +{ + dom_exception err; + unsigned long len; + + err = dom_html_collection_get_length(coll, &len); + if (err != DOM_NO_ERR) + return false; + + if (*iterator >= len) + return false; + + err = dom_html_collection_item(coll, (*iterator), ret); + if (err != DOM_NO_ERR) + return false; + + (*iterator)++; + + return true; +} diff --git a/test/testutils/foreach.h b/test/testutils/foreach.h index 75874bc..aa9543d 100644 --- a/test/testutils/foreach.h +++ b/test/testutils/foreach.h @@ -26,6 +26,7 @@ void foreach_initialise_domnodelist(dom_nodelist *list, unsigned int *iterator); void foreach_initialise_list(list *list, unsigned int *iterator); void foreach_initialise_domnamednodemap(dom_namednodemap *map, unsigned int *iterator); +void foreach_initialise_domhtmlcollection(dom_html_collection *coll, unsigned int *iterator); bool _get_next_domnodelist(dom_nodelist *list, unsigned int *iterator, dom_node **ret); #define get_next_domnodelist(l, i, r) _get_next_domnodelist( \ @@ -37,5 +38,8 @@ bool _get_next_domnamednodemap(dom_namednodemap *map, unsigned int *iterator, do #define get_next_domnamednodemap(m, i, r) _get_next_domnamednodemap( \ (dom_namednodemap *) (m), (unsigned int *) (i), (dom_node **) (r)) +bool _get_next_domhtmlcollection(dom_html_collection *coll, unsigned int *iterator, dom_node **ret); +#define get_next_domhtmlcollection(c, i, r) _get_next_domhtmlcollection( \ + (dom_html_collection *) (c), (unsigned int *) (i), (dom_node **) (r)) #endif -- cgit v1.2.3 From db03d00ad34c4b888e5cf3034411388900f4858e Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Wed, 19 Sep 2012 12:15:09 +0100 Subject: Add select and option .h files to install target. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 6918bb7..b9e1d8b 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,9 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_meta_element.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_form_element.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_button_element.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_input_element.h +INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_select_element.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_text_area_element.h +INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_option_element.h INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/html_opt_group_element.h INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in -- cgit v1.2.3