| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). | 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
| 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 4 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 5 * (C) 2001 Dirk Mueller (mueller@kde.org) | 5 * (C) 2001 Dirk Mueller (mueller@kde.org) |
| 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
reserved. |
| 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
| 8 * Copyright (C) 2010 Google Inc. All rights reserved. | 8 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) | 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo
bile.com/) |
| 10 * | 10 * |
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 | 1115 |
| 1116 if (usesMenuList()) { | 1116 if (usesMenuList()) { |
| 1117 if (shouldDispatchEvents) { | 1117 if (shouldDispatchEvents) { |
| 1118 dispatchInputEvent(); | 1118 dispatchInputEvent(); |
| 1119 dispatchFormControlChangeEvent(); | 1119 dispatchFormControlChangeEvent(); |
| 1120 } | 1120 } |
| 1121 if (LayoutObject* layoutObject = this->layoutObject()) { | 1121 if (LayoutObject* layoutObject = this->layoutObject()) { |
| 1122 // Need to check usesMenuList() again because event handlers might | 1122 // Need to check usesMenuList() again because event handlers might |
| 1123 // change the status. | 1123 // change the status. |
| 1124 if (usesMenuList()) { | 1124 if (usesMenuList()) { |
| 1125 // didSetSelectedIndex() is O(N) because of optionToListIndex. | 1125 // didSelectOption() is O(N) because of HTMLOptionElement::index
(). |
| 1126 toLayoutMenuList(layoutObject)->didSetSelectedIndex(optionIndex)
; | 1126 toLayoutMenuList(layoutObject)->didSelectOption(element); |
| 1127 } | 1127 } |
| 1128 } | 1128 } |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 notifyFormStateChanged(); | 1131 notifyFormStateChanged(); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 int HTMLSelectElement::optionToListIndex(int optionIndex) const | 1134 int HTMLSelectElement::optionToListIndex(int optionIndex) const |
| 1135 { | 1135 { |
| 1136 const ListItems& items = listItems(); | 1136 const ListItems& items = listItems(); |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 } | 1978 } |
| 1979 } | 1979 } |
| 1980 | 1980 |
| 1981 void HTMLSelectElement::setIndexToSelectOnCancel(int listIndex) | 1981 void HTMLSelectElement::setIndexToSelectOnCancel(int listIndex) |
| 1982 { | 1982 { |
| 1983 m_indexToSelectOnCancel = listIndex; | 1983 m_indexToSelectOnCancel = listIndex; |
| 1984 if (layoutObject()) | 1984 if (layoutObject()) |
| 1985 layoutObject()->updateFromElement(); | 1985 layoutObject()->updateFromElement(); |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 int HTMLSelectElement::optionIndexToBeShown() const | 1988 HTMLOptionElement* HTMLSelectElement::optionToBeShown() const |
| 1989 { | 1989 { |
| 1990 if (m_indexToSelectOnCancel >= 0) | 1990 if (m_indexToSelectOnCancel >= 0 && static_cast<size_t>(m_indexToSelectOnCan
cel) < listItems().size() && isHTMLOptionElement(listItems()[m_indexToSelectOnCa
ncel])) |
| 1991 return listToOptionIndex(m_indexToSelectOnCancel); | 1991 return toHTMLOptionElement(listItems()[m_indexToSelectOnCancel]); |
| 1992 // TODO(tkent): HTMLOptionElement::index() is O(N). This function should | |
| 1993 // return HTMLOptionElement*. | |
| 1994 if (m_suggestedOption) | 1992 if (m_suggestedOption) |
| 1995 return m_suggestedOption->index(); | 1993 return m_suggestedOption; |
| 1996 int optionIndex = m_lastOnChangeOption ? m_lastOnChangeOption->index() : -1; | 1994 DCHECK_EQ(selectedOption(), m_lastOnChangeOption); |
| 1997 DCHECK_EQ(optionIndex, selectedIndex()); | 1995 return m_lastOnChangeOption; |
| 1998 return optionIndex; | |
| 1999 } | 1996 } |
| 2000 | 1997 |
| 2001 void HTMLSelectElement::valueChanged(unsigned listIndex) | 1998 void HTMLSelectElement::valueChanged(unsigned listIndex) |
| 2002 { | 1999 { |
| 2003 // Check to ensure a page navigation has not occurred while the popup was | 2000 // Check to ensure a page navigation has not occurred while the popup was |
| 2004 // up. | 2001 // up. |
| 2005 Document& doc = document(); | 2002 Document& doc = document(); |
| 2006 if (&doc != doc.frame()->document()) | 2003 if (&doc != doc.frame()->document()) |
| 2007 return; | 2004 return; |
| 2008 | 2005 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 } | 2141 } |
| 2145 | 2142 |
| 2146 void HTMLSelectElement::didMutateSubtree() | 2143 void HTMLSelectElement::didMutateSubtree() |
| 2147 { | 2144 { |
| 2148 DCHECK(popupIsVisible()); | 2145 DCHECK(popupIsVisible()); |
| 2149 DCHECK(m_popup); | 2146 DCHECK(m_popup); |
| 2150 m_popup->updateFromElement(PopupMenu::ByDOMChange); | 2147 m_popup->updateFromElement(PopupMenu::ByDOMChange); |
| 2151 } | 2148 } |
| 2152 | 2149 |
| 2153 } // namespace blink | 2150 } // namespace blink |
| OLD | NEW |