summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-09 18:31:36 (GMT)
committer Rupinder Singh Khokhar <rsk1coder99@gmail.com>2014-06-21 12:07:15 (GMT)
commit8549b274b52ba00f4d82d514b3a2d264fd74e09f (patch)
tree59533299dad0519b8b2e92f75aa3b6d8848c27e9
parent65e8e13c19d77fdac70b7c6dfa8e4a7a736e49b1 (diff)
downloadlibdom-8549b274b52ba00f4d82d514b3a2d264fd74e09f.tar.gz
libdom-8549b274b52ba00f4d82d514b3a2d264fd74e09f.tar.bz2
Input Element checked on clicking fix and also fixed bubbling and cancelability
-rw-r--r--src/html/TODO4
-rw-r--r--src/html/html_input_element.c31
-rw-r--r--src/html/html_input_element.h2
-rw-r--r--test/testcases/tests/level1/html/HTMLInputElement21.xml (renamed from test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail)0
4 files changed, 27 insertions, 10 deletions
diff --git a/src/html/TODO b/src/html/TODO
index 83ff515..b55a6d7 100644
--- a/src/html/TODO
+++ b/src/html/TODO
@@ -15,9 +15,9 @@ HTMLFormElement html_form_element DONE
HTMLSelectElement html_select_element DONE
HTMLOptGroupElement html_optgroup_element DONE
HTMLOptionElement html_option_element DONE
-HTMLInputElement html_input_element MISSING
+HTMLInputElement html_input_element DONE
HTMLTextAreaElement html_textarea_element DONE
-HTMLButtonElement html_button_element MISSING
+HTMLButtonElement html_button_element DONE
HTMLLabelElement html_label_element DONE
HTMLFieldSetElement html_fieldset_element DONE
HTMLLegendElement html_legend_element DONE
diff --git a/src/html/html_input_element.c b/src/html/html_input_element.c
index c4cfc05..84079f7 100644
--- a/src/html/html_input_element.c
+++ b/src/html/html_input_element.c
@@ -65,6 +65,8 @@ dom_exception _dom_html_input_element_initialise(struct dom_html_document *doc,
ele->default_checked_set = false;
ele->default_value = NULL;
ele->default_value_set = false;
+ ele->checked = false;
+ ele->checked_set = false;
return _dom_html_element_initialise(doc, &ele->base,
doc->memoised[hds_INPUT],
@@ -166,6 +168,11 @@ dom_exception dom_html_input_element_set_read_only(dom_html_input_element *ele,
dom_exception dom_html_input_element_get_checked(dom_html_input_element *ele,
bool *checked)
{
+ if(ele->checked_set) {
+ *checked = ele->checked;
+ return DOM_NO_ERR;
+ }
+
return dom_html_element_get_bool_property(&ele->base, "checked",
SLEN("checked"), checked);
}
@@ -447,11 +454,11 @@ dom_exception dom_html_input_element_focus(dom_html_input_element *ele)
bool success = false;
assert(doc != NULL);
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
+ /** \this event doesnt bubble and is non-cancelable src:wikipedia*/
return _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
- doc->memoised[hds_focus], true,
- true, &success);
+ doc->memoised[hds_focus], false,
+ false, &success);
}
/**
@@ -467,11 +474,11 @@ dom_exception dom_html_input_element_select(dom_html_input_element *ele)
bool success = false;
assert(doc != NULL);
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
+ /** \this event bubbles and non-cancelable src:wikipedia*/
return _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
doc->memoised[hds_select], true,
- true, &success);
+ false, &success);
}
/**
@@ -485,13 +492,21 @@ dom_exception dom_html_input_element_click(dom_html_input_element *ele)
struct dom_html_document *doc =
(dom_html_document *) dom_node_get_owner(ele);
bool success = false;
+ dom_exception err;
assert(doc != NULL);
- /** \todo Is this is meant to check/uncheck boxes, radios etc */
- /** \todo Is this event (a) default (b) bubbling and (c) cancelable? */
- return _dom_dispatch_generic_event((dom_document *)doc,
+
+ /** \This event bubbles & is cancelable src:Wikipedia*/
+ err = _dom_dispatch_generic_event((dom_document *)doc,
(dom_event_target *) ele,
doc->memoised[hds_click], true,
true, &success);
+ if(err != DOM_NO_ERR)
+ return err;
+
+ ele->checked = true;
+ ele->checked_set = true;
+
+ return DOM_NO_ERR;
}
diff --git a/src/html/html_input_element.h b/src/html/html_input_element.h
index 72c7d51..b818b2e 100644
--- a/src/html/html_input_element.h
+++ b/src/html/html_input_element.h
@@ -21,6 +21,8 @@ struct dom_html_input_element {
bool default_checked_set; /**< Whether default_checked has been set */
dom_string *default_value; /**< Initial value */
bool default_value_set; /**< Whether default_value has been set */
+ bool checked; /**< Whether the element has been checked by a click */
+ bool checked_set;
};
/* Create a dom_html_input_element object */
diff --git a/test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail b/test/testcases/tests/level1/html/HTMLInputElement21.xml
index 57fbc76..57fbc76 100644
--- a/test/testcases/tests/level1/html/HTMLInputElement21.xml.kfail
+++ b/test/testcases/tests/level1/html/HTMLInputElement21.xml