| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 , m_typeAhead(this) | 75 , m_typeAhead(this) |
| 76 , m_size(0) | 76 , m_size(0) |
| 77 , m_lastOnChangeIndex(-1) | 77 , m_lastOnChangeIndex(-1) |
| 78 , m_activeSelectionAnchorIndex(-1) | 78 , m_activeSelectionAnchorIndex(-1) |
| 79 , m_activeSelectionEndIndex(-1) | 79 , m_activeSelectionEndIndex(-1) |
| 80 , m_isProcessingUserDrivenChange(false) | 80 , m_isProcessingUserDrivenChange(false) |
| 81 , m_multiple(false) | 81 , m_multiple(false) |
| 82 , m_activeSelectionState(false) | 82 , m_activeSelectionState(false) |
| 83 , m_shouldRecalcListItems(false) | 83 , m_shouldRecalcListItems(false) |
| 84 , m_suggestedIndex(-1) | 84 , m_suggestedIndex(-1) |
| 85 , m_isAutofilledByPreview(false) |
| 85 { | 86 { |
| 86 } | 87 } |
| 87 | 88 |
| 88 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do
cument) | 89 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do
cument) |
| 89 { | 90 { |
| 90 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe
lectElement(document, 0)); | 91 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe
lectElement(document, 0)); |
| 91 select->ensureUserAgentShadowRoot(); | 92 select->ensureUserAgentShadowRoot(); |
| 92 return select.release(); | 93 return select.release(); |
| 93 } | 94 } |
| 94 | 95 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 break; | 263 break; |
| 263 optionIndex++; | 264 optionIndex++; |
| 264 } | 265 } |
| 265 } | 266 } |
| 266 if (optionIndex >= static_cast<int>(items.size())) | 267 if (optionIndex >= static_cast<int>(items.size())) |
| 267 optionIndex = -1; | 268 optionIndex = -1; |
| 268 } | 269 } |
| 269 | 270 |
| 270 int previousSelectedIndex = selectedIndex(); | 271 int previousSelectedIndex = selectedIndex(); |
| 271 setSuggestedIndex(-1); | 272 setSuggestedIndex(-1); |
| 273 if (m_isAutofilledByPreview) |
| 274 setAutofilled(false); |
| 272 setSelectedIndex(optionIndex); | 275 setSelectedIndex(optionIndex); |
| 273 | 276 |
| 274 if (sendEvents && previousSelectedIndex != selectedIndex()) { | 277 if (sendEvents && previousSelectedIndex != selectedIndex()) { |
| 275 if (usesMenuList()) | 278 if (usesMenuList()) |
| 276 dispatchInputAndChangeEventForMenuList(false); | 279 dispatchInputAndChangeEventForMenuList(false); |
| 277 else | 280 else |
| 278 listBoxOnChange(); | 281 listBoxOnChange(); |
| 279 } | 282 } |
| 280 } | 283 } |
| 281 | 284 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 297 setSuggestedIndex(-1); | 300 setSuggestedIndex(-1); |
| 298 return; | 301 return; |
| 299 } | 302 } |
| 300 | 303 |
| 301 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems(
); | 304 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems(
); |
| 302 unsigned optionIndex = 0; | 305 unsigned optionIndex = 0; |
| 303 for (unsigned i = 0; i < items.size(); ++i) { | 306 for (unsigned i = 0; i < items.size(); ++i) { |
| 304 if (isHTMLOptionElement(items[i])) { | 307 if (isHTMLOptionElement(items[i])) { |
| 305 if (toHTMLOptionElement(items[i])->value() == value) { | 308 if (toHTMLOptionElement(items[i])->value() == value) { |
| 306 setSuggestedIndex(optionIndex); | 309 setSuggestedIndex(optionIndex); |
| 310 m_isAutofilledByPreview = true; |
| 307 return; | 311 return; |
| 308 } | 312 } |
| 309 optionIndex++; | 313 optionIndex++; |
| 310 } | 314 } |
| 311 } | 315 } |
| 312 | 316 |
| 313 setSuggestedIndex(-1); | 317 setSuggestedIndex(-1); |
| 314 } | 318 } |
| 315 | 319 |
| 316 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const | 320 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 setAutofilled(false); | 921 setAutofilled(false); |
| 918 } | 922 } |
| 919 | 923 |
| 920 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags) | 924 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags) |
| 921 { | 925 { |
| 922 bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions); | 926 bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions); |
| 923 | 927 |
| 924 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems(
); | 928 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems(
); |
| 925 int listIndex = optionToListIndex(optionIndex); | 929 int listIndex = optionToListIndex(optionIndex); |
| 926 | 930 |
| 931 if (selectedIndex() != optionIndex && isAutofilled()) |
| 932 setAutofilled(false); |
| 933 |
| 927 HTMLElement* element = 0; | 934 HTMLElement* element = 0; |
| 928 if (listIndex >= 0) { | 935 if (listIndex >= 0) { |
| 929 element = items[listIndex]; | 936 element = items[listIndex]; |
| 930 if (isHTMLOptionElement(*element)) { | 937 if (isHTMLOptionElement(*element)) { |
| 931 if (m_activeSelectionAnchorIndex < 0 || shouldDeselect) | 938 if (m_activeSelectionAnchorIndex < 0 || shouldDeselect) |
| 932 setActiveSelectionAnchorIndex(listIndex); | 939 setActiveSelectionAnchorIndex(listIndex); |
| 933 if (m_activeSelectionEndIndex < 0 || shouldDeselect) | 940 if (m_activeSelectionEndIndex < 0 || shouldDeselect) |
| 934 setActiveSelectionEndIndex(listIndex); | 941 setActiveSelectionEndIndex(listIndex); |
| 935 toHTMLOptionElement(*element).setSelectedState(true); | 942 toHTMLOptionElement(*element).setSelectedState(true); |
| 936 } | 943 } |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 int focusedIndex = activeSelectionEndListIndex(); | 1762 int focusedIndex = activeSelectionEndListIndex(); |
| 1756 if (focusedIndex < 0) | 1763 if (focusedIndex < 0) |
| 1757 focusedIndex = firstSelectableListIndex(); | 1764 focusedIndex = firstSelectableListIndex(); |
| 1758 if (focusedIndex < 0) | 1765 if (focusedIndex < 0) |
| 1759 return nullptr; | 1766 return nullptr; |
| 1760 HTMLElement* focused = listItems()[focusedIndex]; | 1767 HTMLElement* focused = listItems()[focusedIndex]; |
| 1761 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; | 1768 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr
; |
| 1762 } | 1769 } |
| 1763 | 1770 |
| 1764 } // namespace | 1771 } // namespace |
| OLD | NEW |