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

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

Issue 613213002: [Patch resubmit]: Turn off autofill highlight when changing option in an autofilled <select> element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update code as per review comments. Created 6 years, 2 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/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLSelectElement.cpp
diff --git a/Source/core/html/HTMLSelectElement.cpp b/Source/core/html/HTMLSelectElement.cpp
index 9f1a5835a7c91e3b02988228ef2974fbd0b6e9ab..130987773a9acd18a7b95053067fb5ef731ad9b9 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -82,6 +82,7 @@ HTMLSelectElement::HTMLSelectElement(Document& document, HTMLFormElement* form)
, m_activeSelectionState(false)
, m_shouldRecalcListItems(false)
, m_suggestedIndex(-1)
+ , m_isAutofilledByPreview(false)
{
}
@@ -269,6 +270,8 @@ void HTMLSelectElement::setValue(const String &value, bool sendEvents)
int previousSelectedIndex = selectedIndex();
setSuggestedIndex(-1);
+ if (m_isAutofilledByPreview)
+ setAutofilled(false);
setSelectedIndex(optionIndex);
if (sendEvents && previousSelectedIndex != selectedIndex()) {
@@ -304,6 +307,7 @@ void HTMLSelectElement::setSuggestedValue(const String& value)
if (isHTMLOptionElement(items[i])) {
if (toHTMLOptionElement(items[i])->value() == value) {
setSuggestedIndex(optionIndex);
+ m_isAutofilledByPreview = true;
return;
}
optionIndex++;
@@ -924,6 +928,9 @@ void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems();
int listIndex = optionToListIndex(optionIndex);
+ if (selectedIndex() != optionIndex && isAutofilled())
+ setAutofilled(false);
+
HTMLElement* element = 0;
if (listIndex >= 0) {
element = items[listIndex];
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698