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

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: Just code rebase. 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 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_regexes.h" 17 #include "components/autofill/core/common/autofill_regexes.h"
18 #include "components/autofill/core/common/autofill_switches.h" 18 #include "components/autofill/core/common/autofill_switches.h"
19 #include "components/autofill/core/common/autofill_util.h"
19 #include "components/autofill/core/common/form_data.h" 20 #include "components/autofill/core/common/form_data.h"
20 #include "components/autofill/core/common/form_field_data.h" 21 #include "components/autofill/core/common/form_field_data.h"
21 #include "third_party/WebKit/public/platform/WebString.h" 22 #include "third_party/WebKit/public/platform/WebString.h"
22 #include "third_party/WebKit/public/platform/WebVector.h" 23 #include "third_party/WebKit/public/platform/WebVector.h"
23 #include "third_party/WebKit/public/web/WebDocument.h" 24 #include "third_party/WebKit/public/web/WebDocument.h"
24 #include "third_party/WebKit/public/web/WebElement.h" 25 #include "third_party/WebKit/public/web/WebElement.h"
25 #include "third_party/WebKit/public/web/WebElementCollection.h" 26 #include "third_party/WebKit/public/web/WebElementCollection.h"
26 #include "third_party/WebKit/public/web/WebFormControlElement.h" 27 #include "third_party/WebKit/public/web/WebFormControlElement.h"
27 #include "third_party/WebKit/public/web/WebFormElement.h" 28 #include "third_party/WebKit/public/web/WebFormElement.h"
28 #include "third_party/WebKit/public/web/WebInputElement.h" 29 #include "third_party/WebKit/public/web/WebInputElement.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 data.value.substr(0, input_element->maxLength())); 865 data.value.substr(0, input_element->maxLength()));
865 input_element->setAutofilled(true); 866 input_element->setAutofilled(true);
866 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { 867 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) {
867 field->setSuggestedValue(data.value); 868 field->setSuggestedValue(data.value);
868 field->setAutofilled(true); 869 field->setAutofilled(true);
869 } 870 }
870 871
871 if (is_initiating_node && 872 if (is_initiating_node &&
872 (IsTextInput(input_element) || IsTextAreaElement(*field))) { 873 (IsTextInput(input_element) || IsTextAreaElement(*field))) {
873 // Select the part of the text that the user didn't type. 874 // Select the part of the text that the user didn't type.
874 int start = field->value().length(); 875 if (IsFeatureSubstringMatchEnabled()) {
please use gerrit instead 2015/06/28 00:43:03 Use PreviewSuggestion() here.
Pritam Nikam 2015/06/29 15:38:21 Ditto.
875 int end = field->suggestedValue().length(); 876 size_t start = autofill::GetTextSelectionStart(field->suggestedValue(),
876 field->setSelectionRange(start, end); 877 field->value());
878 field->setSelectionRange(start, field->suggestedValue().length());
879 } else {
880 field->setSelectionRange(field->value().length(),
881 field->suggestedValue().length());
882 }
877 } 883 }
878 } 884 }
879 885
880 // Recursively checks whether |node| or any of its children have a non-empty 886 // Recursively checks whether |node| or any of its children have a non-empty
881 // bounding box. The recursion depth is bounded by |depth|. 887 // bounding box. The recursion depth is bounded by |depth|.
882 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) { 888 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) {
883 if (depth < 0) 889 if (depth < 0)
884 return false; 890 return false;
885 if (node.hasNonEmptyBoundingBox()) 891 if (node.hasNonEmptyBoundingBox())
886 return true; 892 return true;
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 1534
1529 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { 1535 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) {
1530 gfx::Rect bounding_box(element->boundsInViewportSpace()); 1536 gfx::Rect bounding_box(element->boundsInViewportSpace());
1531 return gfx::RectF(bounding_box.x() * scale, 1537 return gfx::RectF(bounding_box.x() * scale,
1532 bounding_box.y() * scale, 1538 bounding_box.y() * scale,
1533 bounding_box.width() * scale, 1539 bounding_box.width() * scale,
1534 bounding_box.height() * scale); 1540 bounding_box.height() * scale);
1535 } 1541 }
1536 1542
1537 } // namespace autofill 1543 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698