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

Side by Side 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: Incorporated Evan's review inputs. Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/content/renderer/form_autofill_util.h" 5 #include "components/autofill/content/renderer/form_autofill_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "components/autofill/core/common/autofill_data_validation.h" 16 #include "components/autofill/core/common/autofill_data_validation.h"
17 #include "components/autofill/core/common/autofill_switches.h" 17 #include "components/autofill/core/common/autofill_switches.h"
18 #include "components/autofill/core/common/autofill_util.h"
18 #include "components/autofill/core/common/form_data.h" 19 #include "components/autofill/core/common/form_data.h"
19 #include "components/autofill/core/common/form_field_data.h" 20 #include "components/autofill/core/common/form_field_data.h"
20 #include "third_party/WebKit/public/platform/WebString.h" 21 #include "third_party/WebKit/public/platform/WebString.h"
21 #include "third_party/WebKit/public/platform/WebVector.h" 22 #include "third_party/WebKit/public/platform/WebVector.h"
22 #include "third_party/WebKit/public/web/WebDocument.h" 23 #include "third_party/WebKit/public/web/WebDocument.h"
23 #include "third_party/WebKit/public/web/WebElement.h" 24 #include "third_party/WebKit/public/web/WebElement.h"
24 #include "third_party/WebKit/public/web/WebElementCollection.h" 25 #include "third_party/WebKit/public/web/WebElementCollection.h"
25 #include "third_party/WebKit/public/web/WebFormControlElement.h" 26 #include "third_party/WebKit/public/web/WebFormControlElement.h"
26 #include "third_party/WebKit/public/web/WebFormElement.h" 27 #include "third_party/WebKit/public/web/WebFormElement.h"
27 #include "third_party/WebKit/public/web/WebInputElement.h" 28 #include "third_party/WebKit/public/web/WebInputElement.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 data.value.substr(0, input_element->maxLength())); 864 data.value.substr(0, input_element->maxLength()));
864 input_element->setAutofilled(true); 865 input_element->setAutofilled(true);
865 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { 866 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) {
866 field->setSuggestedValue(data.value); 867 field->setSuggestedValue(data.value);
867 field->setAutofilled(true); 868 field->setAutofilled(true);
868 } 869 }
869 870
870 if (is_initiating_node && 871 if (is_initiating_node &&
871 (IsTextInput(input_element) || IsTextAreaElement(*field))) { 872 (IsTextInput(input_element) || IsTextAreaElement(*field))) {
872 // Select the part of the text that the user didn't type. 873 // Select the part of the text that the user didn't type.
873 int start = field->value().length(); 874 if (IsFeatureSubstringMatchEnabled()) {
874 int end = field->suggestedValue().length(); 875 size_t start = autofill::GetTextSelectionStart(field->suggestedValue(),
875 field->setSelectionRange(start, end); 876 field->value());
877 if (start != base::string16::npos) {
Evan Stade 2015/04/27 19:25:21 no curlies
Pritam Nikam 2015/04/28 14:45:55 Done.
878 field->setSelectionRange(start, field->suggestedValue().length());
879 }
880 } else {
881 field->setSelectionRange(field->value().length(),
882 field->suggestedValue().length());
883 }
876 } 884 }
877 } 885 }
878 886
879 // Recursively checks whether |node| or any of its children have a non-empty 887 // Recursively checks whether |node| or any of its children have a non-empty
880 // bounding box. The recursion depth is bounded by |depth|. 888 // bounding box. The recursion depth is bounded by |depth|.
881 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) { 889 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) {
882 if (depth < 0) 890 if (depth < 0)
883 return false; 891 return false;
884 if (node.hasNonEmptyBoundingBox()) 892 if (node.hasNonEmptyBoundingBox())
885 return true; 893 return true;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 1506
1499 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { 1507 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) {
1500 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1508 gfx::Rect bounding_box(element->boundsInViewportSpace());
1501 return gfx::RectF(bounding_box.x() * scale, 1509 return gfx::RectF(bounding_box.x() * scale,
1502 bounding_box.y() * scale, 1510 bounding_box.y() * scale,
1503 bounding_box.width() * scale, 1511 bounding_box.width() * scale,
1504 bounding_box.height() * scale); 1512 bounding_box.height() * scale);
1505 } 1513 }
1506 1514
1507 } // namespace autofill 1515 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698