| Index: third_party/WebKit/Source/web/WebInputElement.cpp
|
| diff --git a/third_party/WebKit/Source/web/WebInputElement.cpp b/third_party/WebKit/Source/web/WebInputElement.cpp
|
| index e8b4233335d845035dcc235a4a6b04be14f6b5e9..c116144aac83e38e3d7f2120ee68442af9a6e4ad 100644
|
| --- a/third_party/WebKit/Source/web/WebInputElement.cpp
|
| +++ b/third_party/WebKit/Source/web/WebInputElement.cpp
|
| @@ -42,6 +42,7 @@
|
| #include "platform/RuntimeEnabledFeatures.h"
|
| #include "public/platform/WebString.h"
|
| #include "public/web/WebElementCollection.h"
|
| +#include "public/web/WebOptionElement.h"
|
| #include "wtf/PassRefPtr.h"
|
|
|
| namespace blink {
|
| @@ -122,11 +123,33 @@ bool WebInputElement::isMultiple() const
|
| return constUnwrap<HTMLInputElement>()->multiple();
|
| }
|
|
|
| -WebElementCollection WebInputElement::dataListOptions() const
|
| -{
|
| - if (HTMLDataListElement* dataList = toHTMLDataListElement(constUnwrap<HTMLInputElement>()->list()))
|
| - return WebElementCollection(dataList->options());
|
| - return WebElementCollection();
|
| +WebVector<WebOptionElement> WebInputElement::filteredDataListOptions() const
|
| +{
|
| + const HTMLInputElement* input = constUnwrap<HTMLInputElement>();
|
| + Vector<WebOptionElement> filtered;
|
| + HTMLDataListElement* dataList = input->dataList();
|
| + if (!dataList)
|
| + return filtered;
|
| +
|
| + String prefix = input->innerEditorValue();
|
| + if (input->multiple() && input->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) || !input->isValidValue(option->value()))
|
| + continue;
|
| + filtered.append(WebOptionElement(option));
|
| + }
|
| + return filtered;
|
| }
|
|
|
| WebString WebInputElement::localizeValue(const WebString& proposedValue) const
|
|
|