Changeset 47767 in webkit
- Timestamp:
- Aug 25, 2009 5:51:02 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r47763 r47767 1 2009-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 1 13 2009-08-25 Eric Carlson <eric.carlson@apple.com> 2 14 -
trunk/WebCore/ChangeLog
r47763 r47767 1 2009-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 1 19 2009-08-25 Eric Carlson <eric.carlson@apple.com> 2 20 -
trunk/WebCore/html/HTMLAttributeNames.in
r47655 r47767 99 99 leftmargin 100 100 link 101 list 101 102 longdesc 102 103 loop -
trunk/WebCore/html/HTMLInputElement.cpp
r47702 r47767 40 40 #include "FormDataList.h" 41 41 #include "Frame.h" 42 #include "HTMLDataListElement.h" 42 43 #include "HTMLFormElement.h" 43 44 #include "HTMLImageLoader.h" 44 45 #include "HTMLNames.h" 46 #include "HTMLOptionElement.h" 45 47 #include "ScriptEventListener.h" 46 48 #include "KeyboardEvent.h" … … 736 738 attr->name() == precisionAttr) 737 739 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 738 745 else 739 746 HTMLFormControlElementWithState::parseMappedAttribute(attr); … … 1766 1773 } 1767 1774 1775 #if ENABLE(DATALIST) 1776 HTMLDataListElement* 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 1809 HTMLOptionElement* 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 1768 1830 } // namespace -
trunk/WebCore/html/HTMLInputElement.h
r47702 r47767 32 32 33 33 class FileList; 34 class HTMLDataListElement; 34 35 class HTMLImageLoader; 36 class HTMLOptionElement; 35 37 class KURL; 36 38 class VisibleSelection; … … 195 197 void setSrc(const String&); 196 198 199 #if ENABLE(DATALIST) 200 HTMLDataListElement* list(); 201 HTMLOptionElement* selectedOption(); 202 #endif 203 197 204 int maxLength() const; 198 205 void setMaxLength(int); … … 260 267 bool m_autofilled : 1; 261 268 bool m_inited : 1; 269 #if ENABLE(DATALIST) 270 bool m_hasNonEmptyList : 1; 271 #endif 262 272 }; 263 273 -
trunk/WebCore/html/HTMLInputElement.idl
r47655 r47767 40 40 attribute boolean disabled; 41 41 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 42 48 attribute long maxLength; 43 49 attribute boolean multiple; … … 57 63 attribute [ConvertNullToNullString] DOMString useMap; 58 64 attribute [ConvertNullToNullString] DOMString value; 65 #if defined(ENABLE_DATALIST) && ENABLE_DATALIST 66 readonly attribute HTMLOptionElement selectedOption; 67 #endif 59 68 readonly attribute boolean willValidate; 60 69 boolean checkValidity();
Note: See TracChangeset
for help on using the changeset viewer.