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

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: 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
Index: Source/core/layout/LayoutMenuList.cpp
diff --git a/Source/core/layout/LayoutMenuList.cpp b/Source/core/layout/LayoutMenuList.cpp
index 2c696e7b02aa4e781a70919ef8429e2991d34cc4..03fb69df686c6b072067483976dca090b9ba83bb 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_popupTemporarySelectedIndex(-1)
{
ASSERT(isHTMLSelectElement(element));
}
@@ -210,7 +211,9 @@ void LayoutMenuList::updateFromElement()
if (m_popupIsVisible)
m_popup->updateFromElement();
- if (selectElement()->suggestedIndex() >= 0)
+ if (m_popupTemporarySelectedIndex >= 0)
+ setTextFromOption(selectElement()->listToOptionIndex(m_popupTemporarySelectedIndex));
+ else if (selectElement()->suggestedIndex() >= 0)
setTextFromOption(selectElement()->suggestedIndex());
else
setTextFromOption(selectElement()->selectedIndex());
@@ -571,6 +574,10 @@ int LayoutMenuList::selectedIndex() const
void LayoutMenuList::popupDidHide()
{
m_popupIsVisible = false;
+ if (m_popupTemporarySelectedIndex >= 0) {
+ valueChanged(m_popupTemporarySelectedIndex);
+ m_popupTemporarySelectedIndex = -1;
+ }
}
bool LayoutMenuList::itemIsSeparator(unsigned listIndex) const
@@ -594,9 +601,10 @@ bool LayoutMenuList::itemIsSelected(unsigned listIndex) const
return isHTMLOptionElement(*element) && toHTMLOptionElement(*element).selected();
}
-void LayoutMenuList::setTextFromItem(unsigned listIndex)
+void LayoutMenuList::setProvisionallySelectedListIndex(unsigned listIndex)
{
- setTextFromOption(selectElement()->listToOptionIndex(listIndex));
+ m_popupTemporarySelectedIndex = listIndex;
+ setTextFromOption(selectElement()->listToOptionIndex(m_popupTemporarySelectedIndex));
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698