diff options
Diffstat (limited to 'Source/WebCore/html/HTMLInputElement.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLInputElement.cpp | 71 |
1 files changed, 65 insertions, 6 deletions
diff --git a/Source/WebCore/html/HTMLInputElement.cpp b/Source/WebCore/html/HTMLInputElement.cpp index 77ea42567..407c1233b 100644 --- a/Source/WebCore/html/HTMLInputElement.cpp +++ b/Source/WebCore/html/HTMLInputElement.cpp @@ -45,6 +45,7 @@ #include "HTMLNames.h" #include "HTMLOptionElement.h" #include "HTMLParserIdioms.h" +#include "IdTargetObserver.h" #include "InputType.h" #include "KeyboardEvent.h" #include "LocalizedStrings.h" @@ -77,6 +78,19 @@ namespace WebCore { using namespace HTMLNames; +#if ENABLE(DATALIST_ELEMENT) +class ListAttributeTargetObserver : IdTargetObserver { +public: + static PassOwnPtr<ListAttributeTargetObserver> create(const AtomicString& id, HTMLInputElement*); + virtual void idTargetChanged() OVERRIDE; + +private: + ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement*); + + HTMLInputElement* m_element; +}; +#endif + // FIXME: According to HTML4, the length attribute's value can be arbitrarily // large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things // get rather sluggish when a text field has a larger number of characters than @@ -183,6 +197,11 @@ HTMLElement* HTMLInputElement::speechButtonElement() const } #endif +HTMLElement* HTMLInputElement::sliderThumbElement() const +{ + return m_inputType->sliderThumbElement(); +} + HTMLElement* HTMLInputElement::placeholderElement() const { return m_inputType->placeholderElement(); @@ -678,10 +697,14 @@ void HTMLInputElement::parseAttribute(const Attribute& attribute) HTMLTextFormControlElement::parseAttribute(attribute); m_inputType->readonlyAttributeChanged(); } -#if ENABLE(DATALIST) - else if (attribute.name() == listAttr) +#if ENABLE(DATALIST_ELEMENT) + else if (attribute.name() == listAttr) { m_hasNonEmptyList = !attribute.isEmpty(); - // FIXME: we need to tell this change to a renderer if the attribute affects the appearance. + if (m_hasNonEmptyList) { + resetListAttributeTargetObserver(); + listAttributeTargetChanged(); + } + } #endif #if ENABLE(INPUT_SPEECH) else if (attribute.name() == webkitspeechAttr) { @@ -1412,6 +1435,9 @@ Node::InsertionNotificationRequest HTMLInputElement::insertedInto(ContainerNode* HTMLTextFormControlElement::insertedInto(insertionPoint); if (insertionPoint->inDocument() && !form()) addToRadioButtonGroup(); +#if ENABLE(DATALIST_ELEMENT) + resetListAttributeTargetObserver(); +#endif return InsertionDone; } @@ -1420,6 +1446,10 @@ void HTMLInputElement::removedFrom(ContainerNode* insertionPoint) if (insertionPoint->inDocument() && !form()) removeFromRadioButtonGroup(); HTMLTextFormControlElement::removedFrom(insertionPoint); + ASSERT(!inDocument()); +#if ENABLE(DATALIST_ELEMENT) + resetListAttributeTargetObserver(); +#endif } void HTMLInputElement::didMoveToNewDocument(Document* oldDocument) @@ -1468,8 +1498,7 @@ void HTMLInputElement::selectColorInColorChooser(const Color& color) } #endif -#if ENABLE(DATALIST) - +#if ENABLE(DATALIST_ELEMENT) HTMLElement* HTMLInputElement::list() const { return dataList(); @@ -1492,7 +1521,19 @@ HTMLDataListElement* HTMLInputElement::dataList() const return static_cast<HTMLDataListElement*>(element); } -#endif // ENABLE(DATALIST) +void HTMLInputElement::resetListAttributeTargetObserver() +{ + if (inDocument()) + m_listAttributeTargetObserver = ListAttributeTargetObserver::create(fastGetAttribute(listAttr), this); + else + m_listAttributeTargetObserver = nullptr; +} + +void HTMLInputElement::listAttributeTargetChanged() +{ + m_inputType->listAttributeTargetChanged(); +} +#endif // ENABLE(DATALIST_ELEMENT) bool HTMLInputElement::isSteppable() const { @@ -1760,4 +1801,22 @@ void HTMLInputElement::setWidth(unsigned width) setAttribute(widthAttr, String::number(width)); } +#if ENABLE(DATALIST_ELEMENT) +PassOwnPtr<ListAttributeTargetObserver> ListAttributeTargetObserver::create(const AtomicString& id, HTMLInputElement* element) +{ + return adoptPtr(new ListAttributeTargetObserver(id, element)); +} + +ListAttributeTargetObserver::ListAttributeTargetObserver(const AtomicString& id, HTMLInputElement* element) + : IdTargetObserver(element->treeScope()->idTargetObserverRegistry(), id) + , m_element(element) +{ +} + +void ListAttributeTargetObserver::idTargetChanged() +{ + m_element->listAttributeTargetChanged(); +} +#endif + } // namespace |