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

Unified Diff: third_party/WebKit/Source/core/html/HTMLSelectElement.cpp

Issue 2143863003: Simplify protocol between SELECT elements and popups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@select-remove-fixed-args
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
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 c39608b845960f171043cbd4dbd028054d7e37a1..b3d3b5262429c28b0e6886db4de4d485cb7081e1 100644
--- a/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLSelectElement.cpp
@@ -208,18 +208,19 @@ String HTMLSelectElement::defaultToolTip() const
return validationMessage();
}
-void HTMLSelectElement::listBoxSelectItem(int listIndex, bool allowMultiplySelections, bool fireOnChangeNow)
+void HTMLSelectElement::selectMultipleOptionsByPopup(const Vector<int>& listIndices)
{
- if (!multiple()) {
- optionSelectedByUser(listToOptionIndex(listIndex), fireOnChangeNow);
- } else {
- HTMLElement* element = listItems()[listIndex];
+ DCHECK(usesMenuList());
+ DCHECK(!multiple());
wychen 2016/09/29 02:42:57 Should this line be DCHECK(multiple())? I'm a bit
tkent 2016/09/29 03:14:55 I think so :)
+ for (size_t i = 0; i < listIndices.size(); ++i) {
+ bool addSelectionIfNotFirst = i > 0;
+ HTMLElement* element = listItems()[listIndices[i]];
if (isHTMLOptionElement(element))
- updateSelectedState(toHTMLOptionElement(element), allowMultiplySelections, false);
- setNeedsValidityCheck();
- if (fireOnChangeNow)
- listBoxOnChange();
+ updateSelectedState(toHTMLOptionElement(element), addSelectionIfNotFirst, false);
}
+ setNeedsValidityCheck();
+ // TODO(tkent): Using listBoxOnChange() is very confusing.
+ listBoxOnChange();
}
bool HTMLSelectElement::usesMenuList() const
@@ -1267,8 +1268,8 @@ void HTMLSelectElement::handlePopupOpenKeyboardEvent(Event* event)
return;
// Save the selection so it can be compared to the new selection when
// dispatching change events during selectOption, which gets called from
- // valueChanged, which gets called after the user makes a selection from the
- // menu.
+ // selectOptionByPopup, which gets called after the user makes a selection
+ // from the menu.
saveLastSelection();
showPopup();
event->setDefaultHandled();
@@ -1386,8 +1387,8 @@ void HTMLSelectElement::menuListDefaultEventHandler(Event* event)
} else {
// Save the selection so it can be compared to the new selection
// when we call onChange during selectOption, which gets called
- // from valueChanged, which gets called after the user makes a
- // selection from the menu.
+ // from selectOptionByPopup, which gets called after the user
+ // makes a selection from the menu.
saveLastSelection();
// TODO(lanwei): Will check if we need to add
// InputDeviceCapabilities here when select menu list gets
@@ -1923,8 +1924,9 @@ HTMLOptionElement* HTMLSelectElement::optionToBeShown() const
return m_lastOnChangeOption;
}
-void HTMLSelectElement::valueChanged(unsigned listIndex)
+void HTMLSelectElement::selectOptionByPopup(int listIndex)
{
+ DCHECK(usesMenuList());
// Check to ensure a page navigation has not occurred while the popup was
// up.
Document& doc = document();
@@ -1938,7 +1940,7 @@ void HTMLSelectElement::valueChanged(unsigned listIndex)
void HTMLSelectElement::popupDidCancel()
{
if (m_indexToSelectOnCancel >= 0)
- valueChanged(m_indexToSelectOnCancel);
+ selectOptionByPopup(m_indexToSelectOnCancel);
}
void HTMLSelectElement::provisionalSelectionChanged(unsigned listIndex)
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSelectElement.h ('k') | third_party/WebKit/Source/web/ExternalPopupMenu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698