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 51a2251258b73d0faf6bf61afbc8fec36b951d11..20a3736f3039a9d1f9bd5ee86d685fc82748c087 100644 |
--- a/components/autofill/content/renderer/form_autofill_util.cc |
+++ b/components/autofill/content/renderer/form_autofill_util.cc |
@@ -16,6 +16,7 @@ |
#include "components/autofill/core/common/autofill_data_validation.h" |
#include "components/autofill/core/common/autofill_regexes.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" |
@@ -871,9 +872,7 @@ 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); |
+ PreviewSuggestion(field->suggestedValue(), field->value(), field); |
} |
} |
@@ -1534,4 +1533,15 @@ gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { |
bounding_box.height() * scale); |
} |
+void PreviewSuggestion(const base::string16& suggestion, |
+ const base::string16& user_input, |
+ blink::WebFormControlElement* input_element) { |
+ input_element->setSelectionRange( |
+ IsFeatureSubstringMatchEnabled() |
+ ? std::min(autofill::GetTextSelectionStart(suggestion, user_input), |
please use gerrit instead
2015/07/03 02:05:43
GetTextSelectionStart() returns only one thing tha
Pritam Nikam
2015/07/03 16:21:27
For password forms we autocomplete field_contents
please use gerrit instead
2015/07/03 22:05:47
Now it makes sense. Please put a sentence about th
Pritam Nikam
2015/07/06 15:29:27
Done.
Changed to:
-- [snap] --
size_t select
|
+ suggestion.length()) |
+ : user_input.length(), |
+ suggestion.length()); |
+} |
+ |
} // namespace autofill |