mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-27 00:40:15 +03:00
Reflect changes to select boxes into the DOM
This commit is contained in:
parent
0516e4c069
commit
9b8988dd23
@ -2853,7 +2853,7 @@ bool box_select_add_option(struct form_control *control, dom_node *n)
|
||||
if (text_nowrap == NULL)
|
||||
goto no_memory;
|
||||
|
||||
if (form_add_option(control, value, text_nowrap, selected) == false)
|
||||
if (form_add_option(control, value, text_nowrap, selected, n) == false)
|
||||
goto no_memory;
|
||||
|
||||
free(text);
|
||||
|
@ -278,10 +278,11 @@ void form_free_control(struct form_control *control)
|
||||
* \param value value of option, used directly (not copied)
|
||||
* \param text text for option, used directly (not copied)
|
||||
* \param selected this option is selected
|
||||
* \param node the DOM node this option is associated with
|
||||
* \return true on success, false on memory exhaustion
|
||||
*/
|
||||
bool form_add_option(struct form_control *control, char *value, char *text,
|
||||
bool selected)
|
||||
bool selected, void *node)
|
||||
{
|
||||
struct form_option *option;
|
||||
|
||||
@ -312,6 +313,8 @@ bool form_add_option(struct form_control *control, char *value, char *text,
|
||||
|
||||
control->data.select.num_items++;
|
||||
|
||||
option->node = node;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1140,12 +1143,15 @@ static void form__select_process_selection(html_content *html,
|
||||
if (control->data.select.multiple) {
|
||||
if (o->selected) {
|
||||
o->selected = false;
|
||||
dom_html_option_element_set_selected(o->node, false);
|
||||
control->data.select.num_selected--;
|
||||
} else {
|
||||
o->selected = true;
|
||||
dom_html_option_element_set_selected(o->node, true);
|
||||
control->data.select.num_selected++;
|
||||
}
|
||||
} else {
|
||||
dom_html_option_element_set_selected(o->node, true);
|
||||
o->selected = true;
|
||||
}
|
||||
}
|
||||
@ -1434,11 +1440,13 @@ void form_radio_set(html_content *html,
|
||||
|
||||
if (control->selected) {
|
||||
control->selected = false;
|
||||
dom_html_input_element_set_checked(control->node, false);
|
||||
html__redraw_a_box(html, control->box);
|
||||
}
|
||||
}
|
||||
|
||||
radio->selected = true;
|
||||
dom_html_input_element_set_checked(radio->node, true);
|
||||
html__redraw_a_box(html, radio->box);
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,7 @@ struct form_control {
|
||||
|
||||
/** Option in a select. */
|
||||
struct form_option {
|
||||
void *node; /**< Corresponding DOM node */
|
||||
bool selected;
|
||||
bool initial_selected;
|
||||
char *value;
|
||||
@ -154,7 +155,7 @@ struct form_control *form_new_control(void *node, form_control_type type);
|
||||
void form_add_control(struct form *form, struct form_control *control);
|
||||
void form_free_control(struct form_control *control);
|
||||
bool form_add_option(struct form_control *control, char *value, char *text,
|
||||
bool selected);
|
||||
bool selected, void *node);
|
||||
bool form_successful_controls(struct form *form,
|
||||
struct form_control *submit_button,
|
||||
struct fetch_multipart_data **successful_controls);
|
||||
|
Loading…
Reference in New Issue
Block a user