Chromium Code Reviews| 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()); | 
| + } | 
| } | 
| } |