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

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: Added comments in autocomplete_history_manager.cc. Created 5 years, 6 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 51a2251258b73d0faf6bf61afbc8fec36b951d11..2fceb82dd78c93a3802d1a67c081bf2e41a1933f 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(data.value, field);
}
}
@@ -1534,4 +1533,14 @@ gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) {
bounding_box.height() * scale);
}
+void PreviewSuggestion(const base::string16& suggestion,
+ WebFormControlElement* input_element) {
+ DCHECK(input_element);
please use gerrit instead 2015/06/29 22:06:28 The rest of the code in this file does not DCHECK
Pritam Nikam 2015/06/30 15:05:50 Done.
+ input_element->setSelectionRange(
+ IsFeatureSubstringMatchEnabled()
+ ? autofill::GetTextSelectionStart(suggestion, input_element->value())
please use gerrit instead 2015/06/29 22:06:28 Either use |suggestion| or input_element->suggeste
Pritam Nikam 2015/06/30 15:05:50 Done.
+ : input_element->value().length(),
+ input_element->suggestedValue().length());
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698