Changeset 57714 in webkit


Ignore:
Timestamp:
Apr 15, 2010 10:59:15 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-15 Luiz Agostini <luiz.agostini@openbossa.org>

Reviewed by Antti Koivisto.

No default selection for <select multiple> menu lists.
https://bugs.webkit.org/show_bug.cgi?id=37530

Manual test: manual-tests/no-listbox-rendering.html

For menu lists, if the selection is not indicated by the html file, the first <option> will be
selected after loading the page or reseting the form. On the other hand listboxes may have no
element selected after loading the page or reseting the form.

When NO_LISTBOX_RENDERING is enabled listboxes becomes menu lists. Those <select multiple>
that did not have selected elements, now being menu lists, will have the first <option>
selected. That is the behavior difference that this patch corrects.

When NO_LISTBOX_RENDERING is enabled usesMenuList() always returns true then usesMenuList() cannot
be used to decide about initial selection of the elements. This patch replaces (usesMenuLists())
by (!multiple && size <= 1) where initial selection is considered.

  • dom/SelectElement.cpp: (WebCore::SelectElement::recalcListItems): (WebCore::SelectElement::reset):
  • manual-tests/no-listbox-rendering.html: Added.
Location:
trunk/WebCore
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57709 r57714  
     12010-04-15  Luiz Agostini  <luiz.agostini@openbossa.org>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        No default selection for <select multiple> menu lists.
     6        https://bugs.webkit.org/show_bug.cgi?id=37530
     7
     8        Manual test: manual-tests/no-listbox-rendering.html
     9
     10        For menu lists, if the selection is not indicated by the html file, the first <option> will be
     11        selected after loading the page or reseting the form. On the other hand listboxes may have no
     12        element selected after loading the page or reseting the form.
     13
     14        When NO_LISTBOX_RENDERING is enabled listboxes becomes menu lists. Those <select multiple>
     15        that did not have selected elements, now being menu lists, will have the first <option>
     16        selected. That is the behavior difference that this patch corrects.
     17
     18        When NO_LISTBOX_RENDERING is enabled usesMenuList() always returns true then usesMenuList() cannot
     19        be used to decide about initial selection of the elements. This patch replaces (usesMenuLists())
     20        by (!multiple && size <= 1) where initial selection is considered.
     21
     22        * dom/SelectElement.cpp:
     23        (WebCore::SelectElement::recalcListItems):
     24        (WebCore::SelectElement::reset):
     25        * manual-tests/no-listbox-rendering.html: Added.
     26
    1272010-04-15  Zhenyao Mo  <zmo@google.com>
    228
  • trunk/WebCore/dom/SelectElement.cpp

    r56180 r57714  
    271271            listItems.append(current);
    272272
    273             if (updateSelectedStates) {
    274                 if (!foundSelected && (data.usesMenuList() || (!data.multiple() && optionElement->selected()))) {
     273            if (updateSelectedStates && !data.multiple()) {
     274                if (!foundSelected && (data.size() <= 1 || optionElement->selected())) {
    275275                    foundSelected = optionElement;
    276276                    foundSelected->setSelectedState(true);
    277                 } else if (foundSelected && !data.multiple() && optionElement->selected()) {
     277                } else if (foundSelected && optionElement->selected()) {
    278278                    foundSelected->setSelectedState(false);
    279279                    foundSelected = optionElement;
     
    500500    }
    501501
    502     if (!selectedOption && firstOption && data.usesMenuList())
     502    if (!selectedOption && firstOption && !data.multiple() && data.size() <= 1)
    503503        firstOption->setSelectedState(true);
    504504
Note: See TracChangeset for help on using the changeset viewer.