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

Unified Diff: Source/core/layout/LayoutMenuList.cpp

Issue 1013303004: Fix issue on <select> style change when popup is visible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test expectation Created 5 years, 9 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 | « Source/core/layout/LayoutMenuList.h ('k') | Source/web/ExternalPopupMenuTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutMenuList.cpp
diff --git a/Source/core/layout/LayoutMenuList.cpp b/Source/core/layout/LayoutMenuList.cpp
index 321dfd4ad687d44170890ebd5e58c32ed5a1e0b8..89ec3d55559070469b34023e3cafb9a3d594008e 100644
--- a/Source/core/layout/LayoutMenuList.cpp
+++ b/Source/core/layout/LayoutMenuList.cpp
@@ -59,6 +59,7 @@ LayoutMenuList::LayoutMenuList(Element* element)
, m_optionsWidth(0)
, m_lastActiveIndex(-1)
, m_popupIsVisible(false)
+ , m_indexToSelectOnCancel(-1)
{
ASSERT(isHTMLSelectElement(element));
}
@@ -210,7 +211,9 @@ void LayoutMenuList::updateFromElement()
if (m_popupIsVisible)
m_popup->updateFromElement();
- if (selectElement()->suggestedIndex() >= 0)
+ if (m_indexToSelectOnCancel >= 0)
+ setTextFromOption(selectElement()->listToOptionIndex(m_indexToSelectOnCancel));
+ else if (selectElement()->suggestedIndex() >= 0)
setTextFromOption(selectElement()->suggestedIndex());
else
setTextFromOption(selectElement()->selectedIndex());
@@ -579,6 +582,14 @@ void LayoutMenuList::popupDidHide()
cache->didHideMenuListPopup(this);
}
+void LayoutMenuList::popupDidCancel()
+{
+ if (m_indexToSelectOnCancel >= 0) {
+ valueChanged(m_indexToSelectOnCancel);
+ m_indexToSelectOnCancel = -1;
+ }
+}
+
bool LayoutMenuList::itemIsSeparator(unsigned listIndex) const
{
const WillBeHeapVector<RawPtrWillBeMember<HTMLElement>>& listItems = selectElement()->listItems();
@@ -600,9 +611,10 @@ bool LayoutMenuList::itemIsSelected(unsigned listIndex) const
return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).selected();
}
-void LayoutMenuList::setTextFromItem(unsigned listIndex)
+void LayoutMenuList::provisionalSelectionChanged(unsigned listIndex)
{
- setTextFromOption(selectElement()->listToOptionIndex(listIndex));
+ m_indexToSelectOnCancel = listIndex;
+ setTextFromOption(selectElement()->listToOptionIndex(m_indexToSelectOnCancel));
}
} // namespace blink
« no previous file with comments | « Source/core/layout/LayoutMenuList.h ('k') | Source/web/ExternalPopupMenuTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698