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

Side by Side Diff: Source/core/html/HTMLSelectElement.cpp

Issue 553983012: 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: Add NeedRebaseline for test code. Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 2 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 * (C) 1999 Antti Koivisto (koivisto@kde.org)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 7 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 9 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
10 * 10 *
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 , m_typeAhead(this) 75 , m_typeAhead(this)
76 , m_size(0) 76 , m_size(0)
77 , m_lastOnChangeIndex(-1) 77 , m_lastOnChangeIndex(-1)
78 , m_activeSelectionAnchorIndex(-1) 78 , m_activeSelectionAnchorIndex(-1)
79 , m_activeSelectionEndIndex(-1) 79 , m_activeSelectionEndIndex(-1)
80 , m_isProcessingUserDrivenChange(false) 80 , m_isProcessingUserDrivenChange(false)
81 , m_multiple(false) 81 , m_multiple(false)
82 , m_activeSelectionState(false) 82 , m_activeSelectionState(false)
83 , m_shouldRecalcListItems(false) 83 , m_shouldRecalcListItems(false)
84 , m_suggestedIndex(-1) 84 , m_suggestedIndex(-1)
85 , m_isAutofilledByPreview(false)
85 { 86 {
86 } 87 }
87 88
88 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument) 89 PassRefPtrWillBeRawPtr<HTMLSelectElement> HTMLSelectElement::create(Document& do cument)
89 { 90 {
90 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe lectElement(document, 0)); 91 RefPtrWillBeRawPtr<HTMLSelectElement> select = adoptRefWillBeNoop(new HTMLSe lectElement(document, 0));
91 select->ensureUserAgentShadowRoot(); 92 select->ensureUserAgentShadowRoot();
92 return select.release(); 93 return select.release();
93 } 94 }
94 95
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 break; 263 break;
263 optionIndex++; 264 optionIndex++;
264 } 265 }
265 } 266 }
266 if (optionIndex >= static_cast<int>(items.size())) 267 if (optionIndex >= static_cast<int>(items.size()))
267 optionIndex = -1; 268 optionIndex = -1;
268 } 269 }
269 270
270 int previousSelectedIndex = selectedIndex(); 271 int previousSelectedIndex = selectedIndex();
271 setSuggestedIndex(-1); 272 setSuggestedIndex(-1);
273 if (m_isAutofilledByPreview)
274 setAutofilled(false);
272 setSelectedIndex(optionIndex); 275 setSelectedIndex(optionIndex);
273 276
274 if (sendEvents && previousSelectedIndex != selectedIndex()) { 277 if (sendEvents && previousSelectedIndex != selectedIndex()) {
275 if (usesMenuList()) 278 if (usesMenuList())
276 dispatchInputAndChangeEventForMenuList(false); 279 dispatchInputAndChangeEventForMenuList(false);
277 else 280 else
278 listBoxOnChange(); 281 listBoxOnChange();
279 } 282 }
280 } 283 }
281 284
(...skipping 15 matching lines...) Expand all
297 setSuggestedIndex(-1); 300 setSuggestedIndex(-1);
298 return; 301 return;
299 } 302 }
300 303
301 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems( ); 304 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems( );
302 unsigned optionIndex = 0; 305 unsigned optionIndex = 0;
303 for (unsigned i = 0; i < items.size(); ++i) { 306 for (unsigned i = 0; i < items.size(); ++i) {
304 if (isHTMLOptionElement(items[i])) { 307 if (isHTMLOptionElement(items[i])) {
305 if (toHTMLOptionElement(items[i])->value() == value) { 308 if (toHTMLOptionElement(items[i])->value() == value) {
306 setSuggestedIndex(optionIndex); 309 setSuggestedIndex(optionIndex);
310 m_isAutofilledByPreview = true;
307 return; 311 return;
308 } 312 }
309 optionIndex++; 313 optionIndex++;
310 } 314 }
311 } 315 }
312 316
313 setSuggestedIndex(-1); 317 setSuggestedIndex(-1);
314 } 318 }
315 319
316 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const 320 bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 setAutofilled(false); 921 setAutofilled(false);
918 } 922 }
919 923
920 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags) 924 void HTMLSelectElement::selectOption(int optionIndex, SelectOptionFlags flags)
921 { 925 {
922 bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions); 926 bool shouldDeselect = !m_multiple || (flags & DeselectOtherOptions);
923 927
924 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems( ); 928 const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& items = listItems( );
925 int listIndex = optionToListIndex(optionIndex); 929 int listIndex = optionToListIndex(optionIndex);
926 930
931 if (selectedIndex() != optionIndex && this->isAutofilled())
932 setAutofilled(false);
933
927 HTMLElement* element = 0; 934 HTMLElement* element = 0;
928 if (listIndex >= 0) { 935 if (listIndex >= 0) {
929 element = items[listIndex]; 936 element = items[listIndex];
930 if (isHTMLOptionElement(*element)) { 937 if (isHTMLOptionElement(*element)) {
931 if (m_activeSelectionAnchorIndex < 0 || shouldDeselect) 938 if (m_activeSelectionAnchorIndex < 0 || shouldDeselect)
932 setActiveSelectionAnchorIndex(listIndex); 939 setActiveSelectionAnchorIndex(listIndex);
933 if (m_activeSelectionEndIndex < 0 || shouldDeselect) 940 if (m_activeSelectionEndIndex < 0 || shouldDeselect)
934 setActiveSelectionEndIndex(listIndex); 941 setActiveSelectionEndIndex(listIndex);
935 toHTMLOptionElement(*element).setSelectedState(true); 942 toHTMLOptionElement(*element).setSelectedState(true);
936 } 943 }
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 int focusedIndex = activeSelectionEndListIndex(); 1748 int focusedIndex = activeSelectionEndListIndex();
1742 if (focusedIndex < 0) 1749 if (focusedIndex < 0)
1743 focusedIndex = firstSelectableListIndex(); 1750 focusedIndex = firstSelectableListIndex();
1744 if (focusedIndex < 0) 1751 if (focusedIndex < 0)
1745 return nullptr; 1752 return nullptr;
1746 HTMLElement* focused = listItems()[focusedIndex]; 1753 HTMLElement* focused = listItems()[focusedIndex];
1747 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ; 1754 return isHTMLOptionElement(focused) ? toHTMLOptionElement(focused) : nullptr ;
1748 } 1755 }
1749 1756
1750 } // namespace 1757 } // namespace
OLDNEW
« 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