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_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 Loading... | |
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 PreviewSuggestion(data.value, field); |
875 int end = field->suggestedValue().length(); | |
876 field->setSelectionRange(start, end); | |
877 } | 876 } |
878 } | 877 } |
879 | 878 |
880 // Recursively checks whether |node| or any of its children have a non-empty | 879 // Recursively checks whether |node| or any of its children have a non-empty |
881 // bounding box. The recursion depth is bounded by |depth|. | 880 // bounding box. The recursion depth is bounded by |depth|. |
882 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) { | 881 bool IsWebNodeVisibleImpl(const blink::WebNode& node, const int depth) { |
883 if (depth < 0) | 882 if (depth < 0) |
884 return false; | 883 return false; |
885 if (node.hasNonEmptyBoundingBox()) | 884 if (node.hasNonEmptyBoundingBox()) |
886 return true; | 885 return true; |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1527 } | 1526 } |
1528 | 1527 |
1529 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { | 1528 gfx::RectF GetScaledBoundingBox(float scale, WebElement* element) { |
1530 gfx::Rect bounding_box(element->boundsInViewportSpace()); | 1529 gfx::Rect bounding_box(element->boundsInViewportSpace()); |
1531 return gfx::RectF(bounding_box.x() * scale, | 1530 return gfx::RectF(bounding_box.x() * scale, |
1532 bounding_box.y() * scale, | 1531 bounding_box.y() * scale, |
1533 bounding_box.width() * scale, | 1532 bounding_box.width() * scale, |
1534 bounding_box.height() * scale); | 1533 bounding_box.height() * scale); |
1535 } | 1534 } |
1536 | 1535 |
1536 void PreviewSuggestion(const base::string16& suggestion, | |
1537 WebFormControlElement* input_element) { | |
1538 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.
| |
1539 input_element->setSelectionRange( | |
1540 IsFeatureSubstringMatchEnabled() | |
1541 ? 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.
| |
1542 : input_element->value().length(), | |
1543 input_element->suggestedValue().length()); | |
1544 } | |
1545 | |
1537 } // namespace autofill | 1546 } // namespace autofill |
OLD | NEW |