| 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 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 if (isHTMLOptionElement(*items[listIndex])) { | 1057 if (isHTMLOptionElement(*items[listIndex])) { |
| 1058 ++optionIndex2; | 1058 ++optionIndex2; |
| 1059 if (optionIndex2 == optionIndex) | 1059 if (optionIndex2 == optionIndex) |
| 1060 return listIndex; | 1060 return listIndex; |
| 1061 } | 1061 } |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 return -1; | 1064 return -1; |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 int HTMLSelectElement::listToOptionIndex(int listIndex) const | |
| 1068 { | |
| 1069 const ListItems& items = listItems(); | |
| 1070 if (!optionAtListIndex(listIndex)) | |
| 1071 return -1; | |
| 1072 | |
| 1073 // Actual index of option not counting OPTGROUP entries that may be in list. | |
| 1074 int optionIndex = 0; | |
| 1075 for (int i = 0; i < listIndex; ++i) { | |
| 1076 if (isHTMLOptionElement(*items[i])) | |
| 1077 ++optionIndex; | |
| 1078 } | |
| 1079 | |
| 1080 return optionIndex; | |
| 1081 } | |
| 1082 | |
| 1083 void HTMLSelectElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusT
ype type, InputDeviceCapabilities* sourceCapabilities) | 1067 void HTMLSelectElement::dispatchFocusEvent(Element* oldFocusedElement, WebFocusT
ype type, InputDeviceCapabilities* sourceCapabilities) |
| 1084 { | 1068 { |
| 1085 // Save the selection so it can be compared to the new selection when | 1069 // Save the selection so it can be compared to the new selection when |
| 1086 // dispatching change events during blur event dispatch. | 1070 // dispatching change events during blur event dispatch. |
| 1087 if (usesMenuList()) | 1071 if (usesMenuList()) |
| 1088 saveLastSelection(); | 1072 saveLastSelection(); |
| 1089 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type,
sourceCapabilities); | 1073 HTMLFormControlElementWithState::dispatchFocusEvent(oldFocusedElement, type,
sourceCapabilities); |
| 1090 } | 1074 } |
| 1091 | 1075 |
| 1092 void HTMLSelectElement::dispatchBlurEvent(Element* newFocusedElement, WebFocusTy
pe type, InputDeviceCapabilities* sourceCapabilities) | 1076 void HTMLSelectElement::dispatchBlurEvent(Element* newFocusedElement, WebFocusTy
pe type, InputDeviceCapabilities* sourceCapabilities) |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 void HTMLSelectElement::typeAheadFind(KeyboardEvent* event) | 1697 void HTMLSelectElement::typeAheadFind(KeyboardEvent* event) |
| 1714 { | 1698 { |
| 1715 int index = m_typeAhead.handleEvent(event, TypeAhead::MatchPrefix | TypeAhea
d::CycleFirstChar); | 1699 int index = m_typeAhead.handleEvent(event, TypeAhead::MatchPrefix | TypeAhea
d::CycleFirstChar); |
| 1716 if (index < 0) | 1700 if (index < 0) |
| 1717 return; | 1701 return; |
| 1718 selectOption(optionAtListIndex(index), DeselectOtherOptions | MakeOptionDirt
y | DispatchInputAndChangeEvent); | 1702 selectOption(optionAtListIndex(index), DeselectOtherOptions | MakeOptionDirt
y | DispatchInputAndChangeEvent); |
| 1719 if (!usesMenuList()) | 1703 if (!usesMenuList()) |
| 1720 listBoxOnChange(); | 1704 listBoxOnChange(); |
| 1721 } | 1705 } |
| 1722 | 1706 |
| 1723 void HTMLSelectElement::accessKeySetSelectedIndex(int index) | 1707 void HTMLSelectElement::selectOptionByAccessKey(HTMLOptionElement* option) |
| 1724 { | 1708 { |
| 1725 // First bring into focus the list box. | 1709 // First bring into focus the list box. |
| 1726 if (!focused()) | 1710 if (!focused()) |
| 1727 accessKeyAction(false); | 1711 accessKeyAction(false); |
| 1728 | 1712 |
| 1729 HTMLOptionElement* option = item(index); | 1713 if (!option || option->ownerSelectElement() != this) |
| 1730 if (!option) | |
| 1731 return; | 1714 return; |
| 1732 EventQueueScope scope; | 1715 EventQueueScope scope; |
| 1733 // If this index is already selected, unselect. otherwise update the | 1716 // If this index is already selected, unselect. otherwise update the |
| 1734 // selected index. | 1717 // selected index. |
| 1735 SelectOptionFlags flags = DispatchInputAndChangeEvent | (multiple() ? 0 : De
selectOtherOptions); | 1718 SelectOptionFlags flags = DispatchInputAndChangeEvent | (multiple() ? 0 : De
selectOtherOptions); |
| 1736 if (option->selected()) { | 1719 if (option->selected()) { |
| 1737 if (usesMenuList()) | 1720 if (usesMenuList()) |
| 1738 selectOption(nullptr, flags); | 1721 selectOption(nullptr, flags); |
| 1739 else | 1722 else |
| 1740 option->setSelectedState(false); | 1723 option->setSelectedState(false); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 } | 2046 } |
| 2064 | 2047 |
| 2065 void HTMLSelectElement::didMutateSubtree() | 2048 void HTMLSelectElement::didMutateSubtree() |
| 2066 { | 2049 { |
| 2067 DCHECK(popupIsVisible()); | 2050 DCHECK(popupIsVisible()); |
| 2068 DCHECK(m_popup); | 2051 DCHECK(m_popup); |
| 2069 m_popup->updateFromElement(PopupMenu::ByDOMChange); | 2052 m_popup->updateFromElement(PopupMenu::ByDOMChange); |
| 2070 } | 2053 } |
| 2071 | 2054 |
| 2072 } // namespace blink | 2055 } // namespace blink |
| OLD | NEW |