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

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

Issue 138433002: Add Autofill preview support for <select> input fields (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase and update code to be in line with the latest code base 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | Source/core/rendering/RenderListBox.cpp » ('j') | 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 6be5c079cccbc348acd6f9a648b0a4354870d240..6349335eedd54dc357abc420cf9b3a050469bd89 100644
--- a/Source/core/html/HTMLSelectElement.cpp
+++ b/Source/core/html/HTMLSelectElement.cpp
@@ -253,6 +253,35 @@ void HTMLSelectElement::setValue(const String &value)
setSelectedIndex(-1);
}
+String HTMLSelectElement::suggestedValue() const
+{
+ return m_suggestedValue;
keishi 2014/03/13 04:47:50 It doesn't matter yet, but, HTMLInputElement seems
ziran.sun 2014/03/13 11:20:52 Done.
+}
+
+void HTMLSelectElement::setSuggestedValue(const String& value)
+{
+ m_suggestedValue = value;
+
+ if (value.isNull()) {
+ setSuggestedIndex(-1);
+ return;
+ }
+
+ const Vector<HTMLElement*>& items = listItems();
+ unsigned optionIndex = 0;
+ for (unsigned i = 0; i < items.size(); i++) {
+ if (items[i]->hasLocalName(optionTag)) {
+ if (toHTMLOptionElement(items[i])->value() == value) {
+ setSuggestedIndex(optionIndex);
+ return;
+ }
+ optionIndex++;
+ }
+ }
+
+ setSuggestedIndex(-1);
+}
+
bool HTMLSelectElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == alignAttr) {
@@ -795,6 +824,24 @@ void HTMLSelectElement::setSelectedIndex(int index)
selectOption(index, DeselectOtherOptions);
}
+int HTMLSelectElement::suggestedIndex() const
+{
+ return m_suggestedIndex;
+}
+
+void HTMLSelectElement::setSuggestedIndex(int suggestedIndex)
+{
+ m_suggestedIndex = suggestedIndex;
+
+ if (RenderObject* renderer = this->renderer()) {
+ renderer->updateFromElement();
+ if (renderer->isListBox())
+ toRenderListBox(renderer)->scrollToRevealElementAtListIndex(suggestedIndex);
+ }
+
+ setNeedsValidityCheck();
+}
+
void HTMLSelectElement::optionSelectionStateChanged(HTMLOptionElement* option, bool optionIsSelected)
{
ASSERT(option->ownerSelectElement() == this);
« no previous file with comments | « Source/core/html/HTMLSelectElement.h ('k') | Source/core/rendering/RenderListBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698