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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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->setValue(value, true); |
895 // Setting the value might trigger JavaScript, which is capable of | |
896 // destroying the frame. | |
897 if (!field->document().frame()) | |
898 return; | |
robwu
2016/05/04 14:35:38
Are you sure that |field| is still valid?
One of t
vabr (Chromium)
2016/05/04 14:49:46
It's refcounted and a reference is held by the cal
| |
895 } | 899 } |
896 | 900 |
897 field->setAutofilled(true); | 901 field->setAutofilled(true); |
898 | 902 |
899 if (is_initiating_node && | 903 if (is_initiating_node && |
900 ((IsTextInput(input_element) || IsMonthInput(input_element)) || | 904 ((IsTextInput(input_element) || IsMonthInput(input_element)) || |
901 IsTextAreaElement(*field))) { | 905 IsTextAreaElement(*field))) { |
902 int length = field->value().length(); | 906 int length = field->value().length(); |
903 field->setSelectionRange(length, length); | 907 field->setSelectionRange(length, length); |
904 // Clear the current IME composition (the underline), if there is one. | 908 // 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 | 1767 // Zero selection start is for password manager, which can show usernames |
1764 // that do not begin with the user input value. | 1768 // that do not begin with the user input value. |
1765 selection_start = (offset == base::string16::npos) ? 0 : offset; | 1769 selection_start = (offset == base::string16::npos) ? 0 : offset; |
1766 } | 1770 } |
1767 | 1771 |
1768 input_element->setSelectionRange(selection_start, suggestion.length()); | 1772 input_element->setSelectionRange(selection_start, suggestion.length()); |
1769 } | 1773 } |
1770 | 1774 |
1771 } // namespace form_util | 1775 } // namespace form_util |
1772 } // namespace autofill | 1776 } // namespace autofill |
OLD | NEW |