Gitweb links:
...log
http://git.netsurf-browser.org/libdom.git/shortlog/ab31e885f78807d691f36decf5de7a0134b8a2f2
...commit
http://git.netsurf-browser.org/libdom.git/commit/ab31e885f78807d691f36decf5de7a0134b8a2f2
...tree
http://git.netsurf-browser.org/libdom.git/tree/ab31e885f78807d691f36decf5de7a0134b8a2f2
The branch, dsilvers/forms1 has been updated
via ab31e885f78807d691f36decf5de7a0134b8a2f2 (commit)
from 596deba4c83454f10a2de0740eb1b4b0ef344cd2 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=ab31e885f78807d691f36decf5de7a0134b8a2f2
commit ab31e885f78807d691f36decf5de7a0134b8a2f2
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
foldme; setting of value for radio nodelist
diff --git a/src/html/html_radio_nodelist.c b/src/html/html_radio_nodelist.c
index bf0570b..484351a 100644
--- a/src/html/html_radio_nodelist.c
+++ b/src/html/html_radio_nodelist.c
@@ -244,7 +244,7 @@ dom_exception
dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *nodelis
dom_string **value)
{
dom_exception exc;
- dom_node *node;
+ dom_node *node = NULL;
uint32_t count;
struct dom_html_document *doc =
(struct dom_html_document *)(((struct dom_node_internal
*)nodelist->form)->owner);
@@ -282,9 +282,12 @@ dom_exception
dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *nodelis
if (dom_string_caseless_isequal(type,
doc->memoised[hds_radio]) == false) {
dom_node_unref(node);
+ dom_string_unref(type);
continue;
}
+ dom_string_unref(type);
+
exc =
dom_html_input_element_get_checked((dom_html_input_element *)node, &checked);
if (exc != DOM_NO_ERR) {
@@ -319,14 +322,98 @@ dom_exception
dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *nodelis
/* 4. Otherwise, return the value of element’s value attribute. */
+ dom_node_unref(node);
+
return DOM_NO_ERR;
}
dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist
*nodelist,
dom_string *value)
{
- (void)nodelist;
- (void)value;
+ dom_exception exc;
+ dom_node *node = NULL;
+ uint32_t count;
+ bool goal_is_on = false;
+ struct dom_html_document *doc =
+ (struct dom_html_document *)(((struct dom_node_internal
*)nodelist->form)->owner);
- return DOM_NO_ERR;
+ assert(doc != NULL);
+
+ exc = dom_html_collection_get_length(nodelist->col, &count);
+
+ if (exc != DOM_NO_ERR)
+ return exc;
+
+ goal_is_on = dom_string_caseless_isequal(value, doc->memoised[hds_on]);
+
+ /* 1. If the new value is the string "on": let element be the first
+ * element in tree order represented by the RadioNodeList object that
+ * is an input element whose type attribute is in the Radio Button
+ * state and whose value content attribute is either absent, or present
+ * and equal to the new value, if any. If no such element exists, then
+ * instead let element be null.
+ *
+ * Otherwise: let element be the first element in tree order
+ * represented by the RadioNodeList object that is an input element
+ * whose type attribute is in the Radio Button state and whose value
+ * content attribute is present and equal to the new value, if any. If
+ * no such element exists, then instead let element be null.
+ */
+
+ for (uint32_t idx = 0; idx < count; idx++) {
+ exc = dom_html_collection_item(nodelist->col, idx, &node);
+ if (exc != DOM_NO_ERR)
+ return exc;
+
+ assert(node->type == DOM_ELEMENT_NODE);
+ if (dom_string_caseless_isequal(((struct dom_node_internal
*)node)->name,
+ doc->elements[DOM_HTML_ELEMENT_TYPE_INPUT])) {
+ dom_string *type;
+ dom_string *test_value;
+
+ exc = dom_element_get_attribute(node,
doc->memoised[hds_type], &type);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ return exc;
+ }
+
+ if (dom_string_caseless_isequal(type,
doc->memoised[hds_radio]) == false) {
+ dom_node_unref(node);
+ dom_string_unref(type);
+ continue;
+ }
+
+ dom_string_unref(type);
+
+ exc =
dom_html_input_element_get_value((dom_html_input_element *)node, &test_value);
+
+ if (test_value == NULL) {
+ if (goal_is_on) {
+ dom_string_unref(test_value);
+ break;
+ }
+ } else {
+ if (dom_string_caseless_isequal(test_value,
value)) {
+ dom_string_unref(test_value);
+ break;
+ }
+ }
+
+ dom_string_unref(test_value);
+ }
+
+ dom_node_unref(node);
+ node = NULL;
+ }
+
+ exc = DOM_NO_ERR;
+
+ /* 2. If element is not null, then set its checkedness to true. */
+ if (node != NULL) {
+ exc =
dom_html_input_element_set_checked((dom_html_input_element *)node, true);
+ }
+
+ dom_node_unref(node);
+
+ return exc;
}
-----------------------------------------------------------------------
Summary of changes:
src/html/html_radio_nodelist.c | 95 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 91 insertions(+), 4 deletions(-)
diff --git a/src/html/html_radio_nodelist.c b/src/html/html_radio_nodelist.c
index bf0570b..484351a 100644
--- a/src/html/html_radio_nodelist.c
+++ b/src/html/html_radio_nodelist.c
@@ -244,7 +244,7 @@ dom_exception
dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *nodelis
dom_string **value)
{
dom_exception exc;
- dom_node *node;
+ dom_node *node = NULL;
uint32_t count;
struct dom_html_document *doc =
(struct dom_html_document *)(((struct dom_node_internal
*)nodelist->form)->owner);
@@ -282,9 +282,12 @@ dom_exception
dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *nodelis
if (dom_string_caseless_isequal(type,
doc->memoised[hds_radio]) == false) {
dom_node_unref(node);
+ dom_string_unref(type);
continue;
}
+ dom_string_unref(type);
+
exc =
dom_html_input_element_get_checked((dom_html_input_element *)node, &checked);
if (exc != DOM_NO_ERR) {
@@ -319,14 +322,98 @@ dom_exception
dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *nodelis
/* 4. Otherwise, return the value of element’s value attribute. */
+ dom_node_unref(node);
+
return DOM_NO_ERR;
}
dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist
*nodelist,
dom_string *value)
{
- (void)nodelist;
- (void)value;
+ dom_exception exc;
+ dom_node *node = NULL;
+ uint32_t count;
+ bool goal_is_on = false;
+ struct dom_html_document *doc =
+ (struct dom_html_document *)(((struct dom_node_internal
*)nodelist->form)->owner);
- return DOM_NO_ERR;
+ assert(doc != NULL);
+
+ exc = dom_html_collection_get_length(nodelist->col, &count);
+
+ if (exc != DOM_NO_ERR)
+ return exc;
+
+ goal_is_on = dom_string_caseless_isequal(value, doc->memoised[hds_on]);
+
+ /* 1. If the new value is the string "on": let element be the first
+ * element in tree order represented by the RadioNodeList object that
+ * is an input element whose type attribute is in the Radio Button
+ * state and whose value content attribute is either absent, or present
+ * and equal to the new value, if any. If no such element exists, then
+ * instead let element be null.
+ *
+ * Otherwise: let element be the first element in tree order
+ * represented by the RadioNodeList object that is an input element
+ * whose type attribute is in the Radio Button state and whose value
+ * content attribute is present and equal to the new value, if any. If
+ * no such element exists, then instead let element be null.
+ */
+
+ for (uint32_t idx = 0; idx < count; idx++) {
+ exc = dom_html_collection_item(nodelist->col, idx, &node);
+ if (exc != DOM_NO_ERR)
+ return exc;
+
+ assert(node->type == DOM_ELEMENT_NODE);
+ if (dom_string_caseless_isequal(((struct dom_node_internal
*)node)->name,
+ doc->elements[DOM_HTML_ELEMENT_TYPE_INPUT])) {
+ dom_string *type;
+ dom_string *test_value;
+
+ exc = dom_element_get_attribute(node,
doc->memoised[hds_type], &type);
+ if (exc != DOM_NO_ERR) {
+ dom_node_unref(node);
+ return exc;
+ }
+
+ if (dom_string_caseless_isequal(type,
doc->memoised[hds_radio]) == false) {
+ dom_node_unref(node);
+ dom_string_unref(type);
+ continue;
+ }
+
+ dom_string_unref(type);
+
+ exc =
dom_html_input_element_get_value((dom_html_input_element *)node, &test_value);
+
+ if (test_value == NULL) {
+ if (goal_is_on) {
+ dom_string_unref(test_value);
+ break;
+ }
+ } else {
+ if (dom_string_caseless_isequal(test_value,
value)) {
+ dom_string_unref(test_value);
+ break;
+ }
+ }
+
+ dom_string_unref(test_value);
+ }
+
+ dom_node_unref(node);
+ node = NULL;
+ }
+
+ exc = DOM_NO_ERR;
+
+ /* 2. If element is not null, then set its checkedness to true. */
+ if (node != NULL) {
+ exc =
dom_html_input_element_set_checked((dom_html_input_element *)node, true);
+ }
+
+ dom_node_unref(node);
+
+ return exc;
}
--
Document Object Model library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org