| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 #include "core/layout/LayoutMenuList.h" | 59 #include "core/layout/LayoutMenuList.h" |
| 60 #include "core/layout/LayoutText.h" | 60 #include "core/layout/LayoutText.h" |
| 61 #include "core/layout/LayoutTheme.h" | 61 #include "core/layout/LayoutTheme.h" |
| 62 #include "core/layout/LayoutView.h" | 62 #include "core/layout/LayoutView.h" |
| 63 #include "core/page/AutoscrollController.h" | 63 #include "core/page/AutoscrollController.h" |
| 64 #include "core/page/ChromeClient.h" | 64 #include "core/page/ChromeClient.h" |
| 65 #include "core/page/Page.h" | 65 #include "core/page/Page.h" |
| 66 #include "core/page/SpatialNavigation.h" | 66 #include "core/page/SpatialNavigation.h" |
| 67 #include "platform/PlatformMouseEvent.h" | 67 #include "platform/PlatformMouseEvent.h" |
| 68 #include "platform/PopupMenu.h" | 68 #include "platform/PopupMenu.h" |
| 69 #include "platform/TraceEvent.h" |
| 69 #include "platform/text/PlatformLocale.h" | 70 #include "platform/text/PlatformLocale.h" |
| 70 | 71 |
| 71 using namespace WTF::Unicode; | 72 using namespace WTF::Unicode; |
| 72 | 73 |
| 73 namespace blink { | 74 namespace blink { |
| 74 | 75 |
| 75 using namespace HTMLNames; | 76 using namespace HTMLNames; |
| 76 | 77 |
| 77 // Upper limit of m_listItems. According to the HTML standard, options larger | 78 // Upper limit of m_listItems. According to the HTML standard, options larger |
| 78 // than this limit doesn't work well because |selectedIndex| IDL attribute is | 79 // than this limit doesn't work well because |selectedIndex| IDL attribute is |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 invalidateSelectedItems(); | 791 invalidateSelectedItems(); |
| 791 | 792 |
| 792 if (layoutObject()) { | 793 if (layoutObject()) { |
| 793 if (AXObjectCache* cache = layoutObject()->document().existingAXObjectCa
che()) | 794 if (AXObjectCache* cache = layoutObject()->document().existingAXObjectCa
che()) |
| 794 cache->childrenChanged(this); | 795 cache->childrenChanged(this); |
| 795 } | 796 } |
| 796 } | 797 } |
| 797 | 798 |
| 798 void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const | 799 void HTMLSelectElement::recalcListItems(bool updateSelectedStates) const |
| 799 { | 800 { |
| 801 TRACE_EVENT0("blink", "HTMLSelectElement::recalcListItems"); |
| 800 m_listItems.clear(); | 802 m_listItems.clear(); |
| 801 | 803 |
| 802 m_shouldRecalcListItems = false; | 804 m_shouldRecalcListItems = false; |
| 803 | 805 |
| 804 HTMLOptionElement* foundSelected = 0; | 806 HTMLOptionElement* foundSelected = 0; |
| 805 HTMLOptionElement* firstOption = 0; | 807 HTMLOptionElement* firstOption = 0; |
| 806 for (Element* currentElement = ElementTraversal::firstWithin(*this); current
Element && m_listItems.size() < maxListItems; ) { | 808 for (Element* currentElement = ElementTraversal::firstWithin(*this); current
Element && m_listItems.size() < maxListItems; ) { |
| 807 if (!currentElement->isHTMLElement()) { | 809 if (!currentElement->isHTMLElement()) { |
| 808 currentElement = ElementTraversal::nextSkippingChildren(*currentElem
ent, this); | 810 currentElement = ElementTraversal::nextSkippingChildren(*currentElem
ent, this); |
| 809 continue; | 811 continue; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 if (listIndex <= m_activeSelectionEndIndex) | 957 if (listIndex <= m_activeSelectionEndIndex) |
| 956 m_activeSelectionEndIndex--; | 958 m_activeSelectionEndIndex--; |
| 957 if (listIndex == selectedIndex()) | 959 if (listIndex == selectedIndex()) |
| 958 setAutofilled(false); | 960 setAutofilled(false); |
| 959 } | 961 } |
| 960 | 962 |
| 961 // TODO(tkent): This function is not efficient. It contains multiple O(N) | 963 // TODO(tkent): This function is not efficient. It contains multiple O(N) |
| 962 // operations. | 964 // operations. |
| 963 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags) | 965 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags) |
| 964 { | 966 { |
| 967 TRACE_EVENT0("blink", "HTMLSelectElement::selectOption"); |
| 965 bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions); | 968 bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions); |
| 966 | 969 |
| 967 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; | 970 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& items = listItems()
; |
| 968 // optionToListIndex is O(N). | 971 // optionToListIndex is O(N). |
| 969 int listIndex = optionToListIndex(optionIndex); | 972 int listIndex = optionToListIndex(optionIndex); |
| 970 | 973 |
| 971 // selectedIndex() is O(N). | 974 // selectedIndex() is O(N). |
| 972 if (selectedIndex() != optionIndex && isAutofilled()) | 975 if (selectedIndex() != optionIndex && isAutofilled()) |
| 973 setAutofilled(false); | 976 setAutofilled(false); |
| 974 | 977 |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 m_popupIsVisible = false; | 1959 m_popupIsVisible = false; |
| 1957 m_popup = nullptr; | 1960 m_popup = nullptr; |
| 1958 } | 1961 } |
| 1959 | 1962 |
| 1960 void HTMLSelectElement::resetTypeAheadSessionForTesting() | 1963 void HTMLSelectElement::resetTypeAheadSessionForTesting() |
| 1961 { | 1964 { |
| 1962 m_typeAhead.resetSession(); | 1965 m_typeAhead.resetSession(); |
| 1963 } | 1966 } |
| 1964 | 1967 |
| 1965 } // namespace blink | 1968 } // namespace blink |
| OLD | NEW |