⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 110340 in webkit


Ignore:
Timestamp:
Mar 9, 2012, 3:11:47 PM (15 years ago)
Author:
alexis.menard@openbossa.org
Message:

Implement selectedOptions attribute of <select>.
https://bugs.webkit.org/show_bug.cgi?id=80631

Reviewed by Benjamin Poulain.

Source/WebCore:

Add a new collection as a member of HTMLSelectElement which is
used to store the selected elements. Extend HTMLCollection to
support the new collection type needed by this feature.

Reference : http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#dom-select-selectedoptions

Test: fast/dom/select-selectedOptions.html

  • html/CollectionType.h:
  • html/HTMLCollection.cpp:

(WebCore::HTMLCollection::shouldIncludeChildren):
(WebCore::HTMLCollection::isAcceptableElement):

  • html/HTMLSelectElement.cpp:

(WebCore::HTMLSelectElement::selectedOptions):
(WebCore):

  • html/HTMLSelectElement.h:

(HTMLSelectElement):

  • html/HTMLSelectElement.idl:

LayoutTests:

New tests to cover the feature.

  • fast/dom/select-selectedOptions-expected.txt: Added.
  • fast/dom/select-selectedOptions.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r110332 r110340  
     12012-03-09  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Implement selectedOptions attribute of <select>.
     4        https://bugs.webkit.org/show_bug.cgi?id=80631
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        New tests to cover the feature.
     9
     10        * fast/dom/select-selectedOptions-expected.txt: Added.
     11        * fast/dom/select-selectedOptions.html: Added.
     12
    1132012-03-09  Ken Buchanan  <kenrb@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r110338 r110340  
     12012-03-09  Alexis Menard  <alexis.menard@openbossa.org>
     2
     3        Implement selectedOptions attribute of <select>.
     4        https://bugs.webkit.org/show_bug.cgi?id=80631
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        Add a new collection as a member of HTMLSelectElement which is
     9        used to store the selected elements. Extend HTMLCollection to
     10        support the new collection type needed by this feature.
     11
     12        Reference : http://www.whatwg.org/specs/web-apps/current-work/multipage/the-button-element.html#dom-select-selectedoptions
     13
     14        Test: fast/dom/select-selectedOptions.html
     15
     16        * html/CollectionType.h:
     17        * html/HTMLCollection.cpp:
     18        (WebCore::HTMLCollection::shouldIncludeChildren):
     19        (WebCore::HTMLCollection::isAcceptableElement):
     20        * html/HTMLSelectElement.cpp:
     21        (WebCore::HTMLSelectElement::selectedOptions):
     22        (WebCore):
     23        * html/HTMLSelectElement.h:
     24        (HTMLSelectElement):
     25        * html/HTMLSelectElement.idl:
     26
    1272012-03-09  Tien-Ren Chen  <trchen@chromium.org>
    228
  • trunk/Source/WebCore/html/CollectionType.h

    r103883 r110340  
    5252    TRCells,      // all cells in this row
    5353    SelectOptions,
     54    SelectedOptions,
    5455    DataListOptions,
    5556    MapAreas,
  • trunk/Source/WebCore/html/HTMLCollection.cpp

    r107477 r110340  
    6262    case OtherCollection:
    6363    case SelectOptions:
     64    case SelectedOptions:
    6465    case DataListOptions:
    6566    case WindowNamedItems:
     
    115116    case SelectOptions:
    116117        return element->hasLocalName(optionTag);
     118    case SelectedOptions:
     119        if (element->hasLocalName(optionTag)) {
     120            HTMLOptionElement* option = static_cast<HTMLOptionElement*>(element);
     121            if (option->selected())
     122                return true;
     123        }
     124        return false;
    117125    case DataListOptions:
    118126        if (element->hasLocalName(optionTag)) {
  • trunk/Source/WebCore/html/HTMLSelectElement.cpp

    r109149 r110340  
    330330{
    331331    return childContext.isOnEncapsulationBoundary() && HTMLFormControlElementWithState::childShouldCreateRenderer(childContext);
     332}
     333
     334HTMLCollection* HTMLSelectElement::selectedOptions()
     335{
     336    if (!m_selectedOptionsCollection)
     337        m_selectedOptionsCollection = HTMLCollection::create(this, SelectedOptions);
     338    return m_selectedOptionsCollection.get();
    332339}
    333340
  • trunk/Source/WebCore/html/HTMLSelectElement.h

    r110055 r110340  
    6464
    6565    HTMLOptionsCollection* options();
     66    HTMLCollection* selectedOptions();
    6667
    6768    void optionElementChildrenChanged();
     
    179180
    180181    OwnPtr<HTMLOptionsCollection> m_optionsCollection;
     182    OwnPtr<HTMLCollection> m_selectedOptionsCollection;
    181183
    182184    // m_listItems contains HTMLOptionElement, HTMLOptGroupElement, and HTMLHRElement objects.
  • trunk/Source/WebCore/html/HTMLSelectElement.idl

    r109562 r110340  
    5454        void remove(in long index);
    5555#endif
     56        readonly attribute HTMLCollection selectedOptions;
    5657        attribute long selectedIndex;
    5758        attribute [TreatNullAs=NullString] DOMString value;
Note: See TracChangeset for help on using the changeset viewer.