|author||Michael Drake <firstname.lastname@example.org>||2020-05-25 10:05:48 +0100|
|committer||Michael Drake <email@example.com>||2020-05-25 10:05:48 +0100|
Dev weekend: Update forms notes with current data structures section.
1 files changed, 28 insertions, 4 deletions
diff --git a/developer-weekend/may-2020.mdwn b/developer-weekend/may-2020.mdwn
index b97ca9d..589968c 100644
@@ -74,15 +74,15 @@ Write ups
Current Forms Handling
-### DOM / Gadget syncronisation
+### DOM / Gadget synchronization
Currently both the DOM and the NetSurf gadget for form input elements
store a representation of the current state of the form element.
-modifiy the repreentation in the form gadget.
+modify the representation in the form gadget.
There is a `form_gadget_sync_with_dom()` in NetSurf's `form.c`.
-This syncronises the data both ways. If the DOM has changed, then
+This synchronizes the data both ways. If the DOM has changed, then
the gadget representation is updated, and if the gadget has changed
then the DOM is updated. If both have changed, the gadget version
@@ -100,6 +100,30 @@ The `form_gadget_sync_with_dom()` is called from:
called during box tree construction of the special box elements in
+### NetSurf data structures
+The `box` structure has a "gadget" member, which is a `struct form_control`
+pointer. These gadget pointers are set to the corresponding form_control
+when the form_control is created during box construction.
+The `html` content contains a forms linked list. These are of type
+`struct form`. The linked list is created by `html_forms_get_forms()` in
+**[html/forms.c]**, called from `html_begin_conversion()` in **[html/html.c]**.
+Since box tree construction hasn't happened yet, this collects a list of
+forms which are empty, containing no form controls.
+The form controls are added to the form structures as the forms are created
+during box construction. Box construction happens later in the `dom_to_box`
+call in `html_finish_conversion`.
+The fact that the form controls are referenced in both the form structures
+and from the box gadget member, and the fact that they aren't ref-counted
+means that we often dare not free them. So they leak everywhere.
+It seems that the struct form is only created for the purposes of form
+submission; to collect all the gadgets associated with the form.
Once more unto the breach dear friends…