diff options
author | Mathieu Perreault <mathp@chromium.org> | 2015-11-26 08:13:51 -0500 |
---|---|---|
committer | Mathieu Perreault <mathp@chromium.org> | 2015-11-26 13:15:25 +0000 |
commit | a1412e66eac56c26789ee4658743271ac670d119 (patch) | |
tree | 44a9789fc173fa81fda14c3e0843604717f0c3b8 | |
parent | d48293d7acb78478d961e79da3556c8b147e82ac (diff) | |
download | chromium_src-a1412e66eac56c26789ee4658743271ac670d119.zip chromium_src-a1412e66eac56c26789ee4658743271ac670d119.tar.gz chromium_src-a1412e66eac56c26789ee4658743271ac670d119.tar.bz2 |
[Autofill] Remove datalist flash when there is an existing entry.
When clicking the datalist arrow the full list would briefly flash before it was filtered down according to the existing entry.
We now filter in all cases on the existing entry. A separate bug will be filed for autofill/datalist interaction when clicking the arrow.
BUG=501161
TEST=manual
Review URL: https://codereview.chromium.org/1455093004
Cr-Commit-Position: refs/heads/master@{#360626}
(cherry picked from commit 523de48cdc8b3e2e1be7a941960b9c168e67b882)
Review URL: https://codereview.chromium.org/1476023004 .
Cr-Commit-Position: refs/branch-heads/2564@{#142}
Cr-Branched-From: 1283eca15bd9f772387f75241576cde7bdec7f54-refs/heads/master@{#359700}
-rw-r--r-- | components/autofill/content/renderer/autofill_agent.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc index f15a580..fbcfeab 100644 --- a/components/autofill/content/renderer/autofill_agent.cc +++ b/components/autofill/content/renderer/autofill_agent.cc @@ -78,26 +78,25 @@ namespace { // Gets all the data list values (with corresponding label) for the given // element. void GetDataListSuggestions(const WebInputElement& element, - bool ignore_current_value, std::vector<base::string16>* values, std::vector<base::string16>* labels) { WebElementCollection options = element.dataListOptions(); if (options.isNull()) return; - base::string16 prefix; - if (!ignore_current_value) { - prefix = element.editingValue(); - if (element.isMultiple() && element.isEmailField()) { - const base::char16 comma[2] = { ',', 0 }; - std::vector<base::string16> parts = base::SplitString( - prefix, comma, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); - if (parts.size() > 0) { - base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, - &prefix); - } + // If the field accepts multiple email addresses, filter only on the last one. + base::string16 prefix = element.editingValue(); + if (element.isMultiple() && element.isEmailField()) { + std::vector<base::string16> parts = base::SplitString( + prefix, base::ASCIIToUTF16(","), base::TRIM_WHITESPACE, + base::SPLIT_WANT_ALL); + if (!parts.empty()) { + base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, + &prefix); } } + + // Prefix filtering. prefix = base::i18n::ToLower(prefix); for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { @@ -739,7 +738,6 @@ void AutofillAgent::QueryAutofillSuggestions( if (input_element) { // Find the datalist values and send them to the browser process. GetDataListSuggestions(*input_element, - datalist_only, &data_list_values, &data_list_labels); TrimStringVectorForIPC(&data_list_values); |