From 05c6ee02d99ea04dde6687d94508b40f4393f77b Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 4 Aug 2019 22:07:42 +0100 Subject: 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 --- content/handlers/html/html.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'content/handlers/html/html.c') diff --git a/content/handlers/html/html.c b/content/handlers/html/html.c index 7280ff66a..f72284daf 100644 --- a/content/handlers/html/html.c +++ b/content/handlers/html/html.c @@ -829,6 +829,23 @@ dom_default_action_DOMNodeInsertedIntoDocument_cb(struct dom_event *evt, void *p } } +/* Deal with input elements being modified by resyncing their gadget + * if they have one. + */ +static void html_texty_element_update(html_content *htmlc, dom_node *node) +{ + struct box *box = box_for_node(node); + if (box == NULL) { + return; /* No Box (yet?) so no gadget to update */ + } + if (box->gadget == NULL) { + return; /* No gadget yet (under construction perhaps?) */ + } + form_gadget_sync_with_dom(box->gadget); + /* And schedule a redraw for the box */ + html__redraw_a_box(htmlc, box); +} + /* callback for DOMSubtreeModified end type */ static void dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw) @@ -861,6 +878,9 @@ dom_default_action_DOMSubtreeModified_cb(struct dom_event *evt, void *pw) case DOM_HTML_ELEMENT_TYPE_STYLE: html_css_update_style(htmlc, (dom_node *)node); break; + case DOM_HTML_ELEMENT_TYPE_TEXTAREA: + case DOM_HTML_ELEMENT_TYPE_INPUT: + html_texty_element_update(htmlc, (dom_node *)node); default: break; } -- cgit v1.2.3