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 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 WebInputElement* input_element = toWebInputElement(field); | 884 WebInputElement* input_element = toWebInputElement(field); |
885 if (IsCheckableElement(input_element)) { | 885 if (IsCheckableElement(input_element)) { |
886 input_element->setChecked(data.is_checked, true); | 886 input_element->setChecked(data.is_checked, true); |
887 } else { | 887 } else { |
888 base::string16 value = data.value; | 888 base::string16 value = data.value; |
889 if (IsTextInput(input_element) || IsMonthInput(input_element)) { | 889 if (IsTextInput(input_element) || IsMonthInput(input_element)) { |
890 // If the maxlength attribute contains a negative value, maxLength() | 890 // If the maxlength attribute contains a negative value, maxLength() |
891 // returns the default maxlength value. | 891 // returns the default maxlength value. |
892 TruncateString(&value, input_element->maxLength()); | 892 TruncateString(&value, input_element->maxLength()); |
893 } | 893 } |
894 field->setValue(value, true); | 894 field->setAutofillValue(value); |
895 } | 895 } |
896 | 896 |
897 field->setAutofilled(true); | 897 field->setAutofilled(true); |
898 | 898 |
899 if (is_initiating_node && | 899 if (is_initiating_node && |
900 ((IsTextInput(input_element) || IsMonthInput(input_element)) || | 900 ((IsTextInput(input_element) || IsMonthInput(input_element)) || |
901 IsTextAreaElement(*field))) { | 901 IsTextAreaElement(*field))) { |
902 int length = field->value().length(); | 902 int length = field->value().length(); |
903 field->setSelectionRange(length, length); | 903 field->setSelectionRange(length, length); |
904 // Clear the current IME composition (the underline), if there is one. | 904 // Clear the current IME composition (the underline), if there is one. |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 // Zero selection start is for password manager, which can show usernames | 1763 // Zero selection start is for password manager, which can show usernames |
1764 // that do not begin with the user input value. | 1764 // that do not begin with the user input value. |
1765 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1765 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1766 } | 1766 } |
1767 | 1767 |
1768 input_element->setSelectionRange(selection_start, suggestion.length()); | 1768 input_element->setSelectionRange(selection_start, suggestion.length()); |
1769 } | 1769 } |
1770 | 1770 |
1771 } // namespace form_util | 1771 } // namespace form_util |
1772 } // namespace autofill | 1772 } // namespace autofill |
OLD | NEW |