| 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" |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 | 871 |
| 872 if (!data.is_autofilled) | 872 if (!data.is_autofilled) |
| 873 return; | 873 return; |
| 874 | 874 |
| 875 WebInputElement* input_element = toWebInputElement(field); | 875 WebInputElement* input_element = toWebInputElement(field); |
| 876 if (IsCheckableElement(input_element)) { | 876 if (IsCheckableElement(input_element)) { |
| 877 input_element->setChecked(data.is_checked, true); | 877 input_element->setChecked(data.is_checked, true); |
| 878 } else { | 878 } else { |
| 879 base::string16 value = data.value; | 879 base::string16 value = data.value; |
| 880 if (IsTextInput(input_element) || IsMonthInput(input_element)) { | 880 if (IsTextInput(input_element) || IsMonthInput(input_element)) { |
| 881 // If the maxlength attribute contains a negative value, maxLength() | 881 if (input_element->maxLength() >= 0) |
| 882 // returns the default maxlength value. | 882 TruncateString(&value, input_element->maxLength()); |
| 883 TruncateString(&value, input_element->maxLength()); | |
| 884 } | 883 } |
| 885 field->setValue(value, true); | 884 field->setValue(value, true); |
| 886 } | 885 } |
| 887 | 886 |
| 888 field->setAutofilled(true); | 887 field->setAutofilled(true); |
| 889 | 888 |
| 890 if (is_initiating_node && | 889 if (is_initiating_node && |
| 891 ((IsTextInput(input_element) || IsMonthInput(input_element)) || | 890 ((IsTextInput(input_element) || IsMonthInput(input_element)) || |
| 892 IsTextAreaElement(*field))) { | 891 IsTextAreaElement(*field))) { |
| 893 int length = field->value().length(); | 892 int length = field->value().length(); |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 // Zero selection start is for password manager, which can show usernames | 1734 // Zero selection start is for password manager, which can show usernames |
| 1736 // that do not begin with the user input value. | 1735 // that do not begin with the user input value. |
| 1737 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1736 selection_start = (offset == base::string16::npos) ? 0 : offset; |
| 1738 } | 1737 } |
| 1739 | 1738 |
| 1740 input_element->setSelectionRange(selection_start, suggestion.length()); | 1739 input_element->setSelectionRange(selection_start, suggestion.length()); |
| 1741 } | 1740 } |
| 1742 | 1741 |
| 1743 } // namespace form_util | 1742 } // namespace form_util |
| 1744 } // namespace autofill | 1743 } // namespace autofill |
| OLD | NEW |