Fix select elements. Requires latest libdom.

This commit is contained in:
Michael Drake 2012-09-19 14:42:05 +01:00
parent ee9ab42f75
commit d5e1616a45
3 changed files with 58 additions and 0 deletions

View File

@ -454,6 +454,56 @@ out:
return control;
}
static struct form_control *
parse_select_element(struct form *forms, dom_html_select_element *select)
{
struct form_control *control = NULL;
dom_html_form_element *form = NULL;
dom_string *ds_name = NULL;
char *name = NULL;
if (dom_html_select_element_get_form(select, &form) != DOM_NO_ERR)
goto out;
if (dom_html_select_element_get_name(select, &ds_name) != DOM_NO_ERR)
goto out;
if (ds_name != NULL)
name = strndup(dom_string_data(ds_name),
dom_string_byte_length(ds_name));
control = form_new_control(select, GADGET_SELECT);
if (control == NULL)
goto out;
if (name != NULL) {
/* Hand the name string over */
control->name = name;
name = NULL;
}
dom_html_select_element_get_multiple(select,
&(control->data.select.multiple));
if (form != NULL && control != NULL)
form_add_control(find_form(forms, form), control);
out:
if (form != NULL)
dom_node_unref(form);
if (ds_name != NULL)
dom_string_unref(ds_name);
if (name != NULL)
free(name);
return control;
}
static struct form_control *
invent_fake_gadget(dom_node *node)
{
@ -505,6 +555,10 @@ struct form_control *html_forms_get_control_for_node(struct form *forms, dom_nod
corestring_lwc_textarea)) {
ctl = parse_textarea_element(forms,
(dom_html_text_area_element *) node);
} else if (dom_string_caseless_lwc_isequal(ds_name,
corestring_lwc_select)) {
ctl = parse_select_element(forms,
(dom_html_select_element *) node);
}
}

View File

@ -85,6 +85,7 @@ lwc_string *corestring_lwc_rectangle;
lwc_string *corestring_lwc_refresh;
lwc_string *corestring_lwc_reset;
lwc_string *corestring_lwc_right;
lwc_string *corestring_lwc_select;
lwc_string *corestring_lwc_src;
lwc_string *corestring_lwc_style;
lwc_string *corestring_lwc_submit;
@ -224,6 +225,7 @@ void corestrings_fini(void)
CSS_LWC_STRING_UNREF(refresh);
CSS_LWC_STRING_UNREF(reset);
CSS_LWC_STRING_UNREF(right);
CSS_LWC_STRING_UNREF(select);
CSS_LWC_STRING_UNREF(src);
CSS_LWC_STRING_UNREF(style);
CSS_LWC_STRING_UNREF(submit);
@ -382,6 +384,7 @@ nserror corestrings_init(void)
CSS_LWC_STRING_INTERN(refresh);
CSS_LWC_STRING_INTERN(reset);
CSS_LWC_STRING_INTERN(right);
CSS_LWC_STRING_INTERN(select);
CSS_LWC_STRING_INTERN(src);
CSS_LWC_STRING_INTERN(style);
CSS_LWC_STRING_INTERN(submit);

View File

@ -89,6 +89,7 @@ extern lwc_string *corestring_lwc_rectangle;
extern lwc_string *corestring_lwc_refresh;
extern lwc_string *corestring_lwc_reset;
extern lwc_string *corestring_lwc_right;
extern lwc_string *corestring_lwc_select;
extern lwc_string *corestring_lwc_src;
extern lwc_string *corestring_lwc_style;
extern lwc_string *corestring_lwc_submit;