Index: components/autofill/content/renderer/autofill_agent.cc |
diff --git a/components/autofill/content/renderer/autofill_agent.cc b/components/autofill/content/renderer/autofill_agent.cc |
index 79542aff2520a500debcf60c29699d73e28d5524..36fb679e0e0d7f4b48048d9468aad4c26c9580f7 100644 |
--- a/components/autofill/content/renderer/autofill_agent.cc |
+++ b/components/autofill/content/renderer/autofill_agent.cc |
@@ -571,10 +571,11 @@ void AutofillAgent::OnFillFieldWithValue(const base::string16& value) { |
} |
} |
-void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value) { |
+void AutofillAgent::OnPreviewFieldWithValue(const base::string16& value, |
+ int match_start) { |
WebInputElement* input_element = toWebInputElement(&element_); |
if (input_element) |
- PreviewFieldWithValue(value, input_element); |
+ PreviewFieldWithValue(value, input_element, match_start); |
} |
void AutofillAgent::OnAcceptDataListSuggestion(const base::string16& value) { |
@@ -590,13 +591,11 @@ void AutofillAgent::OnFillPasswordSuggestion(const base::string16& username, |
DCHECK(handled); |
} |
-void AutofillAgent::OnPreviewPasswordSuggestion( |
- const base::string16& username, |
- const base::string16& password) { |
- bool handled = password_autofill_agent_->PreviewSuggestion( |
- element_, |
- username, |
- password); |
+void AutofillAgent::OnPreviewPasswordSuggestion(const base::string16& username, |
+ const base::string16& password, |
+ int start) { |
+ bool handled = password_autofill_agent_->PreviewSuggestion(element_, username, |
+ password, start); |
DCHECK(handled); |
} |
@@ -736,11 +735,12 @@ void AutofillAgent::FillFieldWithValue(const base::string16& value, |
} |
void AutofillAgent::PreviewFieldWithValue(const base::string16& value, |
- WebInputElement* node) { |
+ WebInputElement* node, |
+ int match_start) { |
was_query_node_autofilled_ = element_.isAutofilled(); |
node->setSuggestedValue(value.substr(0, node->maxLength())); |
node->setAutofilled(true); |
- node->setSelectionRange(node->value().length(), |
+ node->setSelectionRange(std::min(match_start, node->maxLength()), |
node->suggestedValue().length()); |
} |