OLD | NEW |
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 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 data.value.substr(0, input_element->maxLength())); | 876 data.value.substr(0, input_element->maxLength())); |
876 input_element->setAutofilled(true); | 877 input_element->setAutofilled(true); |
877 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { | 878 } else if (IsTextAreaElement(*field) || IsSelectElement(*field)) { |
878 field->setSuggestedValue(data.value); | 879 field->setSuggestedValue(data.value); |
879 field->setAutofilled(true); | 880 field->setAutofilled(true); |
880 } | 881 } |
881 | 882 |
882 if (is_initiating_node && | 883 if (is_initiating_node && |
883 (IsTextInput(input_element) || IsTextAreaElement(*field))) { | 884 (IsTextInput(input_element) || IsTextAreaElement(*field))) { |
884 // Select the part of the text that the user didn't type. | 885 // Select the part of the text that the user didn't type. |
885 int start = field->value().length(); | 886 if (IsFeatureSubstringMatchEnabled()) { |
886 int end = field->suggestedValue().length(); | 887 size_t start = 0, end = 0; |
887 field->setSelectionRange(start, end); | 888 if (base::string16::npos != |
| 889 autofill::ComputeRange(field->suggestedValue(), field->value(), |
| 890 &start, &end)) { |
| 891 field->setSelectionRange(start, end); |
| 892 } |
| 893 } else { |
| 894 field->setSelectionRange(field->value().length(), |
| 895 field->suggestedValue().length()); |
| 896 } |
888 } | 897 } |
889 } | 898 } |
890 | 899 |
891 // Recursively checks whether |node| or any of its children have a non-empty | 900 // Recursively checks whether |node| or any of its children have a non-empty |
892 // bounding box. The recursion depth is bounded by |depth|. | 901 // bounding box. The recursion depth is bounded by |depth|. |
893 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) { | 902 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) { |
894 if (depth < 0) | 903 if (depth < 0) |
895 return false; | 904 return false; |
896 if (node.hasNonEmptyBoundingBox()) | 905 if (node.hasNonEmptyBoundingBox()) |
897 return true; | 906 return true; |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 | 1549 |
1541 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { | 1550 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { |
1542 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1551 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
1543 return gfx::RectF(bounding_box.x() * scale, | 1552 return gfx::RectF(bounding_box.x() * scale, |
1544 bounding_box.y() * scale, | 1553 bounding_box.y() * scale, |
1545 bounding_box.width() * scale, | 1554 bounding_box.width() * scale, |
1546 bounding_box.height() * scale); | 1555 bounding_box.height() * scale); |
1547 } | 1556 } |
1548 | 1557 |
1549 } // namespace autofill | 1558 } // namespace autofill |
OLD | NEW |