Gitweb links:

...log 
http://git.netsurf-browser.org/libdom.git/shortlog/596deba4c83454f10a2de0740eb1b4b0ef344cd2
...commit 
http://git.netsurf-browser.org/libdom.git/commit/596deba4c83454f10a2de0740eb1b4b0ef344cd2
...tree 
http://git.netsurf-browser.org/libdom.git/tree/596deba4c83454f10a2de0740eb1b4b0ef344cd2

The branch, dsilvers/forms1 has been updated
       via  596deba4c83454f10a2de0740eb1b4b0ef344cd2 (commit)
      from  68a89f33cc8d2d9e6b2fd82739b713b4ed323a9d (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=596deba4c83454f10a2de0740eb1b4b0ef344cd2
commit 596deba4c83454f10a2de0740eb1b4b0ef344cd2
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    foldme; get_value

diff --git a/include/dom/html/html_radio_nodelist.h 
b/include/dom/html/html_radio_nodelist.h
index fd4c710..c15ec7c 100644
--- a/include/dom/html/html_radio_nodelist.h
+++ b/include/dom/html/html_radio_nodelist.h
@@ -15,19 +15,19 @@ struct dom_node;
 
 typedef struct dom_html_radio_nodelist dom_html_radio_nodelist;
 
-dom_exception dom_html_radio_nodelist_get_length(dom_html_radio_nodelist *col,
+dom_exception dom_html_radio_nodelist_get_length(dom_html_radio_nodelist 
*nodelist,
                uint32_t *len);
-dom_exception dom_html_radio_nodelist_item(dom_html_radio_nodelist *col,
+dom_exception dom_html_radio_nodelist_item(dom_html_radio_nodelist *nodelist,
                uint32_t index, struct dom_node **node);
 
-dom_exception dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *col,
+dom_exception dom_html_radio_nodelist_get_value(dom_html_radio_nodelist 
*nodelist,
                                               dom_string **value);
 
-dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist *col,
-                                              dom_string **value);
+dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist 
*nodelist,
+                                              dom_string *value);
 
-void dom_html_radio_nodelist_ref(dom_html_radio_nodelist *col);
-void dom_html_radio_nodelist_unref(dom_html_radio_nodelist *col);
+void dom_html_radio_nodelist_ref(dom_html_radio_nodelist *nodelist);
+void dom_html_radio_nodelist_unref(dom_html_radio_nodelist *nodelist);
 
 #endif
 
diff --git a/src/html/html_document_strings.h b/src/html/html_document_strings.h
index 8b5fea7..26c4dde 100644
--- a/src/html/html_document_strings.h
+++ b/src/html/html_document_strings.h
@@ -145,6 +145,9 @@ HTML_DOCUMENT_STRINGS_ACTION1(select)
 HTML_DOCUMENT_STRINGS_ACTION1(click)
 HTML_DOCUMENT_STRINGS_ACTION1(submit)
 HTML_DOCUMENT_STRINGS_ACTION1(reset)
+/* For dom_html_radio_nodelist */
+HTML_DOCUMENT_STRINGS_ACTION1(on)
+HTML_DOCUMENT_STRINGS_ACTION1(radio)
 
 #ifdef HTML_DOCUMENT_STRINGS_SUFFIX
 HTML_DOCUMENT_STRINGS_SUFFIX
diff --git a/src/html/html_radio_nodelist.c b/src/html/html_radio_nodelist.c
index 231900e..bf0570b 100644
--- a/src/html/html_radio_nodelist.c
+++ b/src/html/html_radio_nodelist.c
@@ -11,6 +11,7 @@
 #include <libwapcaplet/libwapcaplet.h>
 
 #include <dom/html/html_radio_nodelist.h>
+#include <dom/html/html_input_element.h>
 
 #include "html/html_radio_nodelist.h"
 #include "html/html_form_controls_collection.h"
@@ -197,3 +198,135 @@ void 
dom_html_radio_nodelist_unref(dom_html_radio_nodelist *nodelist)
        if (nodelist->refcnt == 0)
                _dom_html_radio_nodelist_destroy(nodelist);
 }
+
+
+/**
+ * Retrieve the length of a node list
+ *
+ * \param nodelist List to retrieve length of
+ * \param len  Pointer to location to receive length
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_html_radio_nodelist_get_length(dom_html_radio_nodelist 
*nodelist,
+               uint32_t *len)
+{
+       return dom_html_collection_get_length(nodelist->col, len);
+}
+
+/**
+ * Retrieve an item from a node list
+ *
+ * \param nodelist The list to retrieve the item from
+ * \param index  The list index to retrieve
+ * \param node   Pointer to location to receive item
+ * \return DOM_NO_ERR.
+ *
+ * ::index is a zero-based index into ::list.
+ * ::index lies in the range [0, length-1]
+ *
+ * The returned node will have had its reference count increased. The client
+ * should unref the node once it has finished with it.
+ */
+dom_exception dom_html_radio_nodelist_item(dom_html_radio_nodelist *nodelist,
+               uint32_t index, struct dom_node **node)
+{
+       return dom_html_collection_item(nodelist->col, index, node);
+}
+
+/**
+ * Retrieve the value of the radio nodelist per 2.7.2.2.
+ *
+ * \param nodelist The list to retrieve the value from
+ * \param value The value string to fill out
+ * \return DOM_NO_ERR
+ */
+dom_exception dom_html_radio_nodelist_get_value(dom_html_radio_nodelist 
*nodelist,
+                                              dom_string **value)
+{
+       dom_exception exc;
+       dom_node *node;
+       uint32_t count;
+       struct dom_html_document *doc =
+               (struct dom_html_document *)(((struct dom_node_internal 
*)nodelist->form)->owner);
+
+       assert(doc != NULL);
+
+       exc = dom_html_collection_get_length(nodelist->col, &count);
+
+       if (exc != DOM_NO_ERR)
+               return exc;
+
+       /* 1. 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 checkedness is
+        * true. Otherwise, let it 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])) {
+                       bool checked = false;
+                       dom_string *type;
+
+                       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);
+                               continue;
+                       }
+
+                       exc = 
dom_html_input_element_get_checked((dom_html_input_element *)node, &checked);
+
+                       if (exc != DOM_NO_ERR) {
+                               dom_node_unref(node);
+                               return exc;
+                       }
+                       if (checked == true)
+                               break;
+               }
+
+               dom_node_unref(node);
+               node = NULL;
+       }
+
+       /* 2. If element is null, return the empty string. */
+       if (node == NULL) {
+               *value = doc->base._memo_empty;
+               dom_string_ref(*value);
+               return DOM_NO_ERR;
+       }
+
+       exc = dom_html_input_element_get_value((dom_html_input_element *)node, 
value);
+
+       /* 3. If element is an element with no value attribute, return the
+        * string "on".
+        */
+       if (*value == NULL) {
+               *value = doc->memoised[hds_on];
+               dom_string_ref(*value);
+               return DOM_NO_ERR;
+       }
+
+       /* 4. Otherwise, return the value of element’s value attribute. */
+
+       return DOM_NO_ERR;
+}
+
+dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist 
*nodelist,
+                                              dom_string *value)
+{
+       (void)nodelist;
+       (void)value;
+
+       return DOM_NO_ERR;
+}


-----------------------------------------------------------------------

Summary of changes:
 include/dom/html/html_radio_nodelist.h |   14 ++--
 src/html/html_document_strings.h       |    3 +
 src/html/html_radio_nodelist.c         |  133 ++++++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+), 7 deletions(-)

diff --git a/include/dom/html/html_radio_nodelist.h 
b/include/dom/html/html_radio_nodelist.h
index fd4c710..c15ec7c 100644
--- a/include/dom/html/html_radio_nodelist.h
+++ b/include/dom/html/html_radio_nodelist.h
@@ -15,19 +15,19 @@ struct dom_node;
 
 typedef struct dom_html_radio_nodelist dom_html_radio_nodelist;
 
-dom_exception dom_html_radio_nodelist_get_length(dom_html_radio_nodelist *col,
+dom_exception dom_html_radio_nodelist_get_length(dom_html_radio_nodelist 
*nodelist,
                uint32_t *len);
-dom_exception dom_html_radio_nodelist_item(dom_html_radio_nodelist *col,
+dom_exception dom_html_radio_nodelist_item(dom_html_radio_nodelist *nodelist,
                uint32_t index, struct dom_node **node);
 
-dom_exception dom_html_radio_nodelist_get_value(dom_html_radio_nodelist *col,
+dom_exception dom_html_radio_nodelist_get_value(dom_html_radio_nodelist 
*nodelist,
                                               dom_string **value);
 
-dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist *col,
-                                              dom_string **value);
+dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist 
*nodelist,
+                                              dom_string *value);
 
-void dom_html_radio_nodelist_ref(dom_html_radio_nodelist *col);
-void dom_html_radio_nodelist_unref(dom_html_radio_nodelist *col);
+void dom_html_radio_nodelist_ref(dom_html_radio_nodelist *nodelist);
+void dom_html_radio_nodelist_unref(dom_html_radio_nodelist *nodelist);
 
 #endif
 
diff --git a/src/html/html_document_strings.h b/src/html/html_document_strings.h
index 8b5fea7..26c4dde 100644
--- a/src/html/html_document_strings.h
+++ b/src/html/html_document_strings.h
@@ -145,6 +145,9 @@ HTML_DOCUMENT_STRINGS_ACTION1(select)
 HTML_DOCUMENT_STRINGS_ACTION1(click)
 HTML_DOCUMENT_STRINGS_ACTION1(submit)
 HTML_DOCUMENT_STRINGS_ACTION1(reset)
+/* For dom_html_radio_nodelist */
+HTML_DOCUMENT_STRINGS_ACTION1(on)
+HTML_DOCUMENT_STRINGS_ACTION1(radio)
 
 #ifdef HTML_DOCUMENT_STRINGS_SUFFIX
 HTML_DOCUMENT_STRINGS_SUFFIX
diff --git a/src/html/html_radio_nodelist.c b/src/html/html_radio_nodelist.c
index 231900e..bf0570b 100644
--- a/src/html/html_radio_nodelist.c
+++ b/src/html/html_radio_nodelist.c
@@ -11,6 +11,7 @@
 #include <libwapcaplet/libwapcaplet.h>
 
 #include <dom/html/html_radio_nodelist.h>
+#include <dom/html/html_input_element.h>
 
 #include "html/html_radio_nodelist.h"
 #include "html/html_form_controls_collection.h"
@@ -197,3 +198,135 @@ void 
dom_html_radio_nodelist_unref(dom_html_radio_nodelist *nodelist)
        if (nodelist->refcnt == 0)
                _dom_html_radio_nodelist_destroy(nodelist);
 }
+
+
+/**
+ * Retrieve the length of a node list
+ *
+ * \param nodelist List to retrieve length of
+ * \param len  Pointer to location to receive length
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_html_radio_nodelist_get_length(dom_html_radio_nodelist 
*nodelist,
+               uint32_t *len)
+{
+       return dom_html_collection_get_length(nodelist->col, len);
+}
+
+/**
+ * Retrieve an item from a node list
+ *
+ * \param nodelist The list to retrieve the item from
+ * \param index  The list index to retrieve
+ * \param node   Pointer to location to receive item
+ * \return DOM_NO_ERR.
+ *
+ * ::index is a zero-based index into ::list.
+ * ::index lies in the range [0, length-1]
+ *
+ * The returned node will have had its reference count increased. The client
+ * should unref the node once it has finished with it.
+ */
+dom_exception dom_html_radio_nodelist_item(dom_html_radio_nodelist *nodelist,
+               uint32_t index, struct dom_node **node)
+{
+       return dom_html_collection_item(nodelist->col, index, node);
+}
+
+/**
+ * Retrieve the value of the radio nodelist per 2.7.2.2.
+ *
+ * \param nodelist The list to retrieve the value from
+ * \param value The value string to fill out
+ * \return DOM_NO_ERR
+ */
+dom_exception dom_html_radio_nodelist_get_value(dom_html_radio_nodelist 
*nodelist,
+                                              dom_string **value)
+{
+       dom_exception exc;
+       dom_node *node;
+       uint32_t count;
+       struct dom_html_document *doc =
+               (struct dom_html_document *)(((struct dom_node_internal 
*)nodelist->form)->owner);
+
+       assert(doc != NULL);
+
+       exc = dom_html_collection_get_length(nodelist->col, &count);
+
+       if (exc != DOM_NO_ERR)
+               return exc;
+
+       /* 1. 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 checkedness is
+        * true. Otherwise, let it 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])) {
+                       bool checked = false;
+                       dom_string *type;
+
+                       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);
+                               continue;
+                       }
+
+                       exc = 
dom_html_input_element_get_checked((dom_html_input_element *)node, &checked);
+
+                       if (exc != DOM_NO_ERR) {
+                               dom_node_unref(node);
+                               return exc;
+                       }
+                       if (checked == true)
+                               break;
+               }
+
+               dom_node_unref(node);
+               node = NULL;
+       }
+
+       /* 2. If element is null, return the empty string. */
+       if (node == NULL) {
+               *value = doc->base._memo_empty;
+               dom_string_ref(*value);
+               return DOM_NO_ERR;
+       }
+
+       exc = dom_html_input_element_get_value((dom_html_input_element *)node, 
value);
+
+       /* 3. If element is an element with no value attribute, return the
+        * string "on".
+        */
+       if (*value == NULL) {
+               *value = doc->memoised[hds_on];
+               dom_string_ref(*value);
+               return DOM_NO_ERR;
+       }
+
+       /* 4. Otherwise, return the value of element’s value attribute. */
+
+       return DOM_NO_ERR;
+}
+
+dom_exception dom_html_radio_nodelist_set_value(dom_html_radio_nodelist 
*nodelist,
+                                              dom_string *value)
+{
+       (void)nodelist;
+       (void)value;
+
+       return DOM_NO_ERR;
+}


-- 
Document Object Model library

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to