diff options
Diffstat (limited to 'WebCore/html/HTMLOptionElement.cpp')
-rw-r--r-- | WebCore/html/HTMLOptionElement.cpp | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/WebCore/html/HTMLOptionElement.cpp b/WebCore/html/HTMLOptionElement.cpp index e59537d..66968b0 100644 --- a/WebCore/html/HTMLOptionElement.cpp +++ b/WebCore/html/HTMLOptionElement.cpp @@ -30,9 +30,10 @@ #include "ExceptionCode.h" #include "HTMLNames.h" #include "HTMLSelectElement.h" +#include "MappedAttribute.h" +#include "NodeRenderStyle.h" #include "RenderMenuList.h" #include "Text.h" -#include "NodeRenderStyle.h" #include <wtf/StdLibExtras.h> #include <wtf/Vector.h> @@ -42,7 +43,6 @@ using namespace HTMLNames; HTMLOptionElement::HTMLOptionElement(const QualifiedName& tagName, Document* doc, HTMLFormElement* f) : HTMLFormControlElement(tagName, doc, f) - , m_data(this) , m_style(0) { ASSERT(hasTagName(optionTag)); @@ -71,7 +71,7 @@ bool HTMLOptionElement::isFocusable() const return HTMLElement::isFocusable(); } -const AtomicString& HTMLOptionElement::type() const +const AtomicString& HTMLOptionElement::formControlType() const { DEFINE_STATIC_LOCAL(const AtomicString, option, ("option")); return option; @@ -79,7 +79,7 @@ const AtomicString& HTMLOptionElement::type() const String HTMLOptionElement::text() const { - return OptionElement::collectOptionText(m_data, document()); + return OptionElement::collectOptionText(m_data, this); } void HTMLOptionElement::setText(const String &text, ExceptionCode& ec) @@ -104,22 +104,7 @@ void HTMLOptionElement::accessKeyAction(bool) int HTMLOptionElement::index() const { - // Let's do this dynamically. Might be a bit slow, but we're sure - // we won't forget to update a member variable in some cases... - HTMLSelectElement* select = ownerSelectElement(); - if (select) { - const Vector<HTMLElement*>& items = select->listItems(); - int l = items.size(); - int optionIndex = 0; - for(int i = 0; i < l; i++) { - if (items[i]->hasLocalName(optionTag)) { - if (static_cast<HTMLOptionElement*>(items[i]) == this) - return optionIndex; - optionIndex++; - } - } - } - return 0; + return OptionElement::optionIndex(ownerSelectElement(), this); } void HTMLOptionElement::parseMappedAttribute(MappedAttribute *attr) @@ -136,7 +121,7 @@ void HTMLOptionElement::parseMappedAttribute(MappedAttribute *attr) String HTMLOptionElement::value() const { - return OptionElement::collectOptionValue(m_data, document()); + return OptionElement::collectOptionValue(m_data, this); } void HTMLOptionElement::setValue(const String& value) @@ -154,7 +139,7 @@ void HTMLOptionElement::setSelected(bool selected) if (m_data.selected() == selected) return; - OptionElement::setSelectedState(m_data, selected); + OptionElement::setSelectedState(m_data, this, selected); if (HTMLSelectElement* select = ownerSelectElement()) select->setSelectedIndex(selected ? index() : -1, false); @@ -162,7 +147,7 @@ void HTMLOptionElement::setSelected(bool selected) void HTMLOptionElement::setSelectedState(bool selected) { - OptionElement::setSelectedState(m_data, selected); + OptionElement::setSelectedState(m_data, this, selected); } void HTMLOptionElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) @@ -221,7 +206,7 @@ RenderStyle* HTMLOptionElement::nonRendererRenderStyle() const String HTMLOptionElement::textIndentedToRespectGroupLabel() const { - return OptionElement::collectOptionTextRespectingGroupLabel(m_data, document()); + return OptionElement::collectOptionTextRespectingGroupLabel(m_data, this); } bool HTMLOptionElement::disabled() const |