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

Unified Diff: third_party/WebKit/Source/core/html/HTMLInputElement.cpp

Issue 2174303002: Move filtering logic in GetDataListSuggestions() to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move implementation to HTMLInputElement Created 4 years, 5 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: third_party/WebKit/Source/core/html/HTMLInputElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
index dd60325e359704461bc601ac3a7ba95e1048314c..aff2e0ced5a732300f2b0d2a03be2a7a0c9a6c2a 100644
--- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -1583,6 +1583,34 @@ bool HTMLInputElement::hasValidDataListOptions() const
return false;
}
+HeapVector<Member<HTMLOptionElement>> HTMLInputElement::filteredDataListOptions() const
+{
+ HeapVector<Member<HTMLOptionElement>> filtered;
+ HTMLDataListElement* dataList = this->dataList();
+ if (!dataList)
+ return filtered;
+
+ String prefix = innerEditorValue();
+ if (multiple() && type() == InputTypeNames::email) {
+ Vector<String> emails;
+ prefix.split(',', true, emails);
+ if (!emails.isEmpty())
+ prefix = emails.last().stripWhiteSpace();
+ }
+
+ HTMLDataListOptionsCollection* options = dataList->options();
+ filtered.reserveCapacity(options->length());
+ prefix = prefix.lower();
+ for (unsigned i = 0; i < options->length(); ++i) {
+ HTMLOptionElement* option = options->item(i);
+ DCHECK(option);
+ if (!option->value().lower().startsWith(prefix) || !isValidValue(option->value()))
+ continue;
+ filtered.append(option);
+ }
+ return filtered;
+}
+
void HTMLInputElement::setListAttributeTargetObserver(ListAttributeTargetObserver* newObserver)
{
if (m_listAttributeTargetObserver)

Powered by Google App Engine
This is Rietveld 408576698