summaryrefslogtreecommitdiff
path: root/content/handlers/html/html.c
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/html.c
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/html.c')
-rw-r--r--content/handlers/html/html.c20
1 files changed, 20 insertions, 0 deletions
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;
}