| Index: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
|
| diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
|
| index 7a39cb97914cea24ecf4338e73a50bb5a5421483..84fbc2cad5e71bef1ff6b4eabc42b2b7b05f7066 100644
|
| --- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
|
| +++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
|
| @@ -1122,8 +1122,8 @@ void HTMLSelectElement::selectOption(HTMLOptionElement* element, int optionIndex
|
| // Need to check usesMenuList() again because event handlers might
|
| // change the status.
|
| if (usesMenuList()) {
|
| - // didSetSelectedIndex() is O(N) because of optionToListIndex.
|
| - toLayoutMenuList(layoutObject)->didSetSelectedIndex(optionIndex);
|
| + // didSelectOption() is O(N) because of HTMLOptionElement::index().
|
| + toLayoutMenuList(layoutObject)->didSelectOption(element);
|
| }
|
| }
|
| }
|
| @@ -1985,17 +1985,14 @@ void HTMLSelectElement::setIndexToSelectOnCancel(int listIndex)
|
| layoutObject()->updateFromElement();
|
| }
|
|
|
| -int HTMLSelectElement::optionIndexToBeShown() const
|
| +HTMLOptionElement* HTMLSelectElement::optionToBeShown() const
|
| {
|
| - if (m_indexToSelectOnCancel >= 0)
|
| - return listToOptionIndex(m_indexToSelectOnCancel);
|
| - // TODO(tkent): HTMLOptionElement::index() is O(N). This function should
|
| - // return HTMLOptionElement*.
|
| + if (m_indexToSelectOnCancel >= 0 && static_cast<size_t>(m_indexToSelectOnCancel) < listItems().size() && isHTMLOptionElement(listItems()[m_indexToSelectOnCancel]))
|
| + return toHTMLOptionElement(listItems()[m_indexToSelectOnCancel]);
|
| if (m_suggestedOption)
|
| - return m_suggestedOption->index();
|
| - int optionIndex = m_lastOnChangeOption ? m_lastOnChangeOption->index() : -1;
|
| - DCHECK_EQ(optionIndex, selectedIndex());
|
| - return optionIndex;
|
| + return m_suggestedOption;
|
| + DCHECK_EQ(selectedOption(), m_lastOnChangeOption);
|
| + return m_lastOnChangeOption;
|
| }
|
|
|
| void HTMLSelectElement::valueChanged(unsigned listIndex)
|
|
|