changeset 205:97618a4195ba

- Implemented MULTIPLE SELECT in FORMS.
author jcid
date Mon, 05 May 2008 21:48:23 +0200
parents 5e0f4260c4f5
children 2180286fc604
files ChangeLog src/html.cc
diffstat 2 files changed, 16 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri May 02 20:01:48 2008 +0200
+++ b/ChangeLog	Mon May 05 21:48:23 2008 +0200
@@ -143,6 +143,7 @@
 +- Bound Ctrl-R to reload.
  - Made dialogs use font_factor (e.g. view source).
  - Implemented the SELECT element in FORMS!
+ - Implemented MULTIPLE SELECT in FORMS.
    Patches: Jeremy Henty
 +- Added int32_t, EAI_NODATA and iconv tests for FreeBSD.
    Patch: Thomas-Martin Seck
--- a/src/html.cc	Fri May 02 20:01:48 2008 +0200
+++ b/src/html.cc	Mon May 05 21:48:23 2008 +0200
@@ -4191,7 +4191,8 @@
             dStr_free(dstr, 1);
          }
       }
-      for (int i = 0; i < dList_length(values); i++) {
+      int length = dList_length(values);
+      for (int i = 0; i < length; i++) {
          dstr = (Dstr *) dList_nth_data(values, 0);
          dList_remove(values, dstr);
          if (input->type != DILLO_HTML_INPUT_FILE)
@@ -4283,8 +4284,8 @@
             Html_urlencode_append(DataStr, val->str);
             dStr_free(val, 1);
          } else {
-            int i;
-            for (i = 0; i < dList_length(values); i++) {
+            int length = dList_length(values), i;
+            for (i = 0; i < length; i++) {
                Dstr *val = (Dstr *) dList_nth_data(values, 0);
                dList_remove(values, val);
                val = Html_encode_text(encoder, &val);
@@ -4879,8 +4880,16 @@
 
    DilloHtmlForm *form = html->forms->getRef (html->forms->size() - 1);
    char *name = Html_get_attr_wdef(html, tag, tagsize, "name", NULL);
-   OptionMenuResource *res =
-      HT2LT(html)->getResourceFactory()->createOptionMenuResource ();
+   ResourceFactory *factory = HT2LT(html)->getResourceFactory ();
+   DilloHtmlInputType type;
+   SelectionResource *res;
+   if (Html_get_attr(html, tag, tagsize, "multiple")) {
+      type = DILLO_HTML_INPUT_SEL_LIST;
+      res = factory->createListResource (ListResource::SELECTION_MULTIPLE);
+   } else {
+      type = DILLO_HTML_INPUT_SELECT;
+      res = factory->createOptionMenuResource ();
+   }
    Widget *widget;
    Embed *embed;
    widget = embed = new Embed(res);
@@ -4912,8 +4921,7 @@
 
    DilloHtmlSelect *select = new DilloHtmlSelect;
    select->options = new misc::SimpleVector<DilloHtmlOption *> (4);
-   Html_add_input(form, DILLO_HTML_INPUT_SELECT, widget, embed, name,
-                  NULL, select, false);
+   Html_add_input(form, type, widget, embed, name, NULL, select, false);
    Html_stash_init(html);
    dFree(name);
 }