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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
index b3d3b5262429c28b0e6886db4de4d485cb7081e1..d3c46052dc707340038853ccb3fcb20d01e8b351 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -123,31 +123,6 @@ const AtomicString& HTMLSelectElement::formControlType() const
return m_multiple ? selectMultiple : selectOne;
}
-void HTMLSelectElement::optionSelectedByUser(int optionIndex, bool fireOnChangeNow)
-{
- // User interaction such as mousedown events can cause list box select
- // elements to send change events. This produces that same behavior for
- // changes triggered by other code running on behalf of the user.
- if (!usesMenuList()) {
- updateSelectedState(item(optionIndex), false, false);
- setNeedsValidityCheck();
- if (fireOnChangeNow)
- listBoxOnChange();
- return;
- }
-
- // Bail out if this index is already the selected one, to avoid running
- // unnecessary JavaScript that can mess up autofill when there is no actual
- // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and
- // <rdar://7467917>). The selectOption function does not behave this way,
- // possibly because other callers need a change event even in cases where
- // the selected option is not change.
- if (optionIndex == selectedIndex())
- return;
-
- selectOption(item(optionIndex), DeselectOtherOptions | MakeOptionDirty | (fireOnChangeNow ? DispatchInputAndChangeEvent : 0));
-}
-
bool HTMLSelectElement::hasPlaceholderLabelOption() const
{
// The select element has no placeholder label option if it has an attribute
@@ -1934,7 +1909,19 @@ void HTMLSelectElement::selectOptionByPopup(int listIndex)
return;
setIndexToSelectOnCancel(-1);
- optionSelectedByUser(listToOptionIndex(listIndex), true);
+
+ HTMLOptionElement* option = nullptr;
+ if (listIndex >= 0 && isHTMLOptionElement(listItems()[listIndex]))
+ option = toHTMLOptionElement(listItems()[listIndex]);
+ // Bail out if this index is already the selected one, to avoid running
+ // unnecessary JavaScript that can mess up autofill when there is no actual
+ // change (see https://bugs.webkit.org/show_bug.cgi?id=35256 and
+ // <rdar://7467917>). The selectOption function does not behave this way,
+ // possibly because other callers need a change event even in cases where
+ // the selected option is not change.
+ if (option == selectedOption())
+ return;
+ selectOption(option, DeselectOtherOptions | MakeOptionDirty | DispatchInputAndChangeEvent);
}
void HTMLSelectElement::popupDidCancel()
« 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