diff options
author | corvid <corvid@lavabit.com> | 2012-11-28 01:57:06 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2012-11-28 01:57:06 +0000 |
commit | bb58b5e5989f46809159b0e86cb5d76f3bf42055 (patch) | |
tree | 8a2b746aab77ee7f8a7e87b9b3b74d48fa93ebc3 | |
parent | f8c9c679460315d6e27f993bd996e601fa87f7fc (diff) |
don't require an item selected for SELECT size>1 non-multiple
This had been discussed a bit a few years ago. At the time, the html4 spec's
idea was that you probably should require one but that implementations varied
on the details.
These days, firefox doesn't, and html5 mostly tells you not to (and is clear
that you can deselect the only selected one). (The world's biggest document,
practically a browser written in english at the instruction level, and it
still has many cases that aren't considered and spelled out carefully at this
point.)
-rw-r--r-- | dw/fltkui.cc | 6 | ||||
-rw-r--r-- | src/form.cc | 16 |
2 files changed, 12 insertions, 10 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc index ac3997ab..1ef9b61b 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -1287,10 +1287,10 @@ void FltkListResource::setItem (int index, bool selected) if (item) { itemsSelected.set (index, selected); - if (mode == SELECTION_MULTIPLE) - item->select(selected); - else if (selected) + if (selected && mode != SELECTION_MULTIPLE) tree->select_only(item); + else + item->select(selected); queueResize (true); } } diff --git a/src/form.cc b/src/form.cc index d5bd71da..26ab8e0d 100644 --- a/src/form.cc +++ b/src/form.cc @@ -752,11 +752,12 @@ void Html_tag_open_select(DilloHtml *html, const char *tag, int tagsize) type = DILLO_HTML_INPUT_SELECT; res = factory->createOptionMenuResource (); } else { + ListResource::SelectionMode mode; + type = DILLO_HTML_INPUT_SEL_LIST; - res = factory->createListResource (multi ? - ListResource::SELECTION_MULTIPLE : - ListResource::SELECTION_EXACTLY_ONE, - rows); + mode = multi ? ListResource::SELECTION_MULTIPLE + : ListResource::SELECTION_AT_MOST_ONE; + res = factory->createListResource (mode, rows); } Embed *embed = new Embed(res); @@ -787,9 +788,10 @@ void Html_tag_close_select(DilloHtml *html) DilloHtmlInput *input = Html_get_current_input(html); DilloHtmlSelect *select = input->select; - // BUG(?): should not do this for MULTI selections - select->ensureSelection (); - + if (input->type == DILLO_HTML_INPUT_SELECT) { + // option menu interface requires that something be selected */ + select->ensureSelection (); + } SelectionResource *res = (SelectionResource*)input->embed->getResource(); select->addOptionsTo (res); } |