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 b1f3056e69a2516320d86e87637ef981da1e7158..44a2b23290eec61f2d11eababb2692495c6bfc50 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" |
@@ -870,9 +871,16 @@ 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 = autofill::GetTextSelectionStart(field->suggestedValue(), |
+ field->value()); |
+ if (start != base::string16::npos) { |
Evan Stade
2015/04/27 19:25:21
no curlies
Pritam Nikam
2015/04/28 14:45:55
Done.
|
+ field->setSelectionRange(start, field->suggestedValue().length()); |
+ } |
+ } else { |
+ field->setSelectionRange(field->value().length(), |
+ field->suggestedValue().length()); |
+ } |
} |
} |