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

Unified Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 962673004: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses review comments. Created 5 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
Index: components/autofill/content/renderer/form_autofill_util.cc
diff --git a/components/autofill/content/renderer/form_autofill_util.cc b/components/autofill/content/renderer/form_autofill_util.cc
index 91d3572bc0d4df6142aa02620786d77109b8b78e..a180071e6cb4bf1b153eb031288c05028575f342 100644
--- a/components/autofill/content/renderer/form_autofill_util.cc
+++ b/components/autofill/content/renderer/form_autofill_util.cc
@@ -15,6 +15,7 @@
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/common/autofill_data_validation.h"
#include "components/autofill/core/common/autofill_switches.h"
+#include "components/autofill/core/common/autofill_util.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/form_field_data.h"
#include "third_party/WebKit/public/platform/WebString.h"
@@ -882,9 +883,18 @@ void PreviewFormField(const FormFieldData& data,
if (is_initiating_node &&
(IsTextInput(input_element) || IsTextAreaElement(*field))) {
// Select the part of the text that the user didn't type.
- int start = field->value().length();
- int end = field->suggestedValue().length();
- field->setSelectionRange(start, end);
+ if (IsFeatureSubstringMatchEnabled()) {
+ size_t start = 0;
+ size_t end = 0;
+ if (base::string16::npos !=
+ autofill::ComputeRange(field->suggestedValue(), field->value(),
Evan Stade 2015/03/31 21:41:52 can you use StartsAt directly
Pritam Nikam 2015/04/01 09:10:37 StartsAt() is not equipped handle all complected c
+ &start, &end)) {
+ field->setSelectionRange(start, end);
+ }
+ } else {
+ field->setSelectionRange(field->value().length(),
+ field->suggestedValue().length());
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698