Changeset 47767 in webkit


Ignore:
Timestamp:
Aug 25, 2009 5:51:02 PM (15 years ago)
Author:
eric@webkit.org
Message:

2009-08-25 Kent Tamura <tkent@chromium.org>

Reviewed by Eric Seidel.

Support for HTMLInputElement::list and HTMLInputElement::selectedOption.
https://bugs.webkit.org/show_bug.cgi?id=27756

Tests: fast/forms/input-list.html

fast/forms/input-selectedoption.html

  • html/HTMLAttributeNames.in:
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::parseMappedAttribute): (WebCore::HTMLInputElement::list): (WebCore::HTMLInputElement::selectedOption):
  • html/HTMLInputElement.h:
  • html/HTMLInputElement.idl:

2009-08-25 Kent Tamura <tkent@chromium.org>

Reviewed by Eric Seidel.

Support for HTMLInputElement::list and HTMLInputElement::selectedOption.
https://bugs.webkit.org/show_bug.cgi?id=27756

  • fast/forms/input-list-expected.txt: Added.
  • fast/forms/input-list.html: Added.
  • fast/forms/input-selectedoption-expected.txt: Added.
  • fast/forms/input-selectedoption.html: Added.
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r47763 r47767  
     12009-08-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Support for HTMLInputElement::list and HTMLInputElement::selectedOption.
     6        https://bugs.webkit.org/show_bug.cgi?id=27756
     7
     8        * fast/forms/input-list-expected.txt: Added.
     9        * fast/forms/input-list.html: Added.
     10        * fast/forms/input-selectedoption-expected.txt: Added.
     11        * fast/forms/input-selectedoption.html: Added.
     12
    1132009-08-25  Eric Carlson  <eric.carlson@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r47763 r47767  
     12009-08-25  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Support for HTMLInputElement::list and HTMLInputElement::selectedOption.
     6        https://bugs.webkit.org/show_bug.cgi?id=27756
     7
     8        Tests: fast/forms/input-list.html
     9               fast/forms/input-selectedoption.html
     10
     11        * html/HTMLAttributeNames.in:
     12        * html/HTMLInputElement.cpp:
     13        (WebCore::HTMLInputElement::parseMappedAttribute):
     14        (WebCore::HTMLInputElement::list):
     15        (WebCore::HTMLInputElement::selectedOption):
     16        * html/HTMLInputElement.h:
     17        * html/HTMLInputElement.idl:
     18
    1192009-08-25  Eric Carlson  <eric.carlson@apple.com>
    220
  • trunk/WebCore/html/HTMLAttributeNames.in

    r47655 r47767  
    9999leftmargin
    100100link
     101list
    101102longdesc
    102103loop
  • trunk/WebCore/html/HTMLInputElement.cpp

    r47702 r47767  
    4040#include "FormDataList.h"
    4141#include "Frame.h"
     42#include "HTMLDataListElement.h"
    4243#include "HTMLFormElement.h"
    4344#include "HTMLImageLoader.h"
    4445#include "HTMLNames.h"
     46#include "HTMLOptionElement.h"
    4547#include "ScriptEventListener.h"
    4648#include "KeyboardEvent.h"
     
    736738             attr->name() == precisionAttr)
    737739        setNeedsStyleRecalc();
     740#if ENABLE(DATALIST)
     741    else if (attr->name() == listAttr)
     742        m_hasNonEmptyList = !attr->isEmpty();
     743        // FIXME: we need to tell this change to a renderer if the attribute affects the appearance.
     744#endif
    738745    else
    739746        HTMLFormControlElementWithState::parseMappedAttribute(attr);
     
    17661773}
    17671774
     1775#if ENABLE(DATALIST)
     1776HTMLDataListElement* HTMLInputElement::list()
     1777{
     1778    if (!m_hasNonEmptyList)
     1779        return 0;
     1780
     1781    switch (inputType()) {
     1782    case TEXT:
     1783    case SEARCH:
     1784    case URL:
     1785    case TELEPHONE:
     1786    case EMAIL:
     1787    case NUMBER:
     1788    case RANGE: {
     1789        Element* element = document()->getElementById(getAttribute(listAttr));
     1790        if (element && element->hasTagName(datalistTag))
     1791            return static_cast<HTMLDataListElement*>(element);
     1792        break;
     1793    }
     1794    case HIDDEN:
     1795    case PASSWORD:
     1796    case CHECKBOX:
     1797    case RADIO:
     1798    case FILE:
     1799    case SUBMIT:
     1800    case IMAGE:
     1801    case RESET:
     1802    case BUTTON:
     1803    case ISINDEX:
     1804        break;
     1805    }
     1806    return 0;
     1807}
     1808
     1809HTMLOptionElement* HTMLInputElement::selectedOption()
     1810{
     1811    String currentValue = value();
     1812    // The empty value never matches to a datalist option because it
     1813    // doesn't represent a suggestion according to the standard.
     1814    if (currentValue.isEmpty())
     1815        return 0;
     1816
     1817    HTMLDataListElement* sourceElement = list();
     1818    if (!sourceElement)
     1819        return 0;
     1820    RefPtr<HTMLCollection> options = sourceElement->options();
     1821    for (unsigned i = 0; options && i < options->length(); ++i) {
     1822        HTMLOptionElement* option = static_cast<HTMLOptionElement*>(options->item(i));
     1823        if (!option->disabled() && currentValue == option->value())
     1824            return option;
     1825    }
     1826    return 0;
     1827}
     1828#endif  // ENABLE(DATALIST)
     1829
    17681830} // namespace
  • trunk/WebCore/html/HTMLInputElement.h

    r47702 r47767  
    3232
    3333class FileList;
     34class HTMLDataListElement;
    3435class HTMLImageLoader;
     36class HTMLOptionElement;
    3537class KURL;
    3638class VisibleSelection;
     
    195197    void setSrc(const String&);
    196198
     199#if ENABLE(DATALIST)
     200    HTMLDataListElement* list();
     201    HTMLOptionElement* selectedOption();
     202#endif
     203
    197204    int maxLength() const;
    198205    void setMaxLength(int);
     
    260267    bool m_autofilled : 1;
    261268    bool m_inited : 1;
     269#if ENABLE(DATALIST)
     270    bool m_hasNonEmptyList : 1;
     271#endif
    262272};
    263273
  • trunk/WebCore/html/HTMLInputElement.idl

    r47655 r47767  
    4040                 attribute boolean         disabled;
    4141                 attribute boolean         autofocus;
     42#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
     43                 // The type of the list is HTMLElement according to the standard.
     44                 // We intentionally use HTMLDataListElement for it because our implementation
     45                 // always returns an HTMLDataListElement instance.
     46        readonly attribute HTMLDataListElement list;
     47#endif
    4248                 attribute long            maxLength;
    4349                 attribute boolean         multiple;
     
    5763                 attribute [ConvertNullToNullString] DOMString useMap;
    5864                 attribute [ConvertNullToNullString] DOMString value;
     65#if defined(ENABLE_DATALIST) && ENABLE_DATALIST
     66        readonly attribute HTMLOptionElement selectedOption;
     67#endif
    5968        readonly attribute boolean         willValidate;
    6069        boolean            checkValidity();
Note: See TracChangeset for help on using the changeset viewer.