| Index: Source/core/html/HTMLSelectElement.cpp
|
| diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
|
| index 948371821b3da6c5f83a3d61a006dc199c9b5b3e..535b803c57269174be227ee004b7a3a18d8efb85 100644
|
| --- a/Source/core/html/HTMLSelectElement.cpp
|
| +++ b/Source/core/html/HTMLSelectElement.cpp
|
| @@ -473,7 +473,7 @@ int HTMLSelectElement::nextValidIndex(int listIndex, SkipDirection direction, in
|
| int size = listItems.size();
|
| for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex += direction) {
|
| --skip;
|
| - if (!listItems[listIndex]->isDisabledFormControl() && listItems[listIndex]->hasTagName(optionTag)) {
|
| + if (!listItems[listIndex]->isDisabledFormControl() && isHTMLOptionElement(*listItems[listIndex])) {
|
| lastGoodIndex = listIndex;
|
| if (skip <= 0)
|
| break;
|
| @@ -555,7 +555,7 @@ void HTMLSelectElement::saveLastSelection()
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - m_lastOnChangeSelection.append(element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected());
|
| + m_lastOnChangeSelection.append(isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected());
|
| }
|
| }
|
|
|
| @@ -570,7 +570,7 @@ void HTMLSelectElement::setActiveSelectionAnchorIndex(int index)
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - m_cachedStateForActiveSelection.append(element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected());
|
| + m_cachedStateForActiveSelection.append(isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected());
|
| }
|
| }
|
|
|
| @@ -590,7 +590,7 @@ void HTMLSelectElement::updateListBoxSelection(bool deselectOtherOptions)
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->isDisabledFormControl())
|
| + if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl())
|
| continue;
|
|
|
| if (i >= start && i <= end)
|
| @@ -624,7 +624,7 @@ void HTMLSelectElement::listBoxOnChange()
|
| bool fireOnChange = false;
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - bool selected = element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected();
|
| + bool selected = isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected();
|
| if (selected != m_lastOnChangeSelection[i])
|
| fireOnChange = true;
|
| m_lastOnChangeSelection[i] = selected;
|
| @@ -732,7 +732,7 @@ void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
|
| // optgroup tags may not nest. However, both FireFox and IE will
|
| // flatten the tree automatically, so we follow suit.
|
| // (http://www.w3.org/TR/html401/interact/forms.html#h-17.6)
|
| - if (current.hasTagName(optgroupTag)) {
|
| + if (isHTMLOptGroupElement(current)) {
|
| m_listItems.append(¤t);
|
| if (Element* nextElement = ElementTraversal::firstWithin(current)) {
|
| currentElement = nextElement;
|
| @@ -740,7 +740,7 @@ void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
|
| }
|
| }
|
|
|
| - if (current.hasTagName(optionTag)) {
|
| + if (isHTMLOptionElement(current)) {
|
| m_listItems.append(¤t);
|
|
|
| if (updateSelectedStates && !m_multiple) {
|
| @@ -758,7 +758,7 @@ void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const
|
| }
|
| }
|
|
|
| - if (current.hasTagName(hrTag))
|
| + if (isHTMLHRElement(current))
|
| m_listItems.append(¤t);
|
|
|
| // In conforming HTML code, only <optgroup> and <option> will be found
|
| @@ -782,8 +782,8 @@ int HTMLSelectElement::selectedIndex() const
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (size_t i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - if (element->hasTagName(optionTag)) {
|
| - if (toHTMLOptionElement(element)->selected())
|
| + if (isHTMLOptionElement(*element)) {
|
| + if (toHTMLOptionElement(*element).selected())
|
| return index;
|
| ++index;
|
| }
|
| @@ -818,12 +818,12 @@ void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
|
| HTMLElement* element = 0;
|
| if (listIndex >= 0) {
|
| element = items[listIndex];
|
| - if (element->hasTagName(optionTag)) {
|
| + if (isHTMLOptionElement(*element)) {
|
| if (m_activeSelectionAnchorIndex < 0 || shouldDeselect)
|
| setActiveSelectionAnchorIndex(listIndex);
|
| if (m_activeSelectionEndIndex < 0 || shouldDeselect)
|
| setActiveSelectionEndIndex(listIndex);
|
| - toHTMLOptionElement(element)->setSelectedState(true);
|
| + toHTMLOptionElement(*element).setSelectedState(true);
|
| }
|
| }
|
|
|
| @@ -861,7 +861,7 @@ int HTMLSelectElement::optionToListIndex(int optionIndex) const
|
|
|
| int optionIndex2 = -1;
|
| for (int listIndex = 0; listIndex < listSize; ++listIndex) {
|
| - if (items[listIndex]->hasTagName(optionTag)) {
|
| + if (isHTMLOptionElement(*items[listIndex])) {
|
| ++optionIndex2;
|
| if (optionIndex2 == optionIndex)
|
| return listIndex;
|
| @@ -874,13 +874,13 @@ int HTMLSelectElement::optionToListIndex(int optionIndex) const
|
| int HTMLSelectElement::listToOptionIndex(int listIndex) const
|
| {
|
| const Vector<HTMLElement*>& items = listItems();
|
| - if (listIndex < 0 || listIndex >= static_cast<int>(items.size()) || !items[listIndex]->hasTagName(optionTag))
|
| + if (listIndex < 0 || listIndex >= static_cast<int>(items.size()) || !isHTMLOptionElement(*items[listIndex]))
|
| return -1;
|
|
|
| // Actual index of option not counting OPTGROUP entries that may be in list.
|
| int optionIndex = 0;
|
| for (int i = 0; i < listIndex; ++i) {
|
| - if (items[i]->hasTagName(optionTag))
|
| + if (isHTMLOptionElement(*items[i]))
|
| ++optionIndex;
|
| }
|
|
|
| @@ -911,7 +911,7 @@ void HTMLSelectElement::deselectItemsWithoutValidation(HTMLElement* excludeEleme
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - if (element != excludeElement && element->hasTagName(optionTag))
|
| + if (element != excludeElement && isHTMLOptionElement(*element))
|
| toHTMLOptionElement(element)->setSelectedState(false);
|
| }
|
| }
|
| @@ -922,7 +922,7 @@ FormControlState HTMLSelectElement::saveFormControlState() const
|
| size_t length = items.size();
|
| FormControlState state;
|
| for (unsigned i = 0; i < length; ++i) {
|
| - if (!items[i]->hasTagName(optionTag))
|
| + if (!isHTMLOptionElement(*items[i]))
|
| continue;
|
| HTMLOptionElement* option = toHTMLOptionElement(items[i]);
|
| if (!option->selected())
|
| @@ -1004,8 +1004,8 @@ bool HTMLSelectElement::appendFormData(FormDataList& list, bool)
|
|
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected() && !toHTMLOptionElement(element)->isDisabledFormControl()) {
|
| - list.appendData(name, toHTMLOptionElement(element)->value());
|
| + if (isHTMLOptionElement(*element) && toHTMLOptionElement(*element).selected() && !toHTMLOptionElement(*element).isDisabledFormControl()) {
|
| + list.appendData(name, toHTMLOptionElement(*element).value());
|
| successful = true;
|
| }
|
| }
|
| @@ -1024,7 +1024,7 @@ void HTMLSelectElement::resetImpl()
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| HTMLElement* element = items[i];
|
| - if (!element->hasTagName(optionTag))
|
| + if (!isHTMLOptionElement(*element))
|
| continue;
|
|
|
| if (items[i]->fastHasAttribute(selectedAttr)) {
|
| @@ -1229,13 +1229,14 @@ void HTMLSelectElement::updateSelectedState(int listIndex, bool multi, bool shif
|
| bool multiSelect = m_multiple && multi && !shift;
|
|
|
| HTMLElement* clickedElement = listItems()[listIndex];
|
| - if (clickedElement->hasTagName(optionTag)) {
|
| + ASSERT(clickedElement);
|
| + if (isHTMLOptionElement(*clickedElement)) {
|
| // Keep track of whether an active selection (like during drag
|
| // selection), should select or deselect.
|
| - if (toHTMLOptionElement(clickedElement)->selected() && multiSelect)
|
| + if (toHTMLOptionElement(*clickedElement).selected() && multiSelect)
|
| m_activeSelectionState = false;
|
| if (!m_activeSelectionState)
|
| - toHTMLOptionElement(clickedElement)->setSelectedState(false);
|
| + toHTMLOptionElement(*clickedElement).setSelectedState(false);
|
| }
|
|
|
| // If we're not in any special multiple selection mode, then deselect all
|
| @@ -1250,8 +1251,8 @@ void HTMLSelectElement::updateSelectedState(int listIndex, bool multi, bool shif
|
| setActiveSelectionAnchorIndex(selectedIndex());
|
|
|
| // Set the selection state of the clicked option.
|
| - if (clickedElement->hasTagName(optionTag) && !toHTMLOptionElement(clickedElement)->isDisabledFormControl())
|
| - toHTMLOptionElement(clickedElement)->setSelectedState(true);
|
| + if (isHTMLOptionElement(*clickedElement) && !toHTMLOptionElement(*clickedElement).isDisabledFormControl())
|
| + toHTMLOptionElement(*clickedElement).setSelectedState(true);
|
|
|
| // If there was no selectedIndex() for the previous initialization, or If
|
| // we're doing a single selection, or a multiple selection (using cmd or
|
| @@ -1460,7 +1461,7 @@ int HTMLSelectElement::lastSelectedListIndex() const
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (size_t i = items.size(); i;) {
|
| HTMLElement* element = items[--i];
|
| - if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected())
|
| + if (isHTMLOptionElement(*element) && toHTMLOptionElement(element)->selected())
|
| return i;
|
| }
|
| return -1;
|
| @@ -1481,7 +1482,7 @@ String HTMLSelectElement::optionAtIndex(int index) const
|
| const Vector<HTMLElement*>& items = listItems();
|
|
|
| HTMLElement* element = items[index];
|
| - if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->isDisabledFormControl())
|
| + if (!isHTMLOptionElement(*element) || toHTMLOptionElement(element)->isDisabledFormControl())
|
| return String();
|
| return toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
|
| }
|
| @@ -1517,9 +1518,9 @@ void HTMLSelectElement::accessKeySetSelectedIndex(int index)
|
| int listIndex = optionToListIndex(index);
|
| if (listIndex >= 0) {
|
| HTMLElement* element = items[listIndex];
|
| - if (element->hasTagName(optionTag)) {
|
| - if (toHTMLOptionElement(element)->selected())
|
| - toHTMLOptionElement(element)->setSelectedState(false);
|
| + if (isHTMLOptionElement(*element)) {
|
| + if (toHTMLOptionElement(*element).selected())
|
| + toHTMLOptionElement(*element).setSelectedState(false);
|
| else
|
| selectOption(index, DispatchInputAndChangeEvent | UserDriven);
|
| }
|
| @@ -1539,7 +1540,7 @@ unsigned HTMLSelectElement::length() const
|
|
|
| const Vector<HTMLElement*>& items = listItems();
|
| for (unsigned i = 0; i < items.size(); ++i) {
|
| - if (items[i]->hasTagName(optionTag))
|
| + if (isHTMLOptionElement(*items[i]))
|
| ++options;
|
| }
|
|
|
|
|