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

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

Issue 2183773003: DATALIST element: Filter DATALIST OPTIONs by sustring matching (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLInputElementTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 aff2e0ced5a732300f2b0d2a03be2a7a0c9a6c2a..46f57714d851fec3a64537ee81f4247643f91028 100644
--- a/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLInputElement.cpp
@@ -1590,21 +1590,28 @@ HeapVector<Member<HTMLOptionElement>> HTMLInputElement::filteredDataListOptions(
if (!dataList)
return filtered;
- String prefix = innerEditorValue();
+ String value = innerEditorValue();
if (multiple() && type() == InputTypeNames::email) {
Vector<String> emails;
- prefix.split(',', true, emails);
+ value.split(',', true, emails);
if (!emails.isEmpty())
- prefix = emails.last().stripWhiteSpace();
+ value = emails.last().stripWhiteSpace();
}
HTMLDataListOptionsCollection* options = dataList->options();
filtered.reserveCapacity(options->length());
- prefix = prefix.lower();
+ value = value.foldCase();
for (unsigned i = 0; i < options->length(); ++i) {
HTMLOptionElement* option = options->item(i);
DCHECK(option);
- if (!option->value().lower().startsWith(prefix) || !isValidValue(option->value()))
+ if (!value.isEmpty()) {
+ // Firefox shows OPTIONs with matched labels, Edge shows OPTIONs
+ // with matches values. We show both.
+ if (option->value().foldCase().find(value) == kNotFound && option->label().foldCase().find(value) == kNotFound)
+ continue;
+ }
+ // TODO(tkent): Should allow invalid strings. crbug.com/607097.
+ if (!isValidValue(option->value()))
continue;
filtered.append(option);
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLInputElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698