Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 2701993002: DO NOT COMMIT: Results of running new (proposed) clang-format on Blink (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights
7 * reserved. 7 * reserved.
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
9 * Copyright (C) 2010 Google Inc. All rights reserved. 9 * Copyright (C) 2010 Google Inc. All rights reserved.
10 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 10 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 if (reason == ResetReasonSelectedOptionRemoved) { 817 if (reason == ResetReasonSelectedOptionRemoved) {
818 // There must be no selected OPTIONs. 818 // There must be no selected OPTIONs.
819 break; 819 break;
820 } 820 }
821 } 821 }
822 ++optionIndex; 822 ++optionIndex;
823 } 823 }
824 if (!lastSelectedOption && m_size <= 1 && 824 if (!lastSelectedOption && m_size <= 1 &&
825 (!firstEnabledOption || 825 (!firstEnabledOption ||
826 (firstEnabledOption && !firstEnabledOption->selected()))) { 826 (firstEnabledOption && !firstEnabledOption->selected()))) {
827 selectOption(firstEnabledOption, reason == ResetReasonSelectedOptionRemoved 827 selectOption(
828 ? 0 828 firstEnabledOption,
829 : DeselectOtherOptions); 829 reason == ResetReasonSelectedOptionRemoved ? 0 : DeselectOtherOptions);
830 lastSelectedOption = firstEnabledOption; 830 lastSelectedOption = firstEnabledOption;
831 didChange = true; 831 didChange = true;
832 } 832 }
833 if (didChange) 833 if (didChange)
834 setNeedsValidityCheck(); 834 setNeedsValidityCheck();
835 m_lastOnChangeOption = lastSelectedOption; 835 m_lastOnChangeOption = lastSelectedOption;
836 } 836 }
837 837
838 HTMLOptionElement* HTMLSelectElement::selectedOption() const { 838 HTMLOptionElement* HTMLSelectElement::selectedOption() const {
839 for (const auto option : optionList()) { 839 for (const auto option : optionList()) {
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 else if (key == "PageUp") 1306 else if (key == "PageUp")
1307 option = nextValidOption(listIndex, SkipBackwards, 3); 1307 option = nextValidOption(listIndex, SkipBackwards, 3);
1308 else if (key == "Home") 1308 else if (key == "Home")
1309 option = nextValidOption(-1, SkipForwards, 1); 1309 option = nextValidOption(-1, SkipForwards, 1);
1310 else if (key == "End") 1310 else if (key == "End")
1311 option = nextValidOption(listItems.size(), SkipBackwards, 1); 1311 option = nextValidOption(listItems.size(), SkipBackwards, 1);
1312 else 1312 else
1313 handled = false; 1313 handled = false;
1314 1314
1315 if (handled && option) 1315 if (handled && option)
1316 selectOption(option, DeselectOtherOptions | MakeOptionDirty | 1316 selectOption(
1317 DispatchInputAndChangeEvent); 1317 option,
1318 DeselectOtherOptions | MakeOptionDirty | DispatchInputAndChangeEvent);
1318 1319
1319 if (handled) 1320 if (handled)
1320 event->setDefaultHandled(); 1321 event->setDefaultHandled();
1321 } 1322 }
1322 1323
1323 if (event->type() == EventTypeNames::keypress) { 1324 if (event->type() == EventTypeNames::keypress) {
1324 if (!layoutObject() || !event->isKeyboardEvent()) 1325 if (!layoutObject() || !event->isKeyboardEvent())
1325 return; 1326 return;
1326 1327
1327 int keyCode = toKeyboardEvent(event)->keyCode(); 1328 int keyCode = toKeyboardEvent(event)->keyCode();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 return option->displayLabel(); 1713 return option->displayLabel();
1713 } 1714 }
1714 return String(); 1715 return String();
1715 } 1716 }
1716 1717
1717 void HTMLSelectElement::typeAheadFind(KeyboardEvent* event) { 1718 void HTMLSelectElement::typeAheadFind(KeyboardEvent* event) {
1718 int index = m_typeAhead.handleEvent( 1719 int index = m_typeAhead.handleEvent(
1719 event, TypeAhead::MatchPrefix | TypeAhead::CycleFirstChar); 1720 event, TypeAhead::MatchPrefix | TypeAhead::CycleFirstChar);
1720 if (index < 0) 1721 if (index < 0)
1721 return; 1722 return;
1722 selectOption(optionAtListIndex(index), DeselectOtherOptions | 1723 selectOption(
1723 MakeOptionDirty | 1724 optionAtListIndex(index),
1724 DispatchInputAndChangeEvent); 1725 DeselectOtherOptions | MakeOptionDirty | DispatchInputAndChangeEvent);
1725 if (!usesMenuList()) 1726 if (!usesMenuList())
1726 listBoxOnChange(); 1727 listBoxOnChange();
1727 } 1728 }
1728 1729
1729 void HTMLSelectElement::selectOptionByAccessKey(HTMLOptionElement* option) { 1730 void HTMLSelectElement::selectOptionByAccessKey(HTMLOptionElement* option) {
1730 // First bring into focus the list box. 1731 // First bring into focus the list box.
1731 if (!isFocused()) 1732 if (!isFocused())
1732 accessKeyAction(false); 1733 accessKeyAction(false);
1733 1734
1734 if (!option || option->ownerSelectElement() != this) 1735 if (!option || option->ownerSelectElement() != this)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 1899
1899 HTMLOptionElement* option = optionAtListIndex(listIndex); 1900 HTMLOptionElement* option = optionAtListIndex(listIndex);
1900 // Bail out if this index is already the selected one, to avoid running 1901 // Bail out if this index is already the selected one, to avoid running
1901 // unnecessary JavaScript that can mess up autofill when there is no actual 1902 // unnecessary JavaScript that can mess up autofill when there is no actual
1902 // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and 1903 // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and
1903 // <rdar://7467917>). The selectOption function does not behave this way, 1904 // <rdar://7467917>). The selectOption function does not behave this way,
1904 // possibly because other callers need a change event even in cases where 1905 // possibly because other callers need a change event even in cases where
1905 // the selected option is not change. 1906 // the selected option is not change.
1906 if (option == selectedOption()) 1907 if (option == selectedOption())
1907 return; 1908 return;
1908 selectOption(option, DeselectOtherOptions | MakeOptionDirty | 1909 selectOption(
1909 DispatchInputAndChangeEvent); 1910 option,
1911 DeselectOtherOptions | MakeOptionDirty | DispatchInputAndChangeEvent);
1910 } 1912 }
1911 1913
1912 void HTMLSelectElement::popupDidCancel() { 1914 void HTMLSelectElement::popupDidCancel() {
1913 if (m_indexToSelectOnCancel >= 0) 1915 if (m_indexToSelectOnCancel >= 0)
1914 selectOptionByPopup(m_indexToSelectOnCancel); 1916 selectOptionByPopup(m_indexToSelectOnCancel);
1915 } 1917 }
1916 1918
1917 void HTMLSelectElement::provisionalSelectionChanged(unsigned listIndex) { 1919 void HTMLSelectElement::provisionalSelectionChanged(unsigned listIndex) {
1918 setIndexToSelectOnCancel(listIndex); 1920 setIndexToSelectOnCancel(listIndex);
1919 } 1921 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 m_popupUpdater = nullptr; 2043 m_popupUpdater = nullptr;
2042 } 2044 }
2043 2045
2044 void HTMLSelectElement::didMutateSubtree() { 2046 void HTMLSelectElement::didMutateSubtree() {
2045 DCHECK(popupIsVisible()); 2047 DCHECK(popupIsVisible());
2046 DCHECK(m_popup); 2048 DCHECK(m_popup);
2047 m_popup->updateFromElement(PopupMenu::ByDOMChange); 2049 m_popup->updateFromElement(PopupMenu::ByDOMChange);
2048 } 2050 }
2049 2051
2050 } // namespace blink 2052 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698