summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2016-02-05 16:40:51 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2016-02-05 16:40:51 +0000
commit9f795a621007766624885e52fc914e1b1d0af2dc (patch)
treec48c4326c4d31d19f12664c21bda2bff9500806b /src
parentd3dd1267f3524c999f33bd286c115739f8caee28 (diff)
downloadlibdom-9f795a621007766624885e52fc914e1b1d0af2dc.tar.gz
libdom-9f795a621007766624885e52fc914e1b1d0af2dc.tar.bz2
Provide generic copy constructor for HTMLInputElement.
Diffstat (limited to 'src')
-rw-r--r--src/html/html_input_element.c35
-rw-r--r--src/html/html_input_element.h9
2 files changed, 41 insertions, 3 deletions
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index 2dc0dc3..dac2473 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -303,10 +303,39 @@ void _dom_virtual_html_input_element_destroy(dom_node_internal *node)
}
/* The virtual copy function, see src/core/node.c for detail */
-dom_exception _dom_html_input_element_copy(dom_node_internal *old,
- dom_node_internal **copy)
+dom_exception _dom_html_input_element_copy(
+ dom_node_internal *old, dom_node_internal **copy)
{
- return _dom_html_element_copy(old, copy);
+ dom_html_input_element *new_node;
+ dom_exception err;
+
+ new_node = malloc(sizeof(dom_html_input_element));
+ if (new_node == NULL)
+ return DOM_NO_MEM_ERR;
+
+ err = dom_html_input_element_copy_internal(old, new_node);
+ if (err != DOM_NO_ERR) {
+ free(new_node);
+ return err;
+ }
+
+ *copy = (dom_node_internal *) new_node;
+
+ return DOM_NO_ERR;
+}
+
+dom_exception _dom_html_input_element_copy_internal(
+ dom_html_input_element *old,
+ dom_html_input_element *new)
+{
+ dom_exception err;
+
+ err = dom_html_element_copy_internal(old, new);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
+ return DOM_NO_ERR;
}
/*-----------------------------------------------------------------------*/
diff --git a/src/html/html_input_element.h b/src/html/html_input_element.h
index b445888..3600561 100644
--- a/src/html/html_input_element.h
+++ b/src/html/html_input_element.h
@@ -61,5 +61,14 @@ dom_exception _dom_html_input_element_copy(dom_node_internal *old,
dom_exception _dom_html_input_element_set_form(
dom_html_input_element *input, dom_html_form_element *form);
+/* Helper functions*/
+dom_exception _dom_html_input_element_copy_internal(
+ dom_html_input_element *old,
+ dom_html_input_element *new);
+#define dom_html_input_element_copy_internal(o, n) \
+ _dom_html_input_element_copy_internal( \
+ (dom_html_input_element *) (o), \
+ (dom_html_input_element *) (n))
+
#endif