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