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

Side by Side Diff: Source/core/rendering/RenderMenuList.cpp

Issue 138433002: Add Autofill preview support for <select> input fields (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update code as per keishi's review comment. Created 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of the select element renderer in WebCore. 2 * This file is part of the select element renderer in WebCore.
3 * 3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 6 * 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 setNeedsLayoutAndPrefWidthsRecalc(); 196 setNeedsLayoutAndPrefWidthsRecalc();
197 } 197 }
198 198
199 void RenderMenuList::updateFromElement() 199 void RenderMenuList::updateFromElement()
200 { 200 {
201 if (m_optionsChanged) { 201 if (m_optionsChanged) {
202 updateOptionsWidth(); 202 updateOptionsWidth();
203 m_optionsChanged = false; 203 m_optionsChanged = false;
204 } 204 }
205 205
206 if (m_popupIsVisible) 206 if (m_popupIsVisible) {
207 m_popup->updateFromElement(); 207 m_popup->updateFromElement();
208 else 208 } else {
209 setTextFromOption(selectElement()->selectedIndex()); 209 if (selectElement()->suggestedIndex() >= 0)
210 setTextFromOption(selectElement()->suggestedIndex());
211 else
212 setTextFromOption(selectElement()->selectedIndex());
213 }
210 } 214 }
211 215
212 void RenderMenuList::setTextFromOption(int optionIndex) 216 void RenderMenuList::setTextFromOption(int optionIndex)
213 { 217 {
214 HTMLSelectElement* select = selectElement(); 218 HTMLSelectElement* select = selectElement();
215 const Vector<HTMLElement*>& listItems = select->listItems(); 219 const Vector<HTMLElement*>& listItems = select->listItems();
216 int size = listItems.size(); 220 int size = listItems.size();
217 221
218 int i = select->optionToListIndex(optionIndex); 222 int i = select->optionToListIndex(optionIndex);
219 String text = emptyString(); 223 String text = emptyString();
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 HTMLElement* element = listItems[listIndex]; 566 HTMLElement* element = listItems[listIndex];
563 return element->hasTagName(optionTag) && toHTMLOptionElement(element)->selec ted(); 567 return element->hasTagName(optionTag) && toHTMLOptionElement(element)->selec ted();
564 } 568 }
565 569
566 void RenderMenuList::setTextFromItem(unsigned listIndex) 570 void RenderMenuList::setTextFromItem(unsigned listIndex)
567 { 571 {
568 setTextFromOption(selectElement()->listToOptionIndex(listIndex)); 572 setTextFromOption(selectElement()->listToOptionIndex(listIndex));
569 } 573 }
570 574
571 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698