summaryrefslogtreecommitdiff
path: root/content/handlers/html/form_internal.h
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-04 22:07:42 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-08-04 22:07:42 +0100
commit05c6ee02d99ea04dde6687d94508b40f4393f77b (patch)
tree47ead2087a29ecf2c89a22cc0281099142cb0e9f /content/handlers/html/form_internal.h
parente78dc4f5a945f2035f48c8dc01cd3b1d76f03c81 (diff)
downloadnetsurf-05c6ee02d99ea04dde6687d94508b40f4393f77b.tar.gz
netsurf-05c6ee02d99ea04dde6687d94508b40f4393f77b.tar.bz2
html: Mirror gadget values in and out of the DOM
Currently only supporting text input, password input, and hidden input, along with text areas, this mirrors the text values in and out of the DOM, allowing JS to adjust the gadget values and for the gadget values to be interrogated from JS. Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'content/handlers/html/form_internal.h')
-rw-r--r--content/handlers/html/form_internal.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/content/handlers/html/form_internal.h b/content/handlers/html/form_internal.h
index f76f126b4..657522488 100644
--- a/content/handlers/html/form_internal.h
+++ b/content/handlers/html/form_internal.h
@@ -72,6 +72,8 @@ struct image_input_coords {
/** Form control. */
struct form_control {
void *node; /**< Corresponding DOM node */
+ struct dom_string *node_value; /**< The last value sync'd with the DOM */
+ bool syncing; /**< Set if a DOM sync is in-progress */
struct html_content *html; /**< HTML content containing control */
form_control_type type; /**< Type of control */
@@ -81,6 +83,7 @@ struct form_control {
char *name; /**< Control name */
char *value; /**< Current value of control */
char *initial_value; /**< Initial value of control */
+ char *last_synced_value; /**< The last value sync'd to the DOM */
bool disabled; /**< Whether control is disabled */
struct box *box; /**< Box for control */
@@ -261,4 +264,18 @@ void form_radio_set(struct form_control *radio);
void form_gadget_update_value(struct form_control *control, char *value);
+/**
+ * Synchronise this gadget with its associated DOM node.
+ *
+ * If the DOM has changed and the gadget has not, the DOM's new value is
+ * imported into the gadget. If the gadget's value has changed and the DOM's
+ * has not, the gadget's value is pushed into the DOM.
+ * If both have changed, the gadget's value wins.
+ *
+ * \param control The form gadget to synchronise
+ *
+ * \note Currently this will only synchronise input gadgets (text/password)
+ */
+void form_gadget_sync_with_dom(struct form_control *control);
+
#endif