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

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

Issue 2146243002: Remove HTMLSelectElement::optionSelectedByUser(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 { 116 {
117 } 117 }
118 118
119 const AtomicString& HTMLSelectElement::formControlType() const 119 const AtomicString& HTMLSelectElement::formControlType() const
120 { 120 {
121 DEFINE_STATIC_LOCAL(const AtomicString, selectMultiple, ("select-multiple")) ; 121 DEFINE_STATIC_LOCAL(const AtomicString, selectMultiple, ("select-multiple")) ;
122 DEFINE_STATIC_LOCAL(const AtomicString, selectOne, ("select-one")); 122 DEFINE_STATIC_LOCAL(const AtomicString, selectOne, ("select-one"));
123 return m_multiple ? selectMultiple : selectOne; 123 return m_multiple ? selectMultiple : selectOne;
124 } 124 }
125 125
126 void HTMLSelectElement::optionSelectedByUser(int optionIndex, bool fireOnChangeN ow)
127 {
128 // User interaction such as mousedown events can cause list box select
129 // elements to send change events. This produces that same behavior for
130 // changes triggered by other code running on behalf of the user.
131 if (!usesMenuList()) {
132 updateSelectedState(item(optionIndex), false, false);
133 setNeedsValidityCheck();
134 if (fireOnChangeNow)
135 listBoxOnChange();
136 return;
137 }
138
139 // Bail out if this index is already the selected one, to avoid running
140 // unnecessary JavaScript that can mess up autofill when there is no actual
141 // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and
142 // <rdar://7467917>). The selectOption function does not behave this way,
143 // possibly because other callers need a change event even in cases where
144 // the selected option is not change.
145 if (optionIndex == selectedIndex())
146 return;
147
148 selectOption(item(optionIndex), DeselectOtherOptions | MakeOptionDirty | (fi reOnChangeNow ? DispatchInputAndChangeEvent : 0));
149 }
150
151 bool HTMLSelectElement::hasPlaceholderLabelOption() const 126 bool HTMLSelectElement::hasPlaceholderLabelOption() const
152 { 127 {
153 // The select element has no placeholder label option if it has an attribute 128 // The select element has no placeholder label option if it has an attribute
154 // "multiple" specified or a display size of non-1. 129 // "multiple" specified or a display size of non-1.
155 // 130 //
156 // The condition "size() > 1" is not compliant with the HTML5 spec as of Dec 131 // The condition "size() > 1" is not compliant with the HTML5 spec as of Dec
157 // 3, 2010. "size() != 1" is correct. Using "size() > 1" here because 132 // 3, 2010. "size() != 1" is correct. Using "size() > 1" here because
158 // size() may be 0 in WebKit. See the discussion at 133 // size() may be 0 in WebKit. See the discussion at
159 // https://bugs.webkit.org/show_bug.cgi?id=43887 134 // https://bugs.webkit.org/show_bug.cgi?id=43887
160 // 135 //
(...skipping 1766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 void HTMLSelectElement::selectOptionByPopup(int listIndex) 1902 void HTMLSelectElement::selectOptionByPopup(int listIndex)
1928 { 1903 {
1929 DCHECK(usesMenuList()); 1904 DCHECK(usesMenuList());
1930 // Check to ensure a page navigation has not occurred while the popup was 1905 // Check to ensure a page navigation has not occurred while the popup was
1931 // up. 1906 // up.
1932 Document& doc = document(); 1907 Document& doc = document();
1933 if (&doc != doc.frame()->document()) 1908 if (&doc != doc.frame()->document())
1934 return; 1909 return;
1935 1910
1936 setIndexToSelectOnCancel(-1); 1911 setIndexToSelectOnCancel(-1);
1937 optionSelectedByUser(listToOptionIndex(listIndex), true); 1912
1913 HTMLOptionElement* option = nullptr;
1914 if (listIndex >= 0 && isHTMLOptionElement(listItems()[listIndex]))
1915 option = toHTMLOptionElement(listItems()[listIndex]);
1916 // Bail out if this index is already the selected one, to avoid running
1917 // unnecessary JavaScript that can mess up autofill when there is no actual
1918 // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and
1919 // <rdar://7467917>). The selectOption function does not behave this way,
1920 // possibly because other callers need a change event even in cases where
1921 // the selected option is not change.
1922 if (option == selectedOption())
1923 return;
1924 selectOption(option, DeselectOtherOptions | MakeOptionDirty | DispatchInputA ndChangeEvent);
1938 } 1925 }
1939 1926
1940 void HTMLSelectElement::popupDidCancel() 1927 void HTMLSelectElement::popupDidCancel()
1941 { 1928 {
1942 if (m_indexToSelectOnCancel >= 0) 1929 if (m_indexToSelectOnCancel >= 0)
1943 selectOptionByPopup(m_indexToSelectOnCancel); 1930 selectOptionByPopup(m_indexToSelectOnCancel);
1944 } 1931 }
1945 1932
1946 void HTMLSelectElement::provisionalSelectionChanged(unsigned listIndex) 1933 void HTMLSelectElement::provisionalSelectionChanged(unsigned listIndex)
1947 { 1934 {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
2071 } 2058 }
2072 2059
2073 void HTMLSelectElement::didMutateSubtree() 2060 void HTMLSelectElement::didMutateSubtree()
2074 { 2061 {
2075 DCHECK(popupIsVisible()); 2062 DCHECK(popupIsVisible());
2076 DCHECK(m_popup); 2063 DCHECK(m_popup);
2077 m_popup->updateFromElement(PopupMenu::ByDOMChange); 2064 m_popup->updateFromElement(PopupMenu::ByDOMChange);
2078 } 2065 }
2079 2066
2080 } // namespace blink 2067 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698